Skip to content

Commit

Permalink
fix: add mfa e2e test scenarios and resolve found issues
Browse files Browse the repository at this point in the history
  • Loading branch information
aeneasr committed Oct 19, 2021
1 parent 89736ed commit 436992d
Show file tree
Hide file tree
Showing 32 changed files with 1,133 additions and 274 deletions.
198 changes: 198 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,18 @@
"scripts": {
"format": "prettier --write ${npm_package_config_prettierTarget}",
"format:check": "prettier --check ${npm_package_config_prettierTarget}",
"test": "cypress run",
"test:watch": "cypress open",
"test": "cypress run --browser chrome",
"test:watch": "cypress open --browser chrome",
"openapi-generator-cli": "openapi-generator-cli",
"wait-on": "wait-on",
"text-run": "exit 0"
},
"devDependencies": {
"chrome-remote-interface": "^0.31.0",
"cypress": "^8.3.0",
"dayjs": "^1.10.4",
"ory-prettier-styles": "1.1.1",
"otplib": "^12.0.1",
"prettier": "2.2.1",
"wait-on": "5.3.0"
},
Expand Down
3 changes: 3 additions & 0 deletions selfservice/flow/login/sort.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ func sortNodes(n node.Nodes) error {
node.DefaultGroup,
node.OpenIDConnectGroup,
node.PasswordGroup,
node.WebAuthnGroup,
node.TOTPGroup,
node.LookupGroup,
}),
node.SortUseOrder([]string{
"password_identifier",
Expand Down
30 changes: 15 additions & 15 deletions selfservice/strategy/lookup/fixtures/login/with.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
[
{
"attributes": {
"disabled": false,
"name": "csrf_token",
"required": true,
"type": "hidden",
"value": "YXA2OGtnOXZ3a3F3M3M3MGVtYXBraHJjeHEyMzB5aTU="
},
"group": "default",
"messages": [],
"meta": {},
"type": "input"
},
{
"attributes": {
"disabled": false,
Expand Down Expand Up @@ -31,24 +44,11 @@
"meta": {
"label": {
"context": {},
"id": 1010001,
"text": "Sign in",
"id": 1010010,
"text": "Use backup recovery code",
"type": "info"
}
},
"type": "input"
},
{
"attributes": {
"disabled": false,
"name": "csrf_token",
"required": true,
"type": "hidden",
"value": "anhicmI2dWFhMWlwbHlydWNhZnF4cW13dXhmOW1ucDc="
},
"group": "default",
"messages": [],
"meta": {},
"type": "input"
}
]
2 changes: 1 addition & 1 deletion selfservice/strategy/lookup/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func (s *Strategy) PopulateLoginMethod(r *http.Request, requestedAAL identity.Au

sr.UI.SetCSRF(s.d.GenerateCSRFToken(r))
sr.UI.SetNode(node.NewInputField(node.LookupCodeEnter, "", node.LookupGroup, node.InputAttributeTypeText, node.WithRequiredInputAttribute).WithMetaLabel(text.NewInfoLoginLookupLabel()))
sr.UI.GetNodes().Append(node.NewInputField("method", s.ID(), node.LookupGroup, node.InputAttributeTypeSubmit).WithMetaLabel(text.NewInfoLogin()))
sr.UI.GetNodes().Append(node.NewInputField("method", s.ID(), node.LookupGroup, node.InputAttributeTypeSubmit).WithMetaLabel(text.NewInfoLoginLookup()))

return nil
}
Expand Down
2 changes: 1 addition & 1 deletion selfservice/strategy/lookup/login_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func TestCompleteLogin(t *testing.T) {

apiClient := testhelpers.NewHTTPClientWithIdentitySessionToken(t, reg, id)
f := testhelpers.InitializeLoginFlowViaAPI(t, apiClient, publicTS, false, testhelpers.InitFlowWithAAL(identity.AuthenticatorAssuranceLevel2))
assertx.EqualAsJSONExcept(t, json.RawMessage(loginFixtureWithLookup), f.Ui.Nodes, []string{"2.attributes.value"})
assertx.EqualAsJSONExcept(t, json.RawMessage(loginFixtureWithLookup), f.Ui.Nodes, []string{"0.attributes.value"})
})

t.Run("case=lookup payload is not set when identity has no lookup", func(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion selfservice/strategy/password/login_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@ func TestCompleteLogin(t *testing.T) {

require.Contains(t, res.Request.URL.Path, "return-ts", "%s", res.Request.URL.String())
assert.Equal(t, identifier, gjson.Get(body2, "identity.traits.subject").String(), "%s", body2)
assert.NotEqual(t, gjson.Get(body1, "id").String(), gjson.Get(body2, "id").String(), "%s\n\n%s\n", body1, body2)
assert.Equal(t, gjson.Get(body1, "id").String(), gjson.Get(body2, "id").String(), "%s\n\n%s\n", body1, body2)
})

t.Run("should login same identity regardless of identifier capitalization", func(t *testing.T) {
Expand Down

0 comments on commit 436992d

Please sign in to comment.