Skip to content

Commit

Permalink
fix: unstable webauthn order
Browse files Browse the repository at this point in the history
  • Loading branch information
aeneasr committed Mar 21, 2022
1 parent a4a4e49 commit 6262160
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 18 deletions.
1 change: 1 addition & 0 deletions selfservice/flow/login/sort.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ func sortNodes(ctx context.Context, n node.Nodes) error {
node.LookupGroup,
}),
node.SortUseOrder([]string{
"csrf_token",
"identifier",
"password",
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
{
"attributes": {
"disabled": false,
"name": "identifier",
"name": "csrf_token",
"node_type": "input",
"required": true,
"type": "hidden"
},
"group": "default",
Expand All @@ -14,9 +15,8 @@
{
"attributes": {
"disabled": false,
"name": "csrf_token",
"name": "identifier",
"node_type": "input",
"required": true,
"type": "hidden"
},
"group": "default",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,34 @@
{
"attributes": {
"disabled": false,
"name": "identifier",
"name": "csrf_token",
"node_type": "input",
"required": true,
"type": "text",
"value": ""
"type": "hidden"
},
"group": "default",
"messages": [],
"meta": {
"label": {
"id": 1070004,
"text": "ID",
"type": "info"
}
},
"meta": {},
"type": "input"
},
{
"attributes": {
"disabled": false,
"name": "csrf_token",
"name": "identifier",
"node_type": "input",
"required": true,
"type": "hidden"
"type": "text",
"value": ""
},
"group": "default",
"messages": [],
"meta": {},
"meta": {
"label": {
"id": 1070004,
"text": "ID",
"type": "info"
}
},
"type": "input"
},
{
Expand Down
4 changes: 2 additions & 2 deletions selfservice/strategy/webauthn/login_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ func TestCompleteLogin(t *testing.T) {
t.Run("case=webauthn button exists", func(t *testing.T) {
client := testhelpers.NewClientWithCookies(t)
f := testhelpers.InitializeLoginFlowViaBrowser(t, client, publicTS, false, true)
testhelpers.SnapshotTExcept(t, f.Ui.Nodes, []string{"1.attributes.value"})
testhelpers.SnapshotTExcept(t, f.Ui.Nodes, []string{"0.attributes.value"})
})

t.Run("case=webauthn shows error if user tries to sign in but no such user exists", func(t *testing.T) {
Expand Down Expand Up @@ -459,7 +459,7 @@ func TestCompleteLogin(t *testing.T) {

apiClient := testhelpers.NewHTTPClientWithIdentitySessionToken(t, reg, id)
f := testhelpers.InitializeLoginFlowViaBrowser(t, apiClient, publicTS, false, true, testhelpers.InitFlowWithAAL(identity.AuthenticatorAssuranceLevel2))
assert.Equal(t, gjson.GetBytes(id.Traits, "subject").String(), f.Ui.Nodes[0].Attributes.UiNodeInputAttributes.Value, jsonx.TestMarshalJSONString(t, f.Ui))
assert.Equal(t, gjson.GetBytes(id.Traits, "subject").String(), f.Ui.Nodes[1].Attributes.UiNodeInputAttributes.Value, jsonx.TestMarshalJSONString(t, f.Ui))
testhelpers.SnapshotTExcept(t, f.Ui.Nodes, []string{
"0.attributes.value",
"1.attributes.value",
Expand Down

0 comments on commit 6262160

Please sign in to comment.