summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorjazzyb <json.barnes@gmail.com>2015-02-05 18:19:03 -0500
committerDonald Stufft <donald@stufft.io>2015-06-12 16:57:14 -0400
commit1787cafb83a02e1e2e740fbdd5b30c32dfc62cf2 (patch)
treebd164bd78644a91920ceccb2d9557d09b7dcd5d9 /tests
parent5b7f6df7141d738c83120a217b208e43685391a9 (diff)
downloadpy-bcrypt-git-1787cafb83a02e1e2e740fbdd5b30c32dfc62cf2.tar.gz
Add tests for gensalt(prefix) functionality
Diffstat (limited to 'tests')
-rw-r--r--tests/test_bcrypt.py10
1 files changed, 10 insertions, 0 deletions
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",