Skip to content

Commit

Permalink
Merge pull request #64 from nevans/sasl/case-insensitive-authtype-str…
Browse files Browse the repository at this point in the history
…ings

Allow case-insensitive strings for SASL mechanism
  • Loading branch information
tmtm authored Oct 15, 2023
2 parents bf27727 + 5eedded commit 808cc3f
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 808cc3f

Please sign in to comment.