Skip to content

Commit 36e5151

Browse files
committed
Allow case-insensitive strings for SASL mechanism
In particular, this erases the difference between :scram_sha_256 (the Net::SMTP authtype) and "SCRAM-SHA-256" (the SASL mechanism).
1 parent 2f7ab43 commit 36e5151

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

lib/net/smtp/authenticator.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ def self.auth_classes
66
end
77

88
def self.auth_type(type)
9+
type = type.to_s.upcase.tr(?_, ?-).to_sym
910
Authenticator.auth_classes[type] = self
1011
end
1112

1213
def self.auth_class(type)
13-
Authenticator.auth_classes[type.intern]
14+
type = type.to_s.upcase.tr(?_, ?-).to_sym
15+
Authenticator.auth_classes[type]
1416
end
1517

1618
attr_reader :smtp

test/net/smtp/test_smtp.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ def test_start_auth_cram_md5
485485
omit "openssl or digest library not loaded" unless defined? OpenSSL or defined? Digest
486486

487487
port = fake_server_start(auth: 'CRAM-MD5')
488-
Net::SMTP.start('localhost', port, user: 'account', password: 'password', authtype: :cram_md5){}
488+
Net::SMTP.start('localhost', port, user: 'account', password: 'password', authtype: "CRAM-MD5"){}
489489

490490
port = fake_server_start(auth: 'CRAM-MD5')
491491
assert_raise Net::SMTPAuthenticationError do

0 commit comments

Comments
 (0)