summaryrefslogtreecommitdiff
path: root/test/net/imap
diff options
context:
space:
mode:
authornicholas a. evans <nicholas.evans@gmail.com>2021-04-27 17:49:22 -0400
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2021-05-06 15:20:34 +0900
commit912f39b2c34103620c414d11bc4e61ca28018226 (patch)
treeddb740d5dff6c3274ea14708bf503344bad1dab0 /test/net/imap
parent331005812fc288fb27bef542ecfbb2c061d86999 (diff)
[ruby/net-imap] Update AUTH=PLAIN to be a little closer to RFC4616
* Add authzid support * must not contain NULL chars * improve rdoc https://github.com/ruby/net-imap/commit/a587fc71b7
Diffstat (limited to 'test/net/imap')
-rw-r--r--test/net/imap/test_imap_authenticators.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/net/imap/test_imap_authenticators.rb b/test/net/imap/test_imap_authenticators.rb
new file mode 100644
index 0000000000..0c7a0a325d
--- /dev/null
+++ b/test/net/imap/test_imap_authenticators.rb
@@ -0,0 +1,23 @@
+# frozen_string_literal: true
+
+require "net/imap"
+require "test/unit"
+
+class IMAPAuthenticatorsTest < Test::Unit::TestCase
+
+ PLAIN = Net::IMAP::PlainAuthenticator
+
+ def test_plain
+ assert_equal("\0authc\0passwd",
+ PLAIN.new("authc", "passwd").process(nil))
+ assert_equal("authz\0user\0pass",
+ PLAIN.new("user", "pass", authzid: "authz").process(nil))
+ end
+
+ def test_plain_no_null_chars
+ assert_raise(ArgumentError) { PLAIN.new("bad\0user", "pass") }
+ assert_raise(ArgumentError) { PLAIN.new("user", "bad\0pass") }
+ assert_raise(ArgumentError) { PLAIN.new("u", "p", authzid: "bad\0authz") }
+ end
+
+end