Skip to content

Commit 80c6e96

Browse files
committed
🥅 Add SASL::AuthenticationIncomplete
1 parent 74e4687 commit 80c6e96

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

lib/net/imap.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1266,7 +1266,7 @@ def authenticate(mechanism, *creds, sasl_ir: true, **props, &callback)
12661266
end
12671267
if authenticator.respond_to?(:done?) && !authenticator.done?
12681268
logout!
1269-
raise SASL::AuthenticationFailed, "authentication ended prematurely"
1269+
raise SASL::AuthenticationIncomplete, result
12701270
end
12711271
@capabilities = capabilities_from_resp_code result
12721272
result

lib/net/imap/sasl.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,18 @@ module SASL
114114
# messages has not passed integrity checks.
115115
AuthenticationFailed = Class.new(Error)
116116

117+
# Indicates that authentication cannot proceed because one of the server's
118+
# ended authentication prematurely.
119+
class AuthenticationIncomplete < AuthenticationFailed
120+
# The success response from the server
121+
attr_reader :response
122+
123+
def initialize(response, message = "authentication ended prematurely")
124+
super(message)
125+
@response = response
126+
end
127+
end
128+
117129
# autoloading to avoid loading all of the regexps when they aren't used.
118130
sasl_stringprep_rb = File.expand_path("sasl/stringprep", __dir__)
119131
autoload :StringPrep, sasl_stringprep_rb

test/net/imap/test_imap.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -966,7 +966,7 @@ def test_id
966966
server.state.authenticate(server.config.user)
967967
cmd.done_ok
968968
end
969-
assert_raise(Net::IMAP::SASL::AuthenticationFailed) do
969+
assert_raise(Net::IMAP::SASL::AuthenticationIncomplete) do
970970
imap.authenticate("DIGEST-MD5", "test_user", "test-password",
971971
warn_deprecation: false)
972972
end

0 commit comments

Comments
 (0)