[MISC] Ignore errcheck recommendations for legacy code (#893)

* [MISC] Ignore errcheck recommendations for legacy code
Some of this is likely intended to stay how it is, some could use refactoring, for now we will mark is and ignore it from the linter to be potentially addressed in the future.

* [MISC] Ensure files are gofmt-ed
pull/894/head^2
Amir Zarrinkafsh 2020-04-22 13:33:14 +10:00 committed by GitHub
parent fca190dedc
commit 54694c4fca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
32 changed files with 83 additions and 83 deletions

View File

@ -172,9 +172,9 @@ func setupSuite(suiteName string) error {
if errSetup := runSuiteSetupTeardown("setup", suiteName); errSetup != nil || interrupted { if errSetup := runSuiteSetupTeardown("setup", suiteName); errSetup != nil || interrupted {
if errSetup == utils.ErrTimeoutReached { if errSetup == utils.ErrTimeoutReached {
runOnSetupTimeout(suiteName) runOnSetupTimeout(suiteName) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
} }
teardownSuite(suiteName) teardownSuite(suiteName) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
return errSetup return errSetup
} }

View File

@ -149,7 +149,7 @@ func TestShouldEscapeUserInput(t *testing.T) {
Search(NewSearchRequestMatcher("(|(uid=john\\=abc)(mail=john\\=abc))")). Search(NewSearchRequestMatcher("(|(uid=john\\=abc)(mail=john\\=abc))")).
Return(&ldap.SearchResult{}, nil) Return(&ldap.SearchResult{}, nil)
ldapClient.getUserProfile(mockConn, "john=abc") ldapClient.getUserProfile(mockConn, "john=abc") //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
} }
func TestShouldCombineUsernameFilterAndUsersFilter(t *testing.T) { func TestShouldCombineUsernameFilterAndUsersFilter(t *testing.T) {
@ -174,7 +174,7 @@ func TestShouldCombineUsernameFilterAndUsersFilter(t *testing.T) {
Search(NewSearchRequestMatcher("(&(uid=john)(&(objectCategory=person)(objectClass=user)))")). Search(NewSearchRequestMatcher("(&(uid=john)(&(objectCategory=person)(objectClass=user)))")).
Return(&ldap.SearchResult{}, nil) Return(&ldap.SearchResult{}, nil)
ldapClient.getUserProfile(mockConn, "john") ldapClient.getUserProfile(mockConn, "john") //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
} }
func createSearchResultWithAttributes(attributes ...*ldap.EntryAttribute) *ldap.SearchResult { func createSearchResultWithAttributes(attributes ...*ldap.EntryAttribute) *ldap.SearchResult {

View File

@ -26,10 +26,10 @@ var MigrateLocalCmd = &cobra.Command{
func init() { func init() {
MigrateLocalCmd.PersistentFlags().StringVarP(&localDatabasePath, "db-path", "p", "", "The path to the v3 local database") MigrateLocalCmd.PersistentFlags().StringVarP(&localDatabasePath, "db-path", "p", "", "The path to the v3 local database")
MigrateLocalCmd.MarkPersistentFlagRequired("db-path") MigrateLocalCmd.MarkPersistentFlagRequired("db-path") //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
MigrateLocalCmd.PersistentFlags().StringVarP(&configurationPath, "config", "c", "", "The configuration file of Authelia v4") MigrateLocalCmd.PersistentFlags().StringVarP(&configurationPath, "config", "c", "", "The configuration file of Authelia v4")
MigrateLocalCmd.MarkPersistentFlagRequired("config") MigrateLocalCmd.MarkPersistentFlagRequired("config") //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
} }
// migrateLocal data from v3 to v4. // migrateLocal data from v3 to v4.
@ -58,7 +58,7 @@ func migrateLocalTOTPSecret(dbProvider storage.Provider) {
data := scanner.Text() data := scanner.Text()
entry := TOTPSecretsV3{} entry := TOTPSecretsV3{}
json.Unmarshal([]byte(data), &entry) json.Unmarshal([]byte(data), &entry) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
err := dbProvider.SaveTOTPSecret(entry.UserID, entry.Secret.Base32) err := dbProvider.SaveTOTPSecret(entry.UserID, entry.Secret.Base32)
if err != nil { if err != nil {
@ -80,7 +80,7 @@ func migrateLocalU2FSecret(dbProvider storage.Provider) {
data := scanner.Text() data := scanner.Text()
entry := U2FDeviceHandleV3{} entry := U2FDeviceHandleV3{}
json.Unmarshal([]byte(data), &entry) json.Unmarshal([]byte(data), &entry) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
kH, err := decodeWebsafeBase64(entry.Registration.KeyHandle) kH, err := decodeWebsafeBase64(entry.Registration.KeyHandle)
@ -115,7 +115,7 @@ func migrateLocalPreferences(dbProvider storage.Provider) {
data := scanner.Text() data := scanner.Text()
entry := PreferencesV3{} entry := PreferencesV3{}
json.Unmarshal([]byte(data), &entry) json.Unmarshal([]byte(data), &entry) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
err := dbProvider.SavePreferred2FAMethod(entry.UserID, entry.Method) err := dbProvider.SavePreferred2FAMethod(entry.UserID, entry.Method)
if err != nil { if err != nil {
@ -137,7 +137,7 @@ func migrateLocalAuthenticationTraces(dbProvider storage.Provider) {
data := scanner.Text() data := scanner.Text()
entry := AuthenticationTraceV3{} entry := AuthenticationTraceV3{}
json.Unmarshal([]byte(data), &entry) json.Unmarshal([]byte(data), &entry) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
attempt := models.AuthenticationAttempt{ attempt := models.AuthenticationAttempt{
Username: entry.UserID, Username: entry.UserID,

View File

@ -26,13 +26,13 @@ var MigrateMongoCmd = &cobra.Command{
func init() { func init() {
MigrateMongoCmd.PersistentFlags().StringVar(&mongoURL, "url", "", "The address to the mongo server") MigrateMongoCmd.PersistentFlags().StringVar(&mongoURL, "url", "", "The address to the mongo server")
MigrateMongoCmd.MarkPersistentFlagRequired("url") MigrateMongoCmd.MarkPersistentFlagRequired("url") //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
MigrateMongoCmd.PersistentFlags().StringVar(&mongoDatabase, "database", "", "The mongo database") MigrateMongoCmd.PersistentFlags().StringVar(&mongoDatabase, "database", "", "The mongo database")
MigrateMongoCmd.MarkPersistentFlagRequired("database") MigrateMongoCmd.MarkPersistentFlagRequired("database") //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
MigrateMongoCmd.PersistentFlags().StringVarP(&configurationPath, "config", "c", "", "The configuration file of Authelia v4") MigrateMongoCmd.PersistentFlags().StringVarP(&configurationPath, "config", "c", "", "The configuration file of Authelia v4")
MigrateMongoCmd.MarkPersistentFlagRequired("config") MigrateMongoCmd.MarkPersistentFlagRequired("config") //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
} }
func migrateMongo(cmd *cobra.Command, args []string) { func migrateMongo(cmd *cobra.Command, args []string) {

View File

@ -17,14 +17,14 @@ func Read(configPath string) (*schema.Configuration, []error) {
// we need to bind all env variables as long as https://github.com/spf13/viper/issues/761 // we need to bind all env variables as long as https://github.com/spf13/viper/issues/761
// is not resolved. // is not resolved.
viper.BindEnv("jwt_secret") viper.BindEnv("jwt_secret") //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
viper.BindEnv("duo_api.secret_key") viper.BindEnv("duo_api.secret_key") //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
viper.BindEnv("session.secret") viper.BindEnv("session.secret") //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
viper.BindEnv("authentication_backend.ldap.password") viper.BindEnv("authentication_backend.ldap.password") //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
viper.BindEnv("notifier.smtp.password") viper.BindEnv("notifier.smtp.password") //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
viper.BindEnv("session.redis.password") viper.BindEnv("session.redis.password") //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
viper.BindEnv("storage.mysql.password") viper.BindEnv("storage.mysql.password") //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
viper.BindEnv("storage.postgres.password") viper.BindEnv("storage.postgres.password") //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
viper.SetConfigFile(configPath) viper.SetConfigFile(configPath)
@ -35,7 +35,7 @@ func Read(configPath string) (*schema.Configuration, []error) {
} }
var configuration schema.Configuration var configuration schema.Configuration
viper.Unmarshal(&configuration) viper.Unmarshal(&configuration) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
val := schema.NewStructValidator() val := schema.NewStructValidator()
validator.Validate(&configuration, val) validator.Validate(&configuration, val)

View File

@ -39,7 +39,7 @@ func (v *Validator) validateOne(item QueueItem, q *queue.Queue) error { //nolint
} }
elem := item.value.Elem() elem := item.value.Elem()
q.Put(QueueItem{ q.Put(QueueItem{ //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
value: elem, value: elem,
path: item.path, path: item.path,
}) })
@ -58,7 +58,7 @@ func (v *Validator) validateOne(item QueueItem, q *queue.Queue) error { //nolint
field := item.value.Type().Field(i) field := item.value.Type().Field(i)
value := item.value.Field(i) value := item.value.Field(i)
q.Put(QueueItem{ q.Put(QueueItem{ //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
value: value, value: value,
path: item.path + "." + field.Name, path: item.path + "." + field.Name,
}) })
@ -70,7 +70,7 @@ func (v *Validator) validateOne(item QueueItem, q *queue.Queue) error { //nolint
// Validate validate a struct // Validate validate a struct
func (v *Validator) Validate(s interface{}) error { func (v *Validator) Validate(s interface{}) error {
q := queue.New(40) q := queue.New(40)
q.Put(QueueItem{value: reflect.ValueOf(s), path: "root"}) q.Put(QueueItem{value: reflect.ValueOf(s), path: "root"}) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
for !q.Empty() { for !q.Empty() {
val, err := q.Get(1) val, err := q.Get(1)
@ -81,7 +81,7 @@ func (v *Validator) Validate(s interface{}) error {
if !ok { if !ok {
return fmt.Errorf("Cannot convert item into QueueItem") return fmt.Errorf("Cannot convert item into QueueItem")
} }
v.validateOne(item, q) v.validateOne(item, q) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
} }
return nil return nil
} }

View File

@ -16,5 +16,5 @@ func ConfigurationGet(ctx *middlewares.AutheliaCtx) {
RememberMe: ctx.Providers.SessionProvider.RememberMe != 0, RememberMe: ctx.Providers.SessionProvider.RememberMe != 0,
ResetPassword: !ctx.Configuration.AuthenticationBackend.DisableResetPassword, ResetPassword: !ctx.Configuration.AuthenticationBackend.DisableResetPassword,
} }
ctx.SetJSONBody(body) ctx.SetJSONBody(body) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
} }

View File

@ -26,5 +26,5 @@ func ExtendedConfigurationGet(ctx *middlewares.AutheliaCtx) {
ctx.Logger.Tracef("Second factor enabled: %v", body.SecondFactorEnabled) ctx.Logger.Tracef("Second factor enabled: %v", body.SecondFactorEnabled)
ctx.Logger.Tracef("Available methods are %s", body.AvailableMethods) ctx.Logger.Tracef("Available methods are %s", body.AvailableMethods)
ctx.SetJSONBody(body) ctx.SetJSONBody(body) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
} }

View File

@ -35,7 +35,7 @@ func FirstFactorPost(ctx *middlewares.AutheliaCtx) {
if err != nil { if err != nil {
ctx.Logger.Debugf("Mark authentication attempt made by user %s", bodyJSON.Username) ctx.Logger.Debugf("Mark authentication attempt made by user %s", bodyJSON.Username)
ctx.Providers.Regulator.Mark(bodyJSON.Username, false) ctx.Providers.Regulator.Mark(bodyJSON.Username, false) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
ctx.Error(fmt.Errorf("Error while checking password for user %s: %s", bodyJSON.Username, err.Error()), authenticationFailedMessage) ctx.Error(fmt.Errorf("Error while checking password for user %s: %s", bodyJSON.Username, err.Error()), authenticationFailedMessage)
return return
@ -43,7 +43,7 @@ func FirstFactorPost(ctx *middlewares.AutheliaCtx) {
if !userPasswordOk { if !userPasswordOk {
ctx.Logger.Debugf("Mark authentication attempt made by user %s", bodyJSON.Username) ctx.Logger.Debugf("Mark authentication attempt made by user %s", bodyJSON.Username)
ctx.Providers.Regulator.Mark(bodyJSON.Username, false) ctx.Providers.Regulator.Mark(bodyJSON.Username, false) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
ctx.ReplyError(fmt.Errorf("Credentials are wrong for user %s", bodyJSON.Username), authenticationFailedMessage) ctx.ReplyError(fmt.Errorf("Credentials are wrong for user %s", bodyJSON.Username), authenticationFailedMessage)
return return

View File

@ -21,7 +21,7 @@ func (s *LogoutSuite) SetupTest() {
s.mock = mocks.NewMockAutheliaCtx(s.T()) s.mock = mocks.NewMockAutheliaCtx(s.T())
userSession := s.mock.Ctx.GetSession() userSession := s.mock.Ctx.GetSession()
userSession.Username = "john" userSession.Username = "john"
s.mock.Ctx.SaveSession(userSession) s.mock.Ctx.SaveSession(userSession) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
} }
func (s *LogoutSuite) TearDownTest() { func (s *LogoutSuite) TearDownTest() {

View File

@ -60,7 +60,7 @@ func secondFactorTOTPIdentityFinish(ctx *middlewares.AutheliaCtx, username strin
Base32Secret: key.Secret(), Base32Secret: key.Secret(),
} }
ctx.SetJSONBody(response) ctx.SetJSONBody(response) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
} }
// SecondFactorTOTPIdentityFinish the handler for finishing the identity validation // SecondFactorTOTPIdentityFinish the handler for finishing the identity validation

View File

@ -55,7 +55,7 @@ func secondFactorU2FIdentityFinish(ctx *middlewares.AutheliaCtx, username string
return return
} }
ctx.SetJSONBody(u2f.NewWebRegisterRequest(challenge, []u2f.Registration{})) ctx.SetJSONBody(u2f.NewWebRegisterRequest(challenge, []u2f.Registration{})) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
} }
// SecondFactorU2FIdentityFinish the handler for finishing the identity validation // SecondFactorU2FIdentityFinish the handler for finishing the identity validation

View File

@ -25,7 +25,7 @@ func (s *HandlerRegisterU2FStep1Suite) SetupTest() {
userSession := s.mock.Ctx.GetSession() userSession := s.mock.Ctx.GetSession()
userSession.Username = "john" userSession.Username = "john"
s.mock.Ctx.SaveSession(userSession) s.mock.Ctx.SaveSession(userSession) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
} }
func (s *HandlerRegisterU2FStep1Suite) TearDownTest() { func (s *HandlerRegisterU2FStep1Suite) TearDownTest() {

View File

@ -28,7 +28,7 @@ func SecondFactorU2FRegister(ctx *middlewares.AutheliaCtx) {
// Ensure the challenge is cleared if anything goes wrong. // Ensure the challenge is cleared if anything goes wrong.
defer func() { defer func() {
userSession.U2FChallenge = nil userSession.U2FChallenge = nil
ctx.SaveSession(userSession) ctx.SaveSession(userSession) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
}() }()
registration, err := u2f.Register(responseBody, *userSession.U2FChallenge, u2fConfig) registration, err := u2f.Register(responseBody, *userSession.U2FChallenge, u2fConfig)

View File

@ -46,7 +46,7 @@ func resetPasswordIdentityFinish(ctx *middlewares.AutheliaCtx, username string)
userSession := ctx.GetSession() userSession := ctx.GetSession()
// TODO(c.michaud): use JWT tokens to expire the request in only few seconds for better security. // TODO(c.michaud): use JWT tokens to expire the request in only few seconds for better security.
userSession.PasswordResetUsername = &username userSession.PasswordResetUsername = &username
ctx.SaveSession(userSession) ctx.SaveSession(userSession) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
ctx.ReplyOK() ctx.ReplyOK()
} }

View File

@ -25,7 +25,7 @@ func (s *SecondFactorDuoPostSuite) SetupTest() {
s.mock = mocks.NewMockAutheliaCtx(s.T()) s.mock = mocks.NewMockAutheliaCtx(s.T())
userSession := s.mock.Ctx.GetSession() userSession := s.mock.Ctx.GetSession()
userSession.Username = "john" userSession.Username = "john"
s.mock.Ctx.SaveSession(userSession) s.mock.Ctx.SaveSession(userSession) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
} }
func (s *SecondFactorDuoPostSuite) TearDownTest() { func (s *SecondFactorDuoPostSuite) TearDownTest() {

View File

@ -25,7 +25,7 @@ func (s *HandlerSignTOTPSuite) SetupTest() {
userSession.Username = "john" userSession.Username = "john"
userSession.U2FChallenge = &u2f.Challenge{} userSession.U2FChallenge = &u2f.Challenge{}
userSession.U2FRegistration = &session.U2FRegistration{} userSession.U2FRegistration = &session.U2FRegistration{}
s.mock.Ctx.SaveSession(userSession) s.mock.Ctx.SaveSession(userSession) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
} }
func (s *HandlerSignTOTPSuite) TearDownTest() { func (s *HandlerSignTOTPSuite) TearDownTest() {

View File

@ -25,7 +25,7 @@ func (s *HandlerSignU2FStep2Suite) SetupTest() {
userSession.Username = "john" userSession.Username = "john"
userSession.U2FChallenge = &u2f.Challenge{} userSession.U2FChallenge = &u2f.Challenge{}
userSession.U2FRegistration = &session.U2FRegistration{} userSession.U2FRegistration = &session.U2FRegistration{}
s.mock.Ctx.SaveSession(userSession) s.mock.Ctx.SaveSession(userSession) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
} }
func (s *HandlerSignU2FStep2Suite) TearDownTest() { func (s *HandlerSignU2FStep2Suite) TearDownTest() {

View File

@ -12,5 +12,5 @@ func StateGet(ctx *middlewares.AutheliaCtx) {
AuthenticationLevel: userSession.AuthenticationLevel, AuthenticationLevel: userSession.AuthenticationLevel,
DefaultRedirectionURL: ctx.Configuration.DefaultRedirectionURL, DefaultRedirectionURL: ctx.Configuration.DefaultRedirectionURL,
} }
ctx.SetJSONBody(stateResponse) ctx.SetJSONBody(stateResponse) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
} }

View File

@ -29,7 +29,7 @@ func (s *StateGetSuite) TearDownTest() {
func (s *StateGetSuite) TestShouldReturnUsernameFromSession() { func (s *StateGetSuite) TestShouldReturnUsernameFromSession() {
userSession := s.mock.Ctx.GetSession() userSession := s.mock.Ctx.GetSession()
userSession.Username = "username" userSession.Username = "username"
s.mock.Ctx.SaveSession(userSession) s.mock.Ctx.SaveSession(userSession) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
StateGet(s.mock.Ctx) StateGet(s.mock.Ctx)
@ -48,7 +48,7 @@ func (s *StateGetSuite) TestShouldReturnUsernameFromSession() {
} }
actualBody := Response{} actualBody := Response{}
json.Unmarshal(s.mock.Ctx.Response.Body(), &actualBody) json.Unmarshal(s.mock.Ctx.Response.Body(), &actualBody) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
assert.Equal(s.T(), 200, s.mock.Ctx.Response.StatusCode()) assert.Equal(s.T(), 200, s.mock.Ctx.Response.StatusCode())
assert.Equal(s.T(), []byte("application/json"), s.mock.Ctx.Response.Header.ContentType()) assert.Equal(s.T(), []byte("application/json"), s.mock.Ctx.Response.Header.ContentType())
assert.Equal(s.T(), expectedBody, actualBody) assert.Equal(s.T(), expectedBody, actualBody)
@ -57,7 +57,7 @@ func (s *StateGetSuite) TestShouldReturnUsernameFromSession() {
func (s *StateGetSuite) TestShouldReturnAuthenticationLevelFromSession() { func (s *StateGetSuite) TestShouldReturnAuthenticationLevelFromSession() {
userSession := s.mock.Ctx.GetSession() userSession := s.mock.Ctx.GetSession()
userSession.AuthenticationLevel = authentication.OneFactor userSession.AuthenticationLevel = authentication.OneFactor
s.mock.Ctx.SaveSession(userSession) s.mock.Ctx.SaveSession(userSession) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
StateGet(s.mock.Ctx) StateGet(s.mock.Ctx)
@ -76,7 +76,7 @@ func (s *StateGetSuite) TestShouldReturnAuthenticationLevelFromSession() {
} }
actualBody := Response{} actualBody := Response{}
json.Unmarshal(s.mock.Ctx.Response.Body(), &actualBody) json.Unmarshal(s.mock.Ctx.Response.Body(), &actualBody) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
assert.Equal(s.T(), 200, s.mock.Ctx.Response.StatusCode()) assert.Equal(s.T(), 200, s.mock.Ctx.Response.StatusCode())
assert.Equal(s.T(), []byte("application/json"), s.mock.Ctx.Response.Header.ContentType()) assert.Equal(s.T(), []byte("application/json"), s.mock.Ctx.Response.Header.ContentType())
assert.Equal(s.T(), expectedBody, actualBody) assert.Equal(s.T(), expectedBody, actualBody)

View File

@ -76,7 +76,7 @@ func UserInfoGet(ctx *middlewares.AutheliaCtx) {
ctx.Error(fmt.Errorf("Unable to load user information"), operationFailedMessage) ctx.Error(fmt.Errorf("Unable to load user information"), operationFailedMessage)
return return
} }
ctx.SetJSONBody(preferences) ctx.SetJSONBody(preferences) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
} }
// MethodBody the selected 2FA method. // MethodBody the selected 2FA method.

View File

@ -24,7 +24,7 @@ func (s *FetchSuite) SetupTest() {
userSession := s.mock.Ctx.GetSession() userSession := s.mock.Ctx.GetSession()
userSession.Username = "john" userSession.Username = "john"
userSession.AuthenticationLevel = 1 userSession.AuthenticationLevel = 1
s.mock.Ctx.SaveSession(userSession) s.mock.Ctx.SaveSession(userSession) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
} }
func (s *FetchSuite) TearDownTest() { func (s *FetchSuite) TearDownTest() {
@ -92,7 +92,7 @@ func TestMethodSetToU2F(t *testing.T) {
userSession := mock.Ctx.GetSession() userSession := mock.Ctx.GetSession()
userSession.Username = "john" userSession.Username = "john"
userSession.AuthenticationLevel = 1 userSession.AuthenticationLevel = 1
mock.Ctx.SaveSession(userSession) mock.Ctx.SaveSession(userSession) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
setPreferencesExpectations(expectedPreferences, mock.StorageProviderMock) setPreferencesExpectations(expectedPreferences, mock.StorageProviderMock)
UserInfoGet(mock.Ctx) UserInfoGet(mock.Ctx)
@ -170,7 +170,7 @@ func (s *SaveSuite) SetupTest() {
userSession := s.mock.Ctx.GetSession() userSession := s.mock.Ctx.GetSession()
userSession.Username = "john" userSession.Username = "john"
userSession.AuthenticationLevel = 1 userSession.AuthenticationLevel = 1
s.mock.Ctx.SaveSession(userSession) s.mock.Ctx.SaveSession(userSession) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
} }
func (s *SaveSuite) TearDownTest() { func (s *SaveSuite) TearDownTest() {

View File

@ -447,7 +447,7 @@ func TestShouldVerifyAuthorizationsUsingSessionCookie(t *testing.T) {
userSession := mock.Ctx.GetSession() userSession := mock.Ctx.GetSession()
userSession.Username = testCase.Username userSession.Username = testCase.Username
userSession.AuthenticationLevel = testCase.AuthenticationLevel userSession.AuthenticationLevel = testCase.AuthenticationLevel
mock.Ctx.SaveSession(userSession) mock.Ctx.SaveSession(userSession) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
mock.Ctx.Request.Header.Set("X-Original-URL", testCase.URL) mock.Ctx.Request.Header.Set("X-Original-URL", testCase.URL)
@ -481,7 +481,7 @@ func TestShouldDestroySessionWhenInactiveForTooLong(t *testing.T) {
userSession.Username = "john" userSession.Username = "john"
userSession.AuthenticationLevel = authentication.TwoFactor userSession.AuthenticationLevel = authentication.TwoFactor
userSession.LastActivity = clock.Now().Add(-1 * time.Hour).Unix() userSession.LastActivity = clock.Now().Add(-1 * time.Hour).Unix()
mock.Ctx.SaveSession(userSession) mock.Ctx.SaveSession(userSession) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
mock.Ctx.Request.Header.Set("X-Original-URL", "https://two-factor.example.com") mock.Ctx.Request.Header.Set("X-Original-URL", "https://two-factor.example.com")
@ -509,7 +509,7 @@ func TestShouldDestroySessionWhenInactiveForTooLongUsingDurationNotation(t *test
userSession.Username = "john" userSession.Username = "john"
userSession.AuthenticationLevel = authentication.TwoFactor userSession.AuthenticationLevel = authentication.TwoFactor
userSession.LastActivity = clock.Now().Add(-1 * time.Hour).Unix() userSession.LastActivity = clock.Now().Add(-1 * time.Hour).Unix()
mock.Ctx.SaveSession(userSession) mock.Ctx.SaveSession(userSession) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
mock.Ctx.Request.Header.Set("X-Original-URL", "https://two-factor.example.com") mock.Ctx.Request.Header.Set("X-Original-URL", "https://two-factor.example.com")
@ -535,7 +535,7 @@ func TestShouldKeepSessionWhenUserCheckedRememberMeAndIsInactiveForTooLong(t *te
userSession.AuthenticationLevel = authentication.TwoFactor userSession.AuthenticationLevel = authentication.TwoFactor
userSession.LastActivity = clock.Now().Add(-1 * time.Hour).Unix() userSession.LastActivity = clock.Now().Add(-1 * time.Hour).Unix()
userSession.KeepMeLoggedIn = true userSession.KeepMeLoggedIn = true
mock.Ctx.SaveSession(userSession) mock.Ctx.SaveSession(userSession) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
mock.Ctx.Request.Header.Set("X-Original-URL", "https://two-factor.example.com") mock.Ctx.Request.Header.Set("X-Original-URL", "https://two-factor.example.com")
@ -560,7 +560,7 @@ func TestShouldKeepSessionWhenInactivityTimeoutHasNotBeenExceeded(t *testing.T)
userSession.Username = "john" userSession.Username = "john"
userSession.AuthenticationLevel = authentication.TwoFactor userSession.AuthenticationLevel = authentication.TwoFactor
userSession.LastActivity = clock.Now().Add(-1 * time.Second).Unix() userSession.LastActivity = clock.Now().Add(-1 * time.Second).Unix()
mock.Ctx.SaveSession(userSession) mock.Ctx.SaveSession(userSession) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
mock.Ctx.Request.Header.Set("X-Original-URL", "https://two-factor.example.com") mock.Ctx.Request.Header.Set("X-Original-URL", "https://two-factor.example.com")
@ -579,7 +579,7 @@ func TestShouldURLEncodeRedirectionURLParameter(t *testing.T) {
userSession := mock.Ctx.GetSession() userSession := mock.Ctx.GetSession()
userSession.Username = "john" userSession.Username = "john"
userSession.AuthenticationLevel = authentication.NotAuthenticated userSession.AuthenticationLevel = authentication.NotAuthenticated
mock.Ctx.SaveSession(userSession) mock.Ctx.SaveSession(userSession) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
mock.Ctx.Request.Header.Set("X-Original-URL", "https://two-factor.example.com") mock.Ctx.Request.Header.Set("X-Original-URL", "https://two-factor.example.com")
mock.Ctx.Request.SetHost("mydomain.com") mock.Ctx.Request.SetHost("mydomain.com")

View File

@ -13,7 +13,7 @@ import (
func Handle1FAResponse(ctx *middlewares.AutheliaCtx, targetURI string, username string, groups []string) { func Handle1FAResponse(ctx *middlewares.AutheliaCtx, targetURI string, username string, groups []string) {
if targetURI == "" { if targetURI == "" {
if !ctx.Providers.Authorizer.IsSecondFactorEnabled() && ctx.Configuration.DefaultRedirectionURL != "" { if !ctx.Providers.Authorizer.IsSecondFactorEnabled() && ctx.Configuration.DefaultRedirectionURL != "" {
ctx.SetJSONBody(redirectResponse{Redirect: ctx.Configuration.DefaultRedirectionURL}) ctx.SetJSONBody(redirectResponse{Redirect: ctx.Configuration.DefaultRedirectionURL}) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
} else { } else {
ctx.ReplyOK() ctx.ReplyOK()
} }
@ -44,7 +44,7 @@ func Handle1FAResponse(ctx *middlewares.AutheliaCtx, targetURI string, username
if !safeRedirection { if !safeRedirection {
if !ctx.Providers.Authorizer.IsSecondFactorEnabled() && ctx.Configuration.DefaultRedirectionURL != "" { if !ctx.Providers.Authorizer.IsSecondFactorEnabled() && ctx.Configuration.DefaultRedirectionURL != "" {
ctx.SetJSONBody(redirectResponse{Redirect: ctx.Configuration.DefaultRedirectionURL}) ctx.SetJSONBody(redirectResponse{Redirect: ctx.Configuration.DefaultRedirectionURL}) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
} else { } else {
ctx.ReplyOK() ctx.ReplyOK()
} }
@ -53,14 +53,14 @@ func Handle1FAResponse(ctx *middlewares.AutheliaCtx, targetURI string, username
ctx.Logger.Debugf("Redirection URL %s is safe", targetURI) ctx.Logger.Debugf("Redirection URL %s is safe", targetURI)
response := redirectResponse{Redirect: targetURI} response := redirectResponse{Redirect: targetURI}
ctx.SetJSONBody(response) ctx.SetJSONBody(response) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
} }
// Handle2FAResponse handle the redirection upon 2FA authentication // Handle2FAResponse handle the redirection upon 2FA authentication
func Handle2FAResponse(ctx *middlewares.AutheliaCtx, targetURI string) { func Handle2FAResponse(ctx *middlewares.AutheliaCtx, targetURI string) {
if targetURI == "" { if targetURI == "" {
if ctx.Configuration.DefaultRedirectionURL != "" { if ctx.Configuration.DefaultRedirectionURL != "" {
ctx.SetJSONBody(redirectResponse{Redirect: ctx.Configuration.DefaultRedirectionURL}) ctx.SetJSONBody(redirectResponse{Redirect: ctx.Configuration.DefaultRedirectionURL}) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
} else { } else {
ctx.ReplyOK() ctx.ReplyOK()
} }
@ -75,7 +75,7 @@ func Handle2FAResponse(ctx *middlewares.AutheliaCtx, targetURI string) {
} }
if targetURL != nil && utils.IsRedirectionSafe(*targetURL, ctx.Configuration.Session.Domain) { if targetURL != nil && utils.IsRedirectionSafe(*targetURL, ctx.Configuration.Session.Domain) {
ctx.SetJSONBody(redirectResponse{Redirect: targetURI}) ctx.SetJSONBody(redirectResponse{Redirect: targetURI}) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
} else { } else {
ctx.ReplyOK() ctx.ReplyOK()
} }

View File

@ -43,4 +43,4 @@ func ServeIndex(publicDir string) fasthttp.RequestHandler {
return return
} }
} }
} }

View File

@ -7,7 +7,7 @@ import (
) )
func (wds *WebDriverSession) doChangeMethod(ctx context.Context, t *testing.T, method string) { func (wds *WebDriverSession) doChangeMethod(ctx context.Context, t *testing.T, method string) {
wds.WaitElementLocatedByID(ctx, t, "methods-button").Click() wds.WaitElementLocatedByID(ctx, t, "methods-button").Click() //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
wds.WaitElementLocatedByID(ctx, t, "methods-dialog") wds.WaitElementLocatedByID(ctx, t, "methods-dialog")
wds.WaitElementLocatedByID(ctx, t, fmt.Sprintf("%s-option", method)).Click() wds.WaitElementLocatedByID(ctx, t, fmt.Sprintf("%s-option", method)).Click() //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
} }

View File

@ -6,20 +6,20 @@ import (
) )
func (wds *WebDriverSession) doInitiatePasswordReset(ctx context.Context, t *testing.T, username string) { func (wds *WebDriverSession) doInitiatePasswordReset(ctx context.Context, t *testing.T, username string) {
wds.WaitElementLocatedByID(ctx, t, "reset-password-button").Click() wds.WaitElementLocatedByID(ctx, t, "reset-password-button").Click() //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
// Fill in username // Fill in username
wds.WaitElementLocatedByID(ctx, t, "username-textfield").SendKeys(username) wds.WaitElementLocatedByID(ctx, t, "username-textfield").SendKeys(username) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
// And click on the reset button // And click on the reset button
wds.WaitElementLocatedByID(ctx, t, "reset-button").Click() wds.WaitElementLocatedByID(ctx, t, "reset-button").Click() //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
} }
func (wds *WebDriverSession) doCompletePasswordReset(ctx context.Context, t *testing.T, newPassword1, newPassword2 string) { func (wds *WebDriverSession) doCompletePasswordReset(ctx context.Context, t *testing.T, newPassword1, newPassword2 string) {
link := doGetLinkFromLastMail(t) link := doGetLinkFromLastMail(t)
wds.doVisit(t, link) wds.doVisit(t, link)
wds.WaitElementLocatedByID(ctx, t, "password1-textfield").SendKeys(newPassword1) wds.WaitElementLocatedByID(ctx, t, "password1-textfield").SendKeys(newPassword1) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
wds.WaitElementLocatedByID(ctx, t, "password2-textfield").SendKeys(newPassword2) wds.WaitElementLocatedByID(ctx, t, "password2-textfield").SendKeys(newPassword2) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
wds.WaitElementLocatedByID(ctx, t, "reset-button").Click() wds.WaitElementLocatedByID(ctx, t, "reset-button").Click() //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
} }
func (wds *WebDriverSession) doSuccessfullyCompletePasswordReset(ctx context.Context, t *testing.T, newPassword1, newPassword2 string) { func (wds *WebDriverSession) doSuccessfullyCompletePasswordReset(ctx context.Context, t *testing.T, newPassword1, newPassword2 string) {

View File

@ -10,7 +10,7 @@ import (
) )
func (wds *WebDriverSession) doRegisterTOTP(ctx context.Context, t *testing.T) string { func (wds *WebDriverSession) doRegisterTOTP(ctx context.Context, t *testing.T) string {
wds.WaitElementLocatedByID(ctx, t, "register-link").Click() wds.WaitElementLocatedByID(ctx, t, "register-link").Click() //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
wds.verifyMailNotificationDisplayed(ctx, t) wds.verifyMailNotificationDisplayed(ctx, t)
link := doGetLinkFromLastMail(t) link := doGetLinkFromLastMail(t)
wds.doVisit(t, link) wds.doVisit(t, link)
@ -25,7 +25,7 @@ func (wds *WebDriverSession) doEnterOTP(ctx context.Context, t *testing.T, code
inputs := wds.WaitElementsLocatedByCSSSelector(ctx, t, "#otp-input input") inputs := wds.WaitElementsLocatedByCSSSelector(ctx, t, "#otp-input input")
for i := 0; i < 6; i++ { for i := 0; i < 6; i++ {
inputs[i].SendKeys(string(code[i])) inputs[i].SendKeys(string(code[i])) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
} }
} }

View File

@ -55,14 +55,14 @@ func (s *RegulationScenario) TestShouldBanUserAfterTooManyAttempt() {
s.verifyNotificationDisplayed(ctx, s.T(), "Incorrect username or password.") s.verifyNotificationDisplayed(ctx, s.T(), "Incorrect username or password.")
for i := 0; i < 3; i++ { for i := 0; i < 3; i++ {
s.WaitElementLocatedByID(ctx, s.T(), "password-textfield").SendKeys("bad-password") s.WaitElementLocatedByID(ctx, s.T(), "password-textfield").SendKeys("bad-password") //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
s.WaitElementLocatedByID(ctx, s.T(), "sign-in-button").Click() s.WaitElementLocatedByID(ctx, s.T(), "sign-in-button").Click() //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
time.Sleep(1 * time.Second) time.Sleep(1 * time.Second)
} }
// Enter the correct password and test the regulation lock out // Enter the correct password and test the regulation lock out
s.WaitElementLocatedByID(ctx, s.T(), "password-textfield").SendKeys("password") s.WaitElementLocatedByID(ctx, s.T(), "password-textfield").SendKeys("password") //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
s.WaitElementLocatedByID(ctx, s.T(), "sign-in-button").Click() s.WaitElementLocatedByID(ctx, s.T(), "sign-in-button").Click() //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
s.verifyNotificationDisplayed(ctx, s.T(), "Incorrect username or password.") s.verifyNotificationDisplayed(ctx, s.T(), "Incorrect username or password.")
time.Sleep(1 * time.Second) time.Sleep(1 * time.Second)
@ -70,8 +70,8 @@ func (s *RegulationScenario) TestShouldBanUserAfterTooManyAttempt() {
time.Sleep(9 * time.Second) time.Sleep(9 * time.Second)
// Enter the correct password and test a successful login // Enter the correct password and test a successful login
s.WaitElementLocatedByID(ctx, s.T(), "password-textfield").SendKeys("password") s.WaitElementLocatedByID(ctx, s.T(), "password-textfield").SendKeys("password") //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
s.WaitElementLocatedByID(ctx, s.T(), "sign-in-button").Click() s.WaitElementLocatedByID(ctx, s.T(), "sign-in-button").Click() //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
s.verifyIsSecondFactorPage(ctx, s.T()) s.verifyIsSecondFactorPage(ctx, s.T())
} }

View File

@ -88,8 +88,8 @@ func init() {
} }
teardown := func(suitePath string) error { teardown := func(suitePath string) error {
kubectl.StopDashboard() kubectl.StopDashboard() //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
kubectl.StopProxy() kubectl.StopProxy() //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
return kind.DeleteCluster() return kind.DeleteCluster()
} }

View File

@ -23,7 +23,7 @@ func (s *NetworkACLSuite) TestShouldAccessSecretUpon2FA() {
wds, err := StartWebDriver() wds, err := StartWebDriver()
s.Require().NoError(err) s.Require().NoError(err)
defer wds.Stop() defer wds.Stop() //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
targetURL := fmt.Sprintf("%s/secret.html", SecureBaseURL) targetURL := fmt.Sprintf("%s/secret.html", SecureBaseURL)
wds.doVisit(s.T(), targetURL) wds.doVisit(s.T(), targetURL)
@ -40,7 +40,7 @@ func (s *NetworkACLSuite) TestShouldAccessSecretUpon1FA() {
wds, err := StartWebDriverWithProxy("http://proxy-client1.example.com:3128", 4444) wds, err := StartWebDriverWithProxy("http://proxy-client1.example.com:3128", 4444)
s.Require().NoError(err) s.Require().NoError(err)
defer wds.Stop() defer wds.Stop() //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
targetURL := fmt.Sprintf("%s/secret.html", SecureBaseURL) targetURL := fmt.Sprintf("%s/secret.html", SecureBaseURL)
wds.doVisit(s.T(), targetURL) wds.doVisit(s.T(), targetURL)
@ -58,7 +58,7 @@ func (s *NetworkACLSuite) TestShouldAccessSecretUpon0FA() {
wds, err := StartWebDriverWithProxy("http://proxy-client2.example.com:3128", 4444) wds, err := StartWebDriverWithProxy("http://proxy-client2.example.com:3128", 4444)
s.Require().NoError(err) s.Require().NoError(err)
defer wds.Stop() defer wds.Stop() //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
wds.doVisit(s.T(), fmt.Sprintf("%s/secret.html", SecureBaseURL)) wds.doVisit(s.T(), fmt.Sprintf("%s/secret.html", SecureBaseURL))
wds.verifySecretAuthorized(ctx, s.T()) wds.verifySecretAuthorized(ctx, s.T())

View File

@ -52,7 +52,7 @@ func StartWebDriverWithProxy(proxy string, port int) (*WebDriverSession, error)
wd, err := selenium.NewRemote(caps, fmt.Sprintf("http://localhost:%d/wd/hub", port)) wd, err := selenium.NewRemote(caps, fmt.Sprintf("http://localhost:%d/wd/hub", port))
if err != nil { if err != nil {
service.Stop() service.Stop() //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
panic(err) panic(err)
} }
@ -86,7 +86,7 @@ func WithWebdriver(fn func(webdriver selenium.WebDriver) error) error {
return err return err
} }
defer wds.Stop() defer wds.Stop() //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
return fn(wds.WebDriver) return fn(wds.WebDriver)
} }