[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-edpull/894/head^2
parent
fca190dedc
commit
54694c4fca
|
@ -172,9 +172,9 @@ func setupSuite(suiteName string) error {
|
|||
|
||||
if errSetup := runSuiteSetupTeardown("setup", suiteName); errSetup != nil || interrupted {
|
||||
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
|
||||
}
|
||||
|
||||
|
|
|
@ -149,7 +149,7 @@ func TestShouldEscapeUserInput(t *testing.T) {
|
|||
Search(NewSearchRequestMatcher("(|(uid=john\\=abc)(mail=john\\=abc))")).
|
||||
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) {
|
||||
|
@ -174,7 +174,7 @@ func TestShouldCombineUsernameFilterAndUsersFilter(t *testing.T) {
|
|||
Search(NewSearchRequestMatcher("(&(uid=john)(&(objectCategory=person)(objectClass=user)))")).
|
||||
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 {
|
||||
|
|
|
@ -26,10 +26,10 @@ var MigrateLocalCmd = &cobra.Command{
|
|||
|
||||
func init() {
|
||||
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.MarkPersistentFlagRequired("config")
|
||||
MigrateLocalCmd.MarkPersistentFlagRequired("config") //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
|
||||
}
|
||||
|
||||
// migrateLocal data from v3 to v4.
|
||||
|
@ -58,7 +58,7 @@ func migrateLocalTOTPSecret(dbProvider storage.Provider) {
|
|||
data := scanner.Text()
|
||||
|
||||
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)
|
||||
|
||||
if err != nil {
|
||||
|
@ -80,7 +80,7 @@ func migrateLocalU2FSecret(dbProvider storage.Provider) {
|
|||
data := scanner.Text()
|
||||
|
||||
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)
|
||||
|
||||
|
@ -115,7 +115,7 @@ func migrateLocalPreferences(dbProvider storage.Provider) {
|
|||
data := scanner.Text()
|
||||
|
||||
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)
|
||||
|
||||
if err != nil {
|
||||
|
@ -137,7 +137,7 @@ func migrateLocalAuthenticationTraces(dbProvider storage.Provider) {
|
|||
data := scanner.Text()
|
||||
|
||||
entry := AuthenticationTraceV3{}
|
||||
json.Unmarshal([]byte(data), &entry)
|
||||
json.Unmarshal([]byte(data), &entry) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
|
||||
|
||||
attempt := models.AuthenticationAttempt{
|
||||
Username: entry.UserID,
|
||||
|
|
|
@ -26,13 +26,13 @@ var MigrateMongoCmd = &cobra.Command{
|
|||
|
||||
func init() {
|
||||
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.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.MarkPersistentFlagRequired("config")
|
||||
MigrateMongoCmd.MarkPersistentFlagRequired("config") //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
|
||||
}
|
||||
|
||||
func migrateMongo(cmd *cobra.Command, args []string) {
|
||||
|
|
|
@ -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
|
||||
// is not resolved.
|
||||
viper.BindEnv("jwt_secret")
|
||||
viper.BindEnv("duo_api.secret_key")
|
||||
viper.BindEnv("session.secret")
|
||||
viper.BindEnv("authentication_backend.ldap.password")
|
||||
viper.BindEnv("notifier.smtp.password")
|
||||
viper.BindEnv("session.redis.password")
|
||||
viper.BindEnv("storage.mysql.password")
|
||||
viper.BindEnv("storage.postgres.password")
|
||||
viper.BindEnv("jwt_secret") //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
|
||||
viper.BindEnv("duo_api.secret_key") //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
|
||||
viper.BindEnv("session.secret") //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
|
||||
viper.BindEnv("authentication_backend.ldap.password") //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
|
||||
viper.BindEnv("notifier.smtp.password") //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
|
||||
viper.BindEnv("session.redis.password") //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
|
||||
viper.BindEnv("storage.mysql.password") //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
|
||||
viper.BindEnv("storage.postgres.password") //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
|
||||
|
||||
viper.SetConfigFile(configPath)
|
||||
|
||||
|
@ -35,7 +35,7 @@ func Read(configPath string) (*schema.Configuration, []error) {
|
|||
}
|
||||
|
||||
var configuration schema.Configuration
|
||||
viper.Unmarshal(&configuration)
|
||||
viper.Unmarshal(&configuration) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
|
||||
|
||||
val := schema.NewStructValidator()
|
||||
validator.Validate(&configuration, val)
|
||||
|
|
|
@ -39,7 +39,7 @@ func (v *Validator) validateOne(item QueueItem, q *queue.Queue) error { //nolint
|
|||
}
|
||||
|
||||
elem := item.value.Elem()
|
||||
q.Put(QueueItem{
|
||||
q.Put(QueueItem{ //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
|
||||
value: elem,
|
||||
path: item.path,
|
||||
})
|
||||
|
@ -58,7 +58,7 @@ func (v *Validator) validateOne(item QueueItem, q *queue.Queue) error { //nolint
|
|||
field := item.value.Type().Field(i)
|
||||
value := item.value.Field(i)
|
||||
|
||||
q.Put(QueueItem{
|
||||
q.Put(QueueItem{ //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
|
||||
value: value,
|
||||
path: item.path + "." + field.Name,
|
||||
})
|
||||
|
@ -70,7 +70,7 @@ func (v *Validator) validateOne(item QueueItem, q *queue.Queue) error { //nolint
|
|||
// Validate validate a struct
|
||||
func (v *Validator) Validate(s interface{}) error {
|
||||
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() {
|
||||
val, err := q.Get(1)
|
||||
|
@ -81,7 +81,7 @@ func (v *Validator) Validate(s interface{}) error {
|
|||
if !ok {
|
||||
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
|
||||
}
|
||||
|
|
|
@ -16,5 +16,5 @@ func ConfigurationGet(ctx *middlewares.AutheliaCtx) {
|
|||
RememberMe: ctx.Providers.SessionProvider.RememberMe != 0,
|
||||
ResetPassword: !ctx.Configuration.AuthenticationBackend.DisableResetPassword,
|
||||
}
|
||||
ctx.SetJSONBody(body)
|
||||
ctx.SetJSONBody(body) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
|
||||
}
|
||||
|
|
|
@ -26,5 +26,5 @@ func ExtendedConfigurationGet(ctx *middlewares.AutheliaCtx) {
|
|||
ctx.Logger.Tracef("Second factor enabled: %v", body.SecondFactorEnabled)
|
||||
|
||||
ctx.Logger.Tracef("Available methods are %s", body.AvailableMethods)
|
||||
ctx.SetJSONBody(body)
|
||||
ctx.SetJSONBody(body) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ func FirstFactorPost(ctx *middlewares.AutheliaCtx) {
|
|||
|
||||
if err != nil {
|
||||
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)
|
||||
return
|
||||
|
@ -43,7 +43,7 @@ func FirstFactorPost(ctx *middlewares.AutheliaCtx) {
|
|||
|
||||
if !userPasswordOk {
|
||||
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)
|
||||
return
|
||||
|
|
|
@ -21,7 +21,7 @@ func (s *LogoutSuite) SetupTest() {
|
|||
s.mock = mocks.NewMockAutheliaCtx(s.T())
|
||||
userSession := s.mock.Ctx.GetSession()
|
||||
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() {
|
||||
|
|
|
@ -60,7 +60,7 @@ func secondFactorTOTPIdentityFinish(ctx *middlewares.AutheliaCtx, username strin
|
|||
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
|
||||
|
|
|
@ -55,7 +55,7 @@ func secondFactorU2FIdentityFinish(ctx *middlewares.AutheliaCtx, username string
|
|||
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
|
||||
|
|
|
@ -25,7 +25,7 @@ func (s *HandlerRegisterU2FStep1Suite) SetupTest() {
|
|||
|
||||
userSession := s.mock.Ctx.GetSession()
|
||||
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() {
|
||||
|
|
|
@ -28,7 +28,7 @@ func SecondFactorU2FRegister(ctx *middlewares.AutheliaCtx) {
|
|||
// Ensure the challenge is cleared if anything goes wrong.
|
||||
defer func() {
|
||||
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)
|
||||
|
|
|
@ -46,7 +46,7 @@ func resetPasswordIdentityFinish(ctx *middlewares.AutheliaCtx, username string)
|
|||
userSession := ctx.GetSession()
|
||||
// TODO(c.michaud): use JWT tokens to expire the request in only few seconds for better security.
|
||||
userSession.PasswordResetUsername = &username
|
||||
ctx.SaveSession(userSession)
|
||||
ctx.SaveSession(userSession) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
|
||||
|
||||
ctx.ReplyOK()
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ func (s *SecondFactorDuoPostSuite) SetupTest() {
|
|||
s.mock = mocks.NewMockAutheliaCtx(s.T())
|
||||
userSession := s.mock.Ctx.GetSession()
|
||||
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() {
|
||||
|
|
|
@ -25,7 +25,7 @@ func (s *HandlerSignTOTPSuite) SetupTest() {
|
|||
userSession.Username = "john"
|
||||
userSession.U2FChallenge = &u2f.Challenge{}
|
||||
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() {
|
||||
|
|
|
@ -25,7 +25,7 @@ func (s *HandlerSignU2FStep2Suite) SetupTest() {
|
|||
userSession.Username = "john"
|
||||
userSession.U2FChallenge = &u2f.Challenge{}
|
||||
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() {
|
||||
|
|
|
@ -12,5 +12,5 @@ func StateGet(ctx *middlewares.AutheliaCtx) {
|
|||
AuthenticationLevel: userSession.AuthenticationLevel,
|
||||
DefaultRedirectionURL: ctx.Configuration.DefaultRedirectionURL,
|
||||
}
|
||||
ctx.SetJSONBody(stateResponse)
|
||||
ctx.SetJSONBody(stateResponse) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ func (s *StateGetSuite) TearDownTest() {
|
|||
func (s *StateGetSuite) TestShouldReturnUsernameFromSession() {
|
||||
userSession := s.mock.Ctx.GetSession()
|
||||
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)
|
||||
|
||||
|
@ -48,7 +48,7 @@ func (s *StateGetSuite) TestShouldReturnUsernameFromSession() {
|
|||
}
|
||||
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(), []byte("application/json"), s.mock.Ctx.Response.Header.ContentType())
|
||||
assert.Equal(s.T(), expectedBody, actualBody)
|
||||
|
@ -57,7 +57,7 @@ func (s *StateGetSuite) TestShouldReturnUsernameFromSession() {
|
|||
func (s *StateGetSuite) TestShouldReturnAuthenticationLevelFromSession() {
|
||||
userSession := s.mock.Ctx.GetSession()
|
||||
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)
|
||||
|
||||
|
@ -76,7 +76,7 @@ func (s *StateGetSuite) TestShouldReturnAuthenticationLevelFromSession() {
|
|||
}
|
||||
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(), []byte("application/json"), s.mock.Ctx.Response.Header.ContentType())
|
||||
assert.Equal(s.T(), expectedBody, actualBody)
|
||||
|
|
|
@ -76,7 +76,7 @@ func UserInfoGet(ctx *middlewares.AutheliaCtx) {
|
|||
ctx.Error(fmt.Errorf("Unable to load user information"), operationFailedMessage)
|
||||
return
|
||||
}
|
||||
ctx.SetJSONBody(preferences)
|
||||
ctx.SetJSONBody(preferences) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
|
||||
}
|
||||
|
||||
// MethodBody the selected 2FA method.
|
||||
|
|
|
@ -24,7 +24,7 @@ func (s *FetchSuite) SetupTest() {
|
|||
userSession := s.mock.Ctx.GetSession()
|
||||
userSession.Username = "john"
|
||||
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() {
|
||||
|
@ -92,7 +92,7 @@ func TestMethodSetToU2F(t *testing.T) {
|
|||
userSession := mock.Ctx.GetSession()
|
||||
userSession.Username = "john"
|
||||
userSession.AuthenticationLevel = 1
|
||||
mock.Ctx.SaveSession(userSession)
|
||||
mock.Ctx.SaveSession(userSession) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
|
||||
|
||||
setPreferencesExpectations(expectedPreferences, mock.StorageProviderMock)
|
||||
UserInfoGet(mock.Ctx)
|
||||
|
@ -170,7 +170,7 @@ func (s *SaveSuite) SetupTest() {
|
|||
userSession := s.mock.Ctx.GetSession()
|
||||
userSession.Username = "john"
|
||||
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() {
|
||||
|
|
|
@ -447,7 +447,7 @@ func TestShouldVerifyAuthorizationsUsingSessionCookie(t *testing.T) {
|
|||
userSession := mock.Ctx.GetSession()
|
||||
userSession.Username = testCase.Username
|
||||
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)
|
||||
|
||||
|
@ -481,7 +481,7 @@ func TestShouldDestroySessionWhenInactiveForTooLong(t *testing.T) {
|
|||
userSession.Username = "john"
|
||||
userSession.AuthenticationLevel = authentication.TwoFactor
|
||||
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")
|
||||
|
||||
|
@ -509,7 +509,7 @@ func TestShouldDestroySessionWhenInactiveForTooLongUsingDurationNotation(t *test
|
|||
userSession.Username = "john"
|
||||
userSession.AuthenticationLevel = authentication.TwoFactor
|
||||
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")
|
||||
|
||||
|
@ -535,7 +535,7 @@ func TestShouldKeepSessionWhenUserCheckedRememberMeAndIsInactiveForTooLong(t *te
|
|||
userSession.AuthenticationLevel = authentication.TwoFactor
|
||||
userSession.LastActivity = clock.Now().Add(-1 * time.Hour).Unix()
|
||||
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")
|
||||
|
||||
|
@ -560,7 +560,7 @@ func TestShouldKeepSessionWhenInactivityTimeoutHasNotBeenExceeded(t *testing.T)
|
|||
userSession.Username = "john"
|
||||
userSession.AuthenticationLevel = authentication.TwoFactor
|
||||
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")
|
||||
|
||||
|
@ -579,7 +579,7 @@ func TestShouldURLEncodeRedirectionURLParameter(t *testing.T) {
|
|||
userSession := mock.Ctx.GetSession()
|
||||
userSession.Username = "john"
|
||||
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.SetHost("mydomain.com")
|
||||
|
|
|
@ -13,7 +13,7 @@ import (
|
|||
func Handle1FAResponse(ctx *middlewares.AutheliaCtx, targetURI string, username string, groups []string) {
|
||||
if targetURI == "" {
|
||||
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 {
|
||||
ctx.ReplyOK()
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ func Handle1FAResponse(ctx *middlewares.AutheliaCtx, targetURI string, username
|
|||
|
||||
if !safeRedirection {
|
||||
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 {
|
||||
ctx.ReplyOK()
|
||||
}
|
||||
|
@ -53,14 +53,14 @@ func Handle1FAResponse(ctx *middlewares.AutheliaCtx, targetURI string, username
|
|||
|
||||
ctx.Logger.Debugf("Redirection URL %s is safe", 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
|
||||
func Handle2FAResponse(ctx *middlewares.AutheliaCtx, targetURI string) {
|
||||
if targetURI == "" {
|
||||
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 {
|
||||
ctx.ReplyOK()
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ func Handle2FAResponse(ctx *middlewares.AutheliaCtx, targetURI string) {
|
|||
}
|
||||
|
||||
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 {
|
||||
ctx.ReplyOK()
|
||||
}
|
||||
|
|
|
@ -43,4 +43,4 @@ func ServeIndex(publicDir string) fasthttp.RequestHandler {
|
|||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
)
|
||||
|
||||
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, 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.
|
||||
}
|
||||
|
|
|
@ -6,20 +6,20 @@ import (
|
|||
)
|
||||
|
||||
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
|
||||
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
|
||||
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) {
|
||||
link := doGetLinkFromLastMail(t)
|
||||
wds.doVisit(t, link)
|
||||
|
||||
wds.WaitElementLocatedByID(ctx, t, "password1-textfield").SendKeys(newPassword1)
|
||||
wds.WaitElementLocatedByID(ctx, t, "password2-textfield").SendKeys(newPassword2)
|
||||
wds.WaitElementLocatedByID(ctx, t, "reset-button").Click()
|
||||
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) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
|
||||
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) {
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
)
|
||||
|
||||
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)
|
||||
link := doGetLinkFromLastMail(t)
|
||||
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")
|
||||
|
||||
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.
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -55,14 +55,14 @@ func (s *RegulationScenario) TestShouldBanUserAfterTooManyAttempt() {
|
|||
s.verifyNotificationDisplayed(ctx, s.T(), "Incorrect username or password.")
|
||||
|
||||
for i := 0; i < 3; i++ {
|
||||
s.WaitElementLocatedByID(ctx, s.T(), "password-textfield").SendKeys("bad-password")
|
||||
s.WaitElementLocatedByID(ctx, s.T(), "sign-in-button").Click()
|
||||
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() //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
|
||||
time.Sleep(1 * time.Second)
|
||||
}
|
||||
|
||||
// Enter the correct password and test the regulation lock out
|
||||
s.WaitElementLocatedByID(ctx, s.T(), "password-textfield").SendKeys("password")
|
||||
s.WaitElementLocatedByID(ctx, s.T(), "sign-in-button").Click()
|
||||
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() //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
|
||||
s.verifyNotificationDisplayed(ctx, s.T(), "Incorrect username or password.")
|
||||
|
||||
time.Sleep(1 * time.Second)
|
||||
|
@ -70,8 +70,8 @@ func (s *RegulationScenario) TestShouldBanUserAfterTooManyAttempt() {
|
|||
time.Sleep(9 * time.Second)
|
||||
|
||||
// Enter the correct password and test a successful login
|
||||
s.WaitElementLocatedByID(ctx, s.T(), "password-textfield").SendKeys("password")
|
||||
s.WaitElementLocatedByID(ctx, s.T(), "sign-in-button").Click()
|
||||
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() //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
|
||||
s.verifyIsSecondFactorPage(ctx, s.T())
|
||||
}
|
||||
|
||||
|
|
|
@ -88,8 +88,8 @@ func init() {
|
|||
}
|
||||
|
||||
teardown := func(suitePath string) error {
|
||||
kubectl.StopDashboard()
|
||||
kubectl.StopProxy()
|
||||
kubectl.StopDashboard() //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
|
||||
kubectl.StopProxy() //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
|
||||
return kind.DeleteCluster()
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ func (s *NetworkACLSuite) TestShouldAccessSecretUpon2FA() {
|
|||
|
||||
wds, err := StartWebDriver()
|
||||
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)
|
||||
wds.doVisit(s.T(), targetURL)
|
||||
|
@ -40,7 +40,7 @@ func (s *NetworkACLSuite) TestShouldAccessSecretUpon1FA() {
|
|||
|
||||
wds, err := StartWebDriverWithProxy("http://proxy-client1.example.com:3128", 4444)
|
||||
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)
|
||||
wds.doVisit(s.T(), targetURL)
|
||||
|
@ -58,7 +58,7 @@ func (s *NetworkACLSuite) TestShouldAccessSecretUpon0FA() {
|
|||
|
||||
wds, err := StartWebDriverWithProxy("http://proxy-client2.example.com:3128", 4444)
|
||||
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.verifySecretAuthorized(ctx, s.T())
|
||||
|
|
|
@ -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))
|
||||
if err != nil {
|
||||
service.Stop()
|
||||
service.Stop() //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
|
||||
panic(err)
|
||||
}
|
||||
|
||||
|
@ -86,7 +86,7 @@ func WithWebdriver(fn func(webdriver selenium.WebDriver) error) error {
|
|||
return err
|
||||
}
|
||||
|
||||
defer wds.Stop()
|
||||
defer wds.Stop() //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
|
||||
|
||||
return fn(wds.WebDriver)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue