diff options
| author | Clement Michaud <clement.michaud34@gmail.com> | 2019-11-24 21:27:59 +0100 |
|---|---|---|
| committer | Clément Michaud <clement.michaud34@gmail.com> | 2019-12-05 11:05:24 +0100 |
| commit | c78a732c6a855792ac864c980677a3c027abc90b (patch) | |
| tree | d585e5089412d692f8fdaf1c52aa7f33ebcb7f55 /internal/handlers/handler_firstfactor_test.go | |
| parent | 373911d1990591e4073926845272f3a48ce2706a (diff) | |
Rewrite and fix remaining suites in Go.
Diffstat (limited to 'internal/handlers/handler_firstfactor_test.go')
| -rw-r--r-- | internal/handlers/handler_firstfactor_test.go | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/internal/handlers/handler_firstfactor_test.go b/internal/handlers/handler_firstfactor_test.go index 11e42b550..241c362a0 100644 --- a/internal/handlers/handler_firstfactor_test.go +++ b/internal/handlers/handler_firstfactor_test.go @@ -3,8 +3,10 @@ package handlers import ( "fmt" "testing" + "time" "github.com/clems4ever/authelia/internal/mocks" + "github.com/clems4ever/authelia/internal/models" "github.com/clems4ever/authelia/internal/authentication" "github.com/golang/mock/gomock" @@ -70,6 +72,32 @@ func (s *FirstFactorSuite) TestShouldFailIfUserProviderCheckPasswordFail() { s.mock.Assert200KO(s.T(), "Authentication failed. Check your credentials.") } +func (s *FirstFactorSuite) TestShouldCheckAuthenticationIsMarkedWhenInvalidCredentials() { + t, _ := time.Parse("2006-Jan-02", "2013-Feb-03") + s.mock.Clock.Set(t) + + s.mock.UserProviderMock. + EXPECT(). + CheckUserPassword(gomock.Eq("test"), gomock.Eq("hello")). + Return(false, fmt.Errorf("Invalid credentials")) + + s.mock.StorageProviderMock. + EXPECT(). + AppendAuthenticationLog(gomock.Eq(models.AuthenticationAttempt{ + Username: "test", + Successful: false, + Time: t, + })) + + s.mock.Ctx.Request.SetBodyString(`{ + "username": "test", + "password": "hello", + "keepMeLoggedIn": true + }`) + + FirstFactorPost(s.mock.Ctx) +} + func (s *FirstFactorSuite) TestShouldFailIfUserProviderGetDetailsFail() { s.mock.UserProviderMock. EXPECT(). |
