-
-
Notifications
You must be signed in to change notification settings - Fork 963
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: re-add WithIdentifier (#3992)
- Loading branch information
1 parent
e070b27
commit 0da0c9b
Showing
9 changed files
with
102 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -922,7 +922,7 @@ func TestFormHydration(t *testing.T) { | |
configtesthelpers.WithConfigValue(mfaEnabled, config.ViperKeySecurityAccountEnumerationMitigate, true), | ||
t, | ||
) | ||
require.ErrorIs(t, fh.PopulateLoginMethodIdentifierFirstCredentials(r, f), idfirst.ErrNoCredentialsFound) | ||
require.ErrorIs(t, fh.PopulateLoginMethodIdentifierFirstCredentials(r, f, login.WithIdentifier("[email protected]")), idfirst.ErrNoCredentialsFound) | ||
toSnapshot(t, f) | ||
}) | ||
|
||
|
@@ -931,7 +931,7 @@ func TestFormHydration(t *testing.T) { | |
configtesthelpers.WithConfigValue(passwordlessEnabled, config.ViperKeySecurityAccountEnumerationMitigate, true), | ||
t, | ||
) | ||
require.NoError(t, fh.PopulateLoginMethodIdentifierFirstCredentials(r, f)) | ||
require.NoError(t, fh.PopulateLoginMethodIdentifierFirstCredentials(r, f, login.WithIdentifier("[email protected]"))) | ||
toSnapshot(t, f) | ||
}) | ||
}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -549,6 +549,12 @@ func TestFormHydration(t *testing.T) { | |
toSnapshot(t, f) | ||
}) | ||
|
||
t.Run("case=WithIdentifier", func(t *testing.T) { | ||
r, f := newFlow(ctx, t) | ||
require.ErrorIs(t, fh.PopulateLoginMethodIdentifierFirstCredentials(r, f, login.WithIdentifier("[email protected]")), idfirst.ErrNoCredentialsFound) | ||
toSnapshot(t, f) | ||
}) | ||
|
||
t.Run("case=WithIdentityHint", func(t *testing.T) { | ||
t.Run("case=account enumeration mitigation enabled", func(t *testing.T) { | ||
ctx := configtesthelpers.WithConfigValue(ctx, config.ViperKeySecurityAccountEnumerationMitigate, true) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -120,6 +120,12 @@ func TestFormHydration(t *testing.T) { | |
toSnapshot(t, f) | ||
}) | ||
|
||
t.Run("case=WithIdentifier", func(t *testing.T) { | ||
r, f := newFlow(ctx, t) | ||
require.ErrorIs(t, fh.PopulateLoginMethodIdentifierFirstCredentials(r, f, login.WithIdentifier("[email protected]")), idfirst.ErrNoCredentialsFound) | ||
toSnapshot(t, f) | ||
}) | ||
|
||
t.Run("case=WithIdentityHint", func(t *testing.T) { | ||
t.Run("case=account enumeration mitigation enabled", func(t *testing.T) { | ||
ctx := configtesthelpers.WithConfigValue(ctx, config.ViperKeySecurityAccountEnumerationMitigate, true) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -415,6 +415,22 @@ func TestFormHydration(t *testing.T) { | |
}) | ||
}) | ||
|
||
t.Run("case=WithIdentifier", func(t *testing.T) { | ||
t.Run("case=account enumeration mitigation disabled", func(t *testing.T) { | ||
ctx := configtesthelpers.WithConfigValue(ctx, config.ViperKeySecurityAccountEnumerationMitigate, false) | ||
r, f := newFlow(ctx, t) | ||
require.ErrorIs(t, fh.PopulateLoginMethodIdentifierFirstCredentials(r, f, login.WithIdentifier("[email protected]")), idfirst.ErrNoCredentialsFound) | ||
toSnapshot(t, f) | ||
}) | ||
|
||
t.Run("case=account enumeration mitigation enabled", func(t *testing.T) { | ||
ctx := configtesthelpers.WithConfigValue(ctx, config.ViperKeySecurityAccountEnumerationMitigate, true) | ||
r, f := newFlow(ctx, t) | ||
require.ErrorIs(t, fh.PopulateLoginMethodIdentifierFirstCredentials(r, f, login.WithIdentifier("[email protected]")), idfirst.ErrNoCredentialsFound) | ||
toSnapshot(t, f) | ||
}) | ||
}) | ||
|
||
t.Run("case=WithIdentityHint", func(t *testing.T) { | ||
t.Run("case=account enumeration mitigation enabled", func(t *testing.T) { | ||
ctx := configtesthelpers.WithConfigValue(ctx, config.ViperKeySecurityAccountEnumerationMitigate, true) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1019,7 +1019,6 @@ func TestCompleteLogin(t *testing.T) { | |
}, | ||
expectSuccess: false, | ||
}} { | ||
|
||
t.Run("case="+tc.name, func(t *testing.T) { | ||
if tc.setupFn != nil { | ||
cleanup := tc.setupFn() | ||
|
@@ -1172,6 +1171,22 @@ func TestFormHydration(t *testing.T) { | |
}) | ||
}) | ||
|
||
t.Run("case=WithIdentifier", func(t *testing.T) { | ||
t.Run("case=account enumeration mitigation disabled", func(t *testing.T) { | ||
ctx := configtesthelpers.WithConfigValue(ctx, config.ViperKeySecurityAccountEnumerationMitigate, false) | ||
r, f := newFlow(ctx, t) | ||
require.ErrorIs(t, fh.PopulateLoginMethodIdentifierFirstCredentials(r, f, login.WithIdentifier("[email protected]")), idfirst.ErrNoCredentialsFound) | ||
toSnapshot(t, f) | ||
}) | ||
|
||
t.Run("case=account enumeration mitigation enabled", func(t *testing.T) { | ||
ctx := configtesthelpers.WithConfigValue(ctx, config.ViperKeySecurityAccountEnumerationMitigate, true) | ||
r, f := newFlow(ctx, t) | ||
require.ErrorIs(t, fh.PopulateLoginMethodIdentifierFirstCredentials(r, f, login.WithIdentifier("[email protected]")), idfirst.ErrNoCredentialsFound) | ||
toSnapshot(t, f) | ||
}) | ||
}) | ||
|
||
t.Run("case=WithIdentityHint", func(t *testing.T) { | ||
t.Run("case=account enumeration mitigation enabled and identity has no password", func(t *testing.T) { | ||
ctx := configtesthelpers.WithConfigValue(ctx, config.ViperKeySecurityAccountEnumerationMitigate, true) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -810,6 +810,48 @@ func TestFormHydration(t *testing.T) { | |
}) | ||
}) | ||
|
||
t.Run("case=WithIdentifier", func(t *testing.T) { | ||
t.Run("case=passwordless enabled", func(t *testing.T) { | ||
t.Run("case=account enumeration mitigation disabled", func(t *testing.T) { | ||
r, f := newFlow( | ||
configtesthelpers.WithConfigValue(passwordlessEnabled, config.ViperKeySecurityAccountEnumerationMitigate, false), | ||
t, | ||
) | ||
require.ErrorIs(t, fh.PopulateLoginMethodIdentifierFirstCredentials(r, f, login.WithIdentifier("[email protected]")), idfirst.ErrNoCredentialsFound) | ||
toSnapshot(t, f) | ||
}) | ||
|
||
t.Run("case=account enumeration mitigation enabled", func(t *testing.T) { | ||
r, f := newFlow( | ||
configtesthelpers.WithConfigValue(passwordlessEnabled, config.ViperKeySecurityAccountEnumerationMitigate, true), | ||
t, | ||
) | ||
require.ErrorIs(t, fh.PopulateLoginMethodIdentifierFirstCredentials(r, f, login.WithIdentifier("[email protected]")), idfirst.ErrNoCredentialsFound) | ||
toSnapshot(t, f) | ||
}) | ||
}) | ||
|
||
t.Run("case=mfa enabled", func(t *testing.T) { | ||
t.Run("case=account enumeration mitigation disabled", func(t *testing.T) { | ||
r, f := newFlow( | ||
configtesthelpers.WithConfigValue(mfaEnabled, config.ViperKeySecurityAccountEnumerationMitigate, false), | ||
t, | ||
) | ||
require.ErrorIs(t, fh.PopulateLoginMethodIdentifierFirstCredentials(r, f, login.WithIdentifier("[email protected]")), idfirst.ErrNoCredentialsFound) | ||
toSnapshot(t, f) | ||
}) | ||
|
||
t.Run("case=account enumeration mitigation enabled", func(t *testing.T) { | ||
r, f := newFlow( | ||
configtesthelpers.WithConfigValue(mfaEnabled, config.ViperKeySecurityAccountEnumerationMitigate, true), | ||
t, | ||
) | ||
require.ErrorIs(t, fh.PopulateLoginMethodIdentifierFirstCredentials(r, f, login.WithIdentifier("[email protected]")), idfirst.ErrNoCredentialsFound) | ||
toSnapshot(t, f) | ||
}) | ||
}) | ||
}) | ||
|
||
t.Run("case=WithIdentityHint", func(t *testing.T) { | ||
t.Run("case=account enumeration mitigation enabled", func(t *testing.T) { | ||
mfaEnabled := configtesthelpers.WithConfigValue(mfaEnabled, config.ViperKeySecurityAccountEnumerationMitigate, true) | ||
|