Skip to content

Commit

Permalink
Allow case-insensitive strings for SASL mechanism
Browse files Browse the repository at this point in the history
In particular, this erases the difference between :scram_sha_256 (the
Net::SMTP authtype) and "SCRAM-SHA-256" (the SASL mechanism).
  • Loading branch information
nevans committed Oct 9, 2023
1 parent b84a0bb commit a08d6dc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion lib/net/smtp/authenticator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ def self.auth_classes
end

def self.auth_type(type)
type = type.to_s.upcase.tr(?_, ?-).to_sym
Authenticator.auth_classes[type] = self
end

def self.auth_class(type)
Authenticator.auth_classes[type.intern]
type = type.to_s.upcase.tr(?_, ?-).to_sym
Authenticator.auth_classes[type]
end

attr_reader :smtp
Expand Down
2 changes: 1 addition & 1 deletion test/net/smtp/test_smtp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ def test_start_auth_cram_md5
omit "openssl or digest library not loaded" unless defined? OpenSSL or defined? Digest

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

port = fake_server_start(auth: 'CRAM-MD5')
assert_raise Net::SMTPAuthenticationError do
Expand Down

0 comments on commit a08d6dc

Please sign in to comment.