mirror of
https://github.com/wneessen/apg-go.git
synced 2024-11-22 13:50:49 +01:00
28 lines
524 B
Go
28 lines
524 B
Go
|
package apg
|
||
|
|
||
|
import (
|
||
|
"testing"
|
||
|
)
|
||
|
|
||
|
func TestHasBeenPwned(t *testing.T) {
|
||
|
tests := []struct {
|
||
|
name string
|
||
|
password string
|
||
|
want bool
|
||
|
}{
|
||
|
{"Pwned PW", "Test123", true},
|
||
|
{"Secure PW", "Cta8mWYmW7O*j1V!YMTS", false},
|
||
|
}
|
||
|
for _, tt := range tests {
|
||
|
t.Run(tt.name, func(t *testing.T) {
|
||
|
got, err := HasBeenPwned(tt.password)
|
||
|
if err != nil {
|
||
|
t.Errorf("HasBeenPwned() failed: %s", err)
|
||
|
}
|
||
|
if tt.want != got {
|
||
|
t.Errorf("HasBeenPwned() failed, wanted: %t, got: %t", tt.want, got)
|
||
|
}
|
||
|
})
|
||
|
}
|
||
|
}
|