Skip to content

Commit c3f7e7c

Browse files
committed
🐛 Fix authenticate using Symbol mechanism name
Based on `net-smtp`, I had added the ability to use symbols to lookup authenticator. But it had two issues: 1) dealing with dashes vs underscores, and 2) sending the mechanism name using flag syntax. This fixes both issues.
1 parent 965f9a3 commit c3f7e7c

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

lib/net/imap.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1248,6 +1248,7 @@ def starttls(**options)
12481248
# completes. If the TaggedResponse to #authenticate includes updated
12491249
# capabilities, they will be cached.
12501250
def authenticate(mechanism, *creds, sasl_ir: true, **props, &callback)
1251+
mechanism = mechanism.to_s.tr("_", "-").upcase
12511252
authenticator = SASL.authenticator(mechanism, *creds, **props, &callback)
12521253
cmdargs = ["AUTHENTICATE", mechanism]
12531254
if sasl_ir && capable?("SASL-IR") && auth_capable?(mechanism) &&

test/net/imap/test_imap.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -934,7 +934,7 @@ def test_id
934934
server.state.authenticate(server.config.user)
935935
cmd.done_ok
936936
end
937-
imap.authenticate("DIGEST-MD5", "test_user", "test-password",
937+
imap.authenticate(:digest_md5, "test_user", "test-password",
938938
warn_deprecation: false)
939939
cmd, cont1, cont2 = 3.times.map { server.commands.pop }
940940
assert_equal %w[AUTHENTICATE DIGEST-MD5], [cmd.name, *cmd.args]

0 commit comments

Comments
 (0)