diff options
| author | James Elliott <james-d-elliott@users.noreply.github.com> | 2022-04-08 14:13:47 +1000 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-04-08 14:13:47 +1000 | 
| commit | ce6bf74c8d9013171066482c628c9e60fe6c741e (patch) | |
| tree | c61cd60de5d86779b37eda687bf24e54cc43360b /internal/handlers/handler_user_info_test.go | |
| parent | 90edf11b88a23c2a6ce68a7ab71e3c2fbad9118d (diff) | |
fix(server): incorrect remote ip logged in error handler (#3139)
This fixes edge cases where the remote IP was not correctly logged. Generally this is not an issue as most errors do not hit this handler, but in instances where a transport error occurs this is important.
Diffstat (limited to 'internal/handlers/handler_user_info_test.go')
| -rw-r--r-- | internal/handlers/handler_user_info_test.go | 12 | 
1 files changed, 6 insertions, 6 deletions
diff --git a/internal/handlers/handler_user_info_test.go b/internal/handlers/handler_user_info_test.go index d2fd256a7..e4d0fa659 100644 --- a/internal/handlers/handler_user_info_test.go +++ b/internal/handlers/handler_user_info_test.go @@ -390,7 +390,7 @@ func (s *SaveSuite) TearDownTest() {  func (s *SaveSuite) TestShouldReturnError500WhenNoBodyProvided() {  	s.mock.Ctx.Request.SetBody(nil) -	MethodPreferencePost(s.mock.Ctx) +	MethodPreferencePOST(s.mock.Ctx)  	s.mock.Assert200KO(s.T(), "Operation failed.")  	assert.Equal(s.T(), "unable to parse body: unexpected end of JSON input", s.mock.Hook.LastEntry().Message) @@ -399,7 +399,7 @@ func (s *SaveSuite) TestShouldReturnError500WhenNoBodyProvided() {  func (s *SaveSuite) TestShouldReturnError500WhenMalformedBodyProvided() {  	s.mock.Ctx.Request.SetBody([]byte("{\"method\":\"abc\"")) -	MethodPreferencePost(s.mock.Ctx) +	MethodPreferencePOST(s.mock.Ctx)  	s.mock.Assert200KO(s.T(), "Operation failed.")  	assert.Equal(s.T(), "unable to parse body: unexpected end of JSON input", s.mock.Hook.LastEntry().Message) @@ -408,7 +408,7 @@ func (s *SaveSuite) TestShouldReturnError500WhenMalformedBodyProvided() {  func (s *SaveSuite) TestShouldReturnError500WhenBadBodyProvided() {  	s.mock.Ctx.Request.SetBody([]byte("{\"weird_key\":\"abc\"}")) -	MethodPreferencePost(s.mock.Ctx) +	MethodPreferencePOST(s.mock.Ctx)  	s.mock.Assert200KO(s.T(), "Operation failed.")  	assert.Equal(s.T(), "unable to validate body: method: non zero value required", s.mock.Hook.LastEntry().Message) @@ -417,7 +417,7 @@ func (s *SaveSuite) TestShouldReturnError500WhenBadBodyProvided() {  func (s *SaveSuite) TestShouldReturnError500WhenBadMethodProvided() {  	s.mock.Ctx.Request.SetBody([]byte("{\"method\":\"abc\"}")) -	MethodPreferencePost(s.mock.Ctx) +	MethodPreferencePOST(s.mock.Ctx)  	s.mock.Assert200KO(s.T(), "Operation failed.")  	assert.Equal(s.T(), "unknown or unavailable method 'abc', it should be one of totp, webauthn", s.mock.Hook.LastEntry().Message) @@ -430,7 +430,7 @@ func (s *SaveSuite) TestShouldReturnError500WhenDatabaseFailsToSave() {  		SavePreferred2FAMethod(s.mock.Ctx, gomock.Eq("john"), gomock.Eq("webauthn")).  		Return(fmt.Errorf("Failure")) -	MethodPreferencePost(s.mock.Ctx) +	MethodPreferencePOST(s.mock.Ctx)  	s.mock.Assert200KO(s.T(), "Operation failed.")  	assert.Equal(s.T(), "unable to save new preferred 2FA method: Failure", s.mock.Hook.LastEntry().Message) @@ -443,7 +443,7 @@ func (s *SaveSuite) TestShouldReturn200WhenMethodIsSuccessfullySaved() {  		SavePreferred2FAMethod(s.mock.Ctx, gomock.Eq("john"), gomock.Eq("webauthn")).  		Return(nil) -	MethodPreferencePost(s.mock.Ctx) +	MethodPreferencePOST(s.mock.Ctx)  	assert.Equal(s.T(), 200, s.mock.Ctx.Response.StatusCode())  }  | 
