Tests: Add unit tests #808 #3943

This commit is contained in:
graciousgrey
2024-03-27 13:24:09 +01:00
parent 868ac0fa6c
commit 5821ab7e2a
6 changed files with 322 additions and 0 deletions

View File

@@ -42,6 +42,17 @@ func TestUser_Provider(t *testing.T) {
})
}
func TestUser_Method(t *testing.T) {
t.Run("Empty", func(t *testing.T) {
form := &User{UserName: "", UserEmail: "test@test.com", Password: "passwd", AuthMethod: ""}
assert.Equal(t, authn.MethodUndefined, form.Method())
})
t.Run("Valid", func(t *testing.T) {
form := &User{UserName: "John", UserEmail: "test@test.com", Password: "passwd", AuthMethod: "2fa"}
assert.Equal(t, authn.Method2FA, form.Method())
})
}
func TestUser_Email(t *testing.T) {
t.Run("Empty", func(t *testing.T) {
form := &User{UserName: "foobar", UserEmail: "", Password: "passwd"}