Skip to content

Commit 7cd553e

Browse files
committed
address review
1 parent 1603315 commit 7cd553e

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

test/test_uri_parser.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,32 @@ def test_parse_uri(self):
293293
self.assertEqual(res, parse_uri("mongodb://localhost/?readPreference=secondary"))
294294

295295
# Various authentication tests
296+
res = copy.deepcopy(orig)
297+
res["options"] = {"authmechanism": "SCRAM-SHA-256"}
298+
res["username"] = "user"
299+
res["password"] = "password"
300+
self.assertEqual(
301+
res, parse_uri("mongodb://user:password@localhost/?authMechanism=SCRAM-SHA-256")
302+
)
303+
304+
res = copy.deepcopy(orig)
305+
res["options"] = {"authmechanism": "SCRAM-SHA-256", "authsource": "bar"}
306+
res["username"] = "user"
307+
res["password"] = "password"
308+
res["database"] = "foo"
309+
self.assertEqual(
310+
res,
311+
parse_uri(
312+
"mongodb://user:password@localhost/foo?authSource=bar;authMechanism=SCRAM-SHA-256"
313+
),
314+
)
315+
316+
res = copy.deepcopy(orig)
317+
res["options"] = {"authmechanism": "SCRAM-SHA-256"}
318+
res["username"] = "user"
319+
res["password"] = ""
320+
self.assertEqual(res, parse_uri("mongodb://user:@localhost/?authMechanism=SCRAM-SHA-256"))
321+
296322
res = copy.deepcopy(orig)
297323
res["username"] = "[email protected]"
298324
res["password"] = "password"

0 commit comments

Comments
 (0)