MCPcopy Index your code
hub / github.com/python/cpython / test_auth_function

Method test_auth_function

Lib/test/test_smtplib.py:1231–1251  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1229 smtp.close()
1230
1231 def test_auth_function(self):
1232 supported = {'PLAIN', 'LOGIN'}
1233 try:
1234 hashlib.md5()
1235 except ValueError:
1236 pass
1237 else:
1238 supported.add('CRAM-MD5')
1239 for mechanism in supported:
1240 self.serv.add_feature("AUTH {}".format(mechanism))
1241 for mechanism in supported:
1242 with self.subTest(mechanism=mechanism):
1243 smtp = smtplib.SMTP(HOST, self.port,
1244 local_hostname='localhost',
1245 timeout=support.LOOPBACK_TIMEOUT)
1246 smtp.ehlo('foo')
1247 smtp.user, smtp.password = sim_auth[0], sim_auth[1]
1248 method = 'auth_' + mechanism.lower().replace('-', '_')
1249 resp = smtp.auth(mechanism, getattr(smtp, method))
1250 self.assertEqual(resp, (235, b'Authentication Succeeded'))
1251 smtp.close()
1252
1253 def test_quit_resets_greeting(self):
1254 smtp = smtplib.SMTP(HOST, self.port,

Callers

nothing calls this directly

Calls 10

ehloMethod · 0.95
authMethod · 0.95
closeMethod · 0.95
add_featureMethod · 0.80
addMethod · 0.45
formatMethod · 0.45
subTestMethod · 0.45
replaceMethod · 0.45
lowerMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected