Skip to content

Commit 83f9103

Browse files
committed
Remove obsolete Authenticator implementations
The versions from `net-imap` are more full-featured. E.g: they support `authzid` and print deprecation warnings for MD5 authenticators. The tests are updated to silence deprecation warnings, which are printed by the authenticators from `net-imap`.
1 parent 4913bf4 commit 83f9103

File tree

4 files changed

+24
-94
lines changed

4 files changed

+24
-94
lines changed

lib/net/smtp/auth_cram_md5.rb

Lines changed: 0 additions & 53 deletions
This file was deleted.

lib/net/smtp/auth_login.rb

Lines changed: 0 additions & 16 deletions
This file was deleted.

lib/net/smtp/auth_plain.rb

Lines changed: 0 additions & 14 deletions
This file was deleted.

test/net/smtp/test_smtp.rb

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -138,23 +138,28 @@ def test_unsucessful_auth_plain
138138
def test_auth_cram_md5
139139
server = FakeServer.start(auth: 'CRAM-MD5')
140140
smtp = Net::SMTP.start 'localhost', server.port
141-
assert smtp.auth(:cram_md5, "account", password: "password").success?
141+
assert smtp.auth(:cram_md5, "account", password: "password",
142+
warn_deprecation: false).success?
142143
end
143144

144145
def test_auth_login
145146
server = FakeServer.start(auth: 'login')
146147
smtp = Net::SMTP.start 'localhost', server.port
147-
assert smtp.authenticate("account", "password", :login).success?
148+
assert smtp.auth(:login, "account", "password",
149+
warn_deprecation: false).success?
148150

149151
server = FakeServer.start(auth: 'login')
150152
smtp = Net::SMTP.start 'localhost', server.port
151-
assert smtp.auth("LOGIN", username: "account", secret: "password").success?
153+
assert smtp.auth(username: "account", secret: "password",
154+
type: :login, warn_deprecation: false).success?
152155
end
153156

154157
def test_unsucessful_auth_login
155158
server = FakeServer.start(auth: 'login')
156159
smtp = Net::SMTP.start 'localhost', server.port
157-
err = assert_raise(Net::SMTPAuthenticationError) { smtp.authenticate("foo", "bar", :login) }
160+
err = assert_raise(Net::SMTPAuthenticationError) {
161+
smtp.auth(:login, "foo", "bar", warn_deprecation: false)
162+
}
158163
assert_equal "535 5.7.8 Error: authentication failed: authentication failure\n", err.message
159164
assert_equal "535", err.response.status
160165
end
@@ -167,7 +172,9 @@ def server.auth(*)
167172
@sock.puts "235 2.7.0 Authentication successful\r\n"
168173
end
169174
smtp = Net::SMTP.start 'localhost', server.port
170-
err = assert_raise(Net::SMTPUnknownError) { smtp.authenticate("account", "password", :login) }
175+
err = assert_raise(Net::SMTPUnknownError) {
176+
smtp.auth(:login, "account", "password", warn_deprecation: false)
177+
}
171178
assert_equal "235 2.7.0 Authentication successful\n", err.message
172179
assert_equal "235", err.response.status
173180
end
@@ -502,33 +509,39 @@ def test_start_auth_plain
502509

503510
def test_start_auth_login
504511
port = fake_server_start(auth: 'LOGIN')
505-
Net::SMTP.start('localhost', port, user: 'account', password: 'password', authtype: :login){}
512+
Net::SMTP.start('localhost', port, user: 'account', password: 'password',
513+
authtype: :login, auth: {warn_deprecation: false}){}
506514

507515
port = fake_server_start(auth: 'LOGIN')
508516
assert_raise Net::SMTPAuthenticationError do
509-
Net::SMTP.start('localhost', port, user: 'account', password: 'invalid', authtype: :login){}
517+
Net::SMTP.start('localhost', port, user: 'account', password: 'invalid',
518+
authtype: :login, auth: {warn_deprecation: false}){}
510519
end
511520

512521
port = fake_server_start(auth: 'PLAIN')
513522
assert_raise Net::SMTPAuthenticationError do
514-
Net::SMTP.start('localhost', port, user: 'account', password: 'password', authtype: :login){}
523+
Net::SMTP.start('localhost', port, user: 'account', password: 'password',
524+
authtype: :login, auth: {warn_deprecation: false}){}
515525
end
516526
end
517527

518528
def test_start_auth_cram_md5
519529
omit "openssl or digest library not loaded" unless defined? OpenSSL or defined? Digest
520530

521531
port = fake_server_start(auth: 'CRAM-MD5')
522-
Net::SMTP.start('localhost', port, user: 'account', password: 'password', authtype: "CRAM-MD5"){}
532+
Net::SMTP.start('localhost', port, user: 'account', password: 'password',
533+
authtype: "CRAM-MD5", auth: {warn_deprecation: false}){}
523534

524535
port = fake_server_start(auth: 'CRAM-MD5')
525536
assert_raise Net::SMTPAuthenticationError do
526-
Net::SMTP.start('localhost', port, user: 'account', password: 'invalid', authtype: :cram_md5){}
537+
Net::SMTP.start('localhost', port, user: 'account', password: 'invalid',
538+
authtype: :cram_md5, auth: {warn_deprecation: false}){}
527539
end
528540

529541
port = fake_server_start(auth: 'PLAIN')
530542
assert_raise Net::SMTPAuthenticationError do
531-
Net::SMTP.start('localhost', port, user: 'account', password: 'password', authtype: :cram_md5){}
543+
Net::SMTP.start('localhost', port, user: 'account', password: 'password',
544+
authtype: :cram_md5, auth: {warn_deprecation: false}){}
532545
end
533546
end
534547

0 commit comments

Comments
 (0)