Skip to content

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jonas-jonas committed Aug 20, 2024
1 parent df6e1e2 commit 3078490
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
18 changes: 11 additions & 7 deletions selfservice/strategy/oidc/strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -668,8 +668,6 @@ func (s *Strategy) handleError(w http.ResponseWriter, r *http.Request, f flow.Fl
}

func (s *Strategy) populateAccountLinkingUI(ctx context.Context, lf *login.Flow, usedProviderID string, duplicateIdentifier string, availableCredentials []string) {
// TODO(jonas): since this clears messages and deletes nodes, there should be more safe-guards in place, that ensure that if there is a
// mis-configuration, we don't delete the entire flow, making it useless for the user.
newLoginURL := s.d.Config().SelfServiceFlowLoginUI(ctx).String()
usedProviderLabel := usedProviderID
provider, _ := s.provider(ctx, usedProviderID)
Expand Down Expand Up @@ -702,11 +700,17 @@ func (s *Strategy) populateAccountLinkingUI(ctx context.Context, lf *login.Flow,
lf.UI.Nodes[i].Meta.Label = text.NewInfoLoginWithAndLink(p)
}

// Hide nodes from credentials that are not relevant for the user
for _, ct := range availableCredentials {
if ct == string(n.Group) {
nodes = append(nodes, n)
break
// This can happen, if login hints are disabled. In that case, we need to make sure to show all credential options.
// It could in theory also happen due to a mis-configuration, and in that case, we should make sure to not delete the entire flow.
if len(availableCredentials) == 0 {
nodes = append(nodes, n)
} else {
// Hide nodes from credentials that are not relevant for the user
for _, ct := range availableCredentials {
if ct == string(n.Group) {
nodes = append(nodes, n)
break
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ context("Social Sign In Successes", () => {
cy.noSession()

// Log in with the same identifier through the login flow. This should link the accounts.
cy.get(`${appPrefix(app)}input[name="identifier"]`).type(email)
cy.get('input[name="password"]').type(password)
cy.submitPasswordForm()
cy.location("pathname").should("not.contain", "/login")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,15 +252,13 @@ context("Social Sign Up Successes", () => {

cy.location("href").should("contain", "/login")

cy.get("[name='provider'][value='hydra']").should("be.visible")
cy.get("[name='provider'][value='google']").should("be.visible")
cy.get("[name='provider'][value='github']").should("be.visible")

if (app === "express") {
cy.get("[data-testid='forgot-password-link']").should("be.visible")
}

cy.get("input[name='identifier']").type(email)
cy.get("input[name='password']").type(password)
cy.submitPasswordForm()
cy.getSession()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ context("Social Sign In Settings Success", () => {

cy.get('[data-testid="ui/message/1010016"]').should(
"contain.text",
"Signing in will link your account",
"as another way to sign in to your account.",
)

cy.noSession()
Expand Down

0 comments on commit 3078490

Please sign in to comment.