Skip to content

Commit

Permalink
fix test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
hperl committed Dec 11, 2024
1 parent 988c628 commit aec9ff9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion selfservice/flow/registration/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ func TestOIDCStrategyOrder(t *testing.T) {

// reorder the strategies
reg.WithSelfserviceStrategies(t, []any{
oidc.NewStrategy(reg),
oidc.NewStrategy(reg, oidc.ForCredentialType(identity.CredentialsTypeOIDC)),
password.NewStrategy(reg),
})

Expand Down
13 changes: 13 additions & 0 deletions selfservice/strategy/oidc/strategy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ func TestStrategy(t *testing.T) {
newOIDCProvider(t, ts, remotePublic, remoteAdmin, "valid"),
newOIDCProvider(t, ts, remotePublic, remoteAdmin, "valid2"),
newOIDCProvider(t, ts, remotePublic, remoteAdmin, "secondProvider"),
newOIDCProvider(t, ts, remotePublic, remoteAdmin, "saml:provider"),
newOIDCProvider(t, ts, remotePublic, remoteAdmin, "claimsViaUserInfo", func(c *oidc.Configuration) {
c.ClaimsSource = oidc.ClaimsSourceUserInfo
}),
Expand Down Expand Up @@ -338,6 +339,18 @@ func TestStrategy(t *testing.T) {
}
})

t.Run("case=should redirect to UI because strategy not responsible", func(t *testing.T) {
for k, v := range []string{
loginAction(newBrowserLoginFlow(t, returnTS.URL, time.Minute).ID),
registerAction(newBrowserRegistrationFlow(t, returnTS.URL, time.Minute).ID),
} {
t.Run(fmt.Sprintf("case=%d", k), func(t *testing.T) {
res, body := makeRequest(t, "saml:provider", v, url.Values{})
assert.Contains(t, res.Request.URL.String(), uiTS.URL, "Redirect does not point to UI server. Status: %d, body: %s", res.StatusCode, body)
})
}
})

t.Run("case=should fail because flow does not exist", func(t *testing.T) {
for k, v := range []string{loginAction(x.NewUUID()), registerAction(x.NewUUID())} {
t.Run(fmt.Sprintf("case=%d", k), func(t *testing.T) {
Expand Down

0 comments on commit aec9ff9

Please sign in to comment.