From 1787cafb83a02e1e2e740fbdd5b30c32dfc62cf2 Mon Sep 17 00:00:00 2001 From: jazzyb Date: Thu, 5 Feb 2015 18:19:03 -0500 Subject: [PATCH] Add tests for gensalt(prefix) functionality --- tests/test_bcrypt.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/test_bcrypt.py b/tests/test_bcrypt.py index cdbca27..32fa15f 100644 --- a/tests/test_bcrypt.py +++ b/tests/test_bcrypt.py @@ -48,6 +48,16 @@ def test_gensalt_rounds_invalid(rounds, monkeypatch): bcrypt.gensalt(rounds) +def test_gensalt_bad_prefix(): + with pytest.raises(ValueError): + bcrypt.gensalt(prefix="bad") + + +def test_gensalt_2a_prefix(monkeypatch): + monkeypatch.setattr(os, "urandom", lambda n: b"0000000000000000") + assert bcrypt.gensalt(prefix=b"2a") == b"$2a$12$KB.uKB.uKB.uKB.uKB.uK." + + @pytest.mark.parametrize(("password", "salt", "expected"), [ ( b"Kk4DQuMMfZL9o",