Add option to check for weak passwords

This commit is contained in:
eikendev 2021-01-16 15:29:04 +01:00
parent ad56422838
commit b06bd51d21
No known key found for this signature in database
GPG key ID: A1BDB1B28C8EF694
12 changed files with 141 additions and 15 deletions

View file

@ -0,0 +1,23 @@
package credentials
import "testing"
type isPasswordPwnedTest struct {
arg string
exp1 bool
exp2 error
}
var isPasswordPwnedTests = []isPasswordPwnedTest{
{"", true, nil},
{"password", true, nil},
{"2y6bWMETuHpNP08HCZq00QAAzE6nmwEb", false, nil},
}
func TestIsPasswordPwned(t *testing.T) {
for _, test := range isPasswordPwnedTests {
if out1, out2 := IsPasswordPwned(test.arg); out1 != test.exp1 || out2 != test.exp2 {
t.Errorf("Output (%t,%q) not equal to expected (%t,%q)", out1, out2, test.exp1, test.exp2)
}
}
}