Skip to content

Commit

Permalink
fix: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
alnr committed Jan 24, 2024
1 parent 96dba50 commit e8740c3
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 33 deletions.
5 changes: 1 addition & 4 deletions hash/hash_comparator.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
"golang.org/x/crypto/bcrypt"

//nolint:staticcheck
//lint:ignore SA1019
//lint:ignore SA1019 compatibility for imported passwords
"golang.org/x/crypto/md4" //#nosec G501 -- compatibility for imported passwords
"golang.org/x/crypto/pbkdf2"
"golang.org/x/crypto/scrypt"
Expand Down Expand Up @@ -211,7 +211,6 @@ func CompareScrypt(_ context.Context, password []byte, hash []byte) error {

func CompareSSHA(_ context.Context, password []byte, hash []byte) error {
hasher, salt, hash, err := decodeSSHAHash(string(hash))

if err != nil {
return err
}
Expand All @@ -222,7 +221,6 @@ func CompareSSHA(_ context.Context, password []byte, hash []byte) error {
}

func CompareSHA(_ context.Context, password []byte, hash []byte) error {

hasher, pf, salt, hash, err := decodeSHAHash(string(hash))
if err != nil {
return err
Expand Down Expand Up @@ -485,7 +483,6 @@ func decodeSHAHash(encodedHash string) (hasher string, pf, salt, hash []byte, er

// used for CompareSHA and CompareSSHA
func compareSHAHelper(hasher string, raw []byte, hash []byte) error {

var sha []byte

switch hasher {
Expand Down
4 changes: 2 additions & 2 deletions selfservice/strategy/code/strategy_recovery_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ func TestRecovery(t *testing.T) {
expectedAAL: "aal2",
},
} {
t.Run(fmt.Sprintf("%s", tc.desc), func(t *testing.T) {
t.Run(tc.desc, func(t *testing.T) {
client := testhelpers.NewClientWithCookies(t)
email := testhelpers.RandomEmail()
i := createIdentityToRecover(t, reg, email)
Expand Down Expand Up @@ -1191,7 +1191,7 @@ func TestRecovery_WithContinueWith(t *testing.T) {
expectedAAL: "aal2",
},
} {
t.Run(fmt.Sprintf("%s", tc.desc), func(t *testing.T) {
t.Run(tc.desc, func(t *testing.T) {
client := testhelpers.NewClientWithCookies(t)
email := testhelpers.RandomEmail()
i := createIdentityToRecover(t, reg, email)
Expand Down
2 changes: 1 addition & 1 deletion selfservice/strategy/link/strategy_recovery_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ func TestRecovery(t *testing.T) {
},
},
} {
t.Run(fmt.Sprintf("%s", tc.desc), func(t *testing.T) {
t.Run(tc.desc, func(t *testing.T) {
email := testhelpers.RandomEmail()
createIdentityToRecover(t, reg, email)

Expand Down
26 changes: 13 additions & 13 deletions selfservice/strategy/password/op_helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,25 +43,25 @@ type callTrace string

const (
RegistrationUI callTrace = "registration-ui"
RegistrationWithOAuth2LoginChallenge = "registration-with-oauth2-login-challenge"
RegistrationWithFlowID = "registration-with-flow-id"
LoginUI = "login-ui"
LoginWithOAuth2LoginChallenge = "login-with-oauth2-login-challenge"
LoginWithFlowID = "login-with-flow-id"
Consent = "consent"
ConsentWithChallenge = "consent-with-challenge"
ConsentAccept = "consent-accept"
ConsentSkip = "consent-skip"
ConsentClientSkip = "consent-client-skip"
CodeExchange = "code-exchange"
CodeExchangeWithToken = "code-exchange-with-token"
RegistrationWithOAuth2LoginChallenge callTrace = "registration-with-oauth2-login-challenge"
RegistrationWithFlowID callTrace = "registration-with-flow-id"
LoginUI callTrace = "login-ui"
LoginWithOAuth2LoginChallenge callTrace = "login-with-oauth2-login-challenge"
LoginWithFlowID callTrace = "login-with-flow-id"
Consent callTrace = "consent"
ConsentWithChallenge callTrace = "consent-with-challenge"
ConsentAccept callTrace = "consent-accept"
ConsentSkip callTrace = "consent-skip"
ConsentClientSkip callTrace = "consent-client-skip"
CodeExchange callTrace = "code-exchange"
CodeExchangeWithToken callTrace = "code-exchange-with-token"
)

type testContextKey string

const (
TestUIConfig testContextKey = "test-ui-config"
TestOAuthClientState = "test-oauth-client-state"
TestOAuthClientState testContextKey = "test-oauth-client-state"
)

type testConfig struct {
Expand Down
6 changes: 2 additions & 4 deletions selfservice/strategy/password/op_login_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,8 @@ func TestOAuth2Provider(t *testing.T) {
require.NoError(t, err)
assert.Equal(t, http.StatusOK, resp.StatusCode)

if completedAcceptRequest != nil {
*c.callTrace = append(*c.callTrace, ConsentAccept)
}
assert.NotNil(t, completedAcceptRequest)
require.NotNil(t, completedAcceptRequest)
*c.callTrace = append(*c.callTrace, ConsentAccept)

t.Logf("[consentTS] navigating to %s", completedAcceptRequest.RedirectTo)
resp, err = c.browserClient.Get(completedAcceptRequest.RedirectTo)
Expand Down
14 changes: 5 additions & 9 deletions selfservice/strategy/password/op_registration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,10 @@ func TestOAuth2ProviderRegistration(t *testing.T) {

router := x.NewRouterPublic()

type contextKey string
const (
TestUIConfig = "test-ui-config"
TestOAuthClientState = "test-oauth-client-state"
TestUIConfig contextKey = "test-ui-config"
TestOAuthClientState contextKey = "test-oauth-client-state"
)

router.GET("/login-ts", func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
Expand Down Expand Up @@ -176,10 +177,8 @@ func TestOAuth2ProviderRegistration(t *testing.T) {
require.NoError(t, err)
assert.Equal(t, http.StatusOK, resp.StatusCode)

if completedAcceptRequest != nil {
*c.callTrace = append(*c.callTrace, ConsentAccept)
}
assert.NotNil(t, completedAcceptRequest)
require.NotNil(t, completedAcceptRequest)
*c.callTrace = append(*c.callTrace, ConsentAccept)

t.Logf("[consentTS] navigating to %s", completedAcceptRequest.RedirectTo)
resp, err = c.browserClient.Get(completedAcceptRequest.RedirectTo)
Expand Down Expand Up @@ -244,9 +243,6 @@ func TestOAuth2ProviderRegistration(t *testing.T) {
conf.MustSet(ctx, config.HookStrategyKey(config.ViperKeySelfServiceRegistrationAfter, identity.CredentialsTypePassword.String()), []config.SelfServiceHook{{Name: "session"}})
testhelpers.SetDefaultIdentitySchema(conf, "file://./stub/registration.schema.json")

type state struct {
cas clientAppState
}
doOAuthFlow := func(t *testing.T, ctx context.Context, oauthClient *oauth2.Config, browserClient *http.Client) {
t.Helper()

Expand Down

0 comments on commit e8740c3

Please sign in to comment.