initial commit
This commit is contained in:
commit
54576d9d33
61 changed files with 5569 additions and 0 deletions
22
internal/password/password_test.go
Normal file
22
internal/password/password_test.go
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
package password
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestHashAndVerify(t *testing.T) {
|
||||
encoded, err := Hash("correct horse battery staple")
|
||||
if err != nil {
|
||||
t.Fatalf("Hash() error = %v", err)
|
||||
}
|
||||
if !Verify(encoded, "correct horse battery staple") {
|
||||
t.Fatal("expected password to verify")
|
||||
}
|
||||
if Verify(encoded, "incorrect password") {
|
||||
t.Fatal("expected incorrect password to fail")
|
||||
}
|
||||
}
|
||||
|
||||
func TestHashRejectsShortPassword(t *testing.T) {
|
||||
if _, err := Hash("too-short"); err == nil {
|
||||
t.Fatal("expected short password to fail")
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue