[ruby/net-imap] Update AUTH=PLAIN to be a little closer to RFC4616

* Add authzid support
* must not contain NULL chars
* improve rdoc

a587fc71b7
This commit is contained in:
nicholas a. evans 2021-04-27 17:49:22 -04:00 committed by Hiroshi SHIBATA
parent 331005812f
commit 912f39b2c3
No known key found for this signature in database
GPG key ID: F9CF13417264FAC2
2 changed files with 41 additions and 3 deletions

View file

@ -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