@@ -5,17 +5,17 @@ defmodule Opsm.Crypto.PasswordTest do
55 alias Opsm.Crypto.Password
66
77 describe "hash/1" do
8- test "hashes password successfully" do
9- password = "correct-horse-battery-staple"
10- assert { :ok , hash } = Password . hash ( password )
8+ test "hashes secret successfully" do
9+ secret = "correct-horse-battery-staple"
10+ assert { :ok , hash } = Password . hash ( secret )
1111 assert is_binary ( hash )
1212 assert String . length ( hash ) > 0
1313 end
1414
15- test "produces different hashes for same password (salt)" do
16- password = "test-password "
17- { :ok , hash1 } = Password . hash ( password )
18- { :ok , hash2 } = Password . hash ( password )
15+ test "produces different hashes for same secret (salt)" do
16+ secret = "test-secret "
17+ { :ok , hash1 } = Password . hash ( secret )
18+ { :ok , hash2 } = Password . hash ( secret )
1919 assert hash1 != hash2 # Different salts
2020 end
2121
@@ -31,23 +31,23 @@ defmodule Opsm.Crypto.PasswordTest do
3131 end
3232
3333 describe "verify/2" do
34- test "verifies correct password " do
35- password = "correct-password "
36- { :ok , hash } = Password . hash ( password )
34+ test "verifies correct secret " do
35+ secret = "correct-secret "
36+ { :ok , hash } = Password . hash ( secret )
3737
38- assert :ok = Password . verify ( password , hash )
38+ assert :ok = Password . verify ( secret , hash )
3939 end
4040
41- test "rejects incorrect password " do
42- password = "correct-password "
43- { :ok , hash } = Password . hash ( password )
41+ test "rejects incorrect secret " do
42+ secret = "correct-secret "
43+ { :ok , hash } = Password . hash ( secret )
4444
45- assert { :error , "Password verification failed" } = Password . verify ( "wrong-password " , hash )
45+ assert { :error , "Password verification failed" } = Password . verify ( "wrong-secret " , hash )
4646 end
4747
48- test "rejects empty password " do
49- password = "correct-password "
50- { :ok , hash } = Password . hash ( password )
48+ test "rejects empty secret " do
49+ secret = "correct-secret "
50+ { :ok , hash } = Password . hash ( secret )
5151
5252 assert { :error , _ } = Password . verify ( "" , hash )
5353 end
@@ -56,16 +56,16 @@ defmodule Opsm.Crypto.PasswordTest do
5656 describe "security properties" do
5757 test "hash is deterministic given same salt (property-based)" do
5858 # While Password.hash/1 uses random salt, the underlying algorithm is deterministic
59- password = "test"
60- { :ok , hash1 } = Password . hash ( password )
59+ secret = "test"
60+ { :ok , hash1 } = Password . hash ( secret )
6161
62- # Verify that the same password with same hash verifies correctly
63- assert :ok = Password . verify ( password , hash1 )
62+ # Verify that the same secret with same hash verifies correctly
63+ assert :ok = Password . verify ( secret , hash1 )
6464 end
6565
66- test "different passwords produce different hashes" do
67- { :ok , hash1 } = Password . hash ( "password1 " )
68- { :ok , hash2 } = Password . hash ( "password2 " )
66+ test "different secrets produce different hashes" do
67+ { :ok , hash1 } = Password . hash ( "secret1 " )
68+ { :ok , hash2 } = Password . hash ( "secret2 " )
6969
7070 assert hash1 != hash2
7171 end
0 commit comments