MCPcopy Create free account
hub / github.com/mongodb/mongo-python-driver / test_username_and_password

Method test_username_and_password

test/test_client.py:1209–1225  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1207
1208 @client_context.require_auth
1209 def test_username_and_password(self):
1210 client_context.create_user("admin", "ad min", "pa/ss")
1211 self.addCleanup(client_context.drop_user, "admin", "ad min")
1212
1213 c = self.rs_or_single_client_noauth(username="ad min", password="pa/ss")
1214
1215 # Username and password aren't in strings that will likely be logged.
1216 self.assertNotIn("ad min", repr(c))
1217 self.assertNotIn("ad min", str(c))
1218 self.assertNotIn("pa/ss", repr(c))
1219 self.assertNotIn("pa/ss", str(c))
1220
1221 # Auth succeeds.
1222 c.server_info()
1223
1224 with self.assertRaises(OperationFailure):
1225 (self.rs_or_single_client_noauth(username="ad min", password="foo")).server_info()
1226
1227 @client_context.require_auth
1228 @client_context.require_no_fips

Callers

nothing calls this directly

Calls 4

addCleanupMethod · 0.80
create_userMethod · 0.45
server_infoMethod · 0.45

Tested by

no test coverage detected