Skip to content

Commit

Permalink
WIP: settings tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hperl committed Dec 7, 2023
1 parent 82839e1 commit 41f28f0
Show file tree
Hide file tree
Showing 13 changed files with 865 additions and 82 deletions.
14 changes: 13 additions & 1 deletion identity/identity.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,12 +240,24 @@ func (i *Identity) GetCredentialsOr(t CredentialsType, fallback *Credentials) *C
return c
}

func (i *Identity) UpsertCredentialsConfig(t CredentialsType, conf []byte, version int) {
type CredentialsOptions func(c *Credentials)

func WithAdditionalIdentifier(identifier string) CredentialsOptions {
return func(c *Credentials) {
c.Identifiers = append(c.Identifiers, identifier)
}
}

func (i *Identity) UpsertCredentialsConfig(t CredentialsType, conf []byte, version int, opt ...CredentialsOptions) {
c, ok := i.GetCredentials(t)
if !ok {
c = &Credentials{}
}

for _, optionFn := range opt {
optionFn(c)
}

c.Type = t
c.IdentityID = i.ID
c.Config = conf
Expand Down
2 changes: 1 addition & 1 deletion internal/testhelpers/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type SessionLifespanProvider struct {
e time.Duration
}

func (p *SessionLifespanProvider) SessionLifespan(ctx context.Context) time.Duration {
func (p *SessionLifespanProvider) SessionLifespan(context.Context) time.Duration {
return p.e
}

Expand Down
1 change: 0 additions & 1 deletion selfservice/strategy/passkey/.schema/settings.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
}
},
"required": [
"csrf_token",
"method"
]
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
[
{
"attributes": {
"disabled": false,
"name": "passkey_register_trigger",
"node_type": "input",
"type": "button",
"value": ""
},
"group": "passkey",
"messages": [],
"meta": {
"label": {
"id": 1050019,
"text": "Add passkey",
"type": "info"
}
},
"type": "input"
},
{
"attributes": {
"disabled": false,
"name": "passkey_remove",
"node_type": "input",
"type": "submit",
"value": "626172626172"
},
"group": "passkey",
"messages": [],
"meta": {
"label": {
"context": {
"added_at": "0001-01-01T00:00:00Z",
"added_at_unix": -62135596800,
"display_name": "bar"
},
"id": 1050020,
"text": "Remove passkey \"bar\"",
"type": "info"
}
},
"type": "input"
},
{
"attributes": {
"disabled": false,
"name": "passkey_remove",
"node_type": "input",
"type": "submit",
"value": "666f6f666f6f"
},
"group": "passkey",
"messages": [],
"meta": {
"label": {
"context": {
"added_at": "0001-01-01T00:00:00Z",
"added_at_unix": -62135596800,
"display_name": "foo"
},
"id": 1050020,
"text": "Remove passkey \"foo\"",
"type": "info"
}
},
"type": "input"
},
{
"attributes": {
"disabled": false,
"name": "passkey_settings_register",
"node_type": "input",
"type": "hidden"
},
"group": "passkey",
"messages": [],
"meta": {},
"type": "input"
},
{
"attributes": {
"disabled": false,
"name": "create_passkey_data",
"node_type": "input",
"type": "hidden"
},
"group": "passkey",
"messages": [],
"meta": {},
"type": "input"
},
{
"attributes": {
"disabled": false,
"name": "csrf_token",
"node_type": "input",
"required": true,
"type": "hidden"
},
"group": "default",
"messages": [],
"meta": {},
"type": "input"
},
{
"attributes": {
"disabled": false,
"name": "traits.website",
"node_type": "input",
"type": "text"
},
"group": "profile",
"messages": [],
"meta": {},
"type": "input"
},
{
"attributes": {
"disabled": false,
"name": "traits.email",
"node_type": "input",
"type": "text"
},
"group": "profile",
"messages": [],
"meta": {},
"type": "input"
},
{
"attributes": {
"disabled": false,
"name": "traits.subject",
"node_type": "input",
"type": "text"
},
"group": "profile",
"messages": [],
"meta": {},
"type": "input"
},
{
"attributes": {
"disabled": false,
"name": "method",
"node_type": "input",
"type": "submit",
"value": "profile"
},
"group": "profile",
"messages": [],
"meta": {
"label": {
"id": 1070003,
"text": "Save",
"type": "info"
}
},
"type": "input"
},
{
"attributes": {
"async": true,
"crossorigin": "anonymous",
"id": "webauthn_script",
"integrity": "sha512-YzOFTy1y50T/3vPo0kEOcZASjzaclfJEHdP52e8Tq5g2n8B9ybVa5VdtX1YBBysvFluHihEzXoSFpEF/mRtBKQ==",
"node_type": "script",
"referrerpolicy": "no-referrer",
"type": "text/javascript"
},
"group": "webauthn",
"messages": [],
"meta": {},
"type": "script"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
[
{
"attributes": {
"disabled": false,
"name": "passkey_register_trigger",
"node_type": "input",
"type": "button",
"value": ""
},
"group": "passkey",
"messages": [],
"meta": {
"label": {
"id": 1050019,
"text": "Add passkey",
"type": "info"
}
},
"type": "input"
},
{
"attributes": {
"disabled": false,
"name": "passkey_settings_register",
"node_type": "input",
"type": "hidden"
},
"group": "passkey",
"messages": [],
"meta": {},
"type": "input"
},
{
"attributes": {
"disabled": false,
"name": "create_passkey_data",
"node_type": "input",
"type": "hidden"
},
"group": "passkey",
"messages": [],
"meta": {},
"type": "input"
},
{
"attributes": {
"disabled": false,
"name": "csrf_token",
"node_type": "input",
"required": true,
"type": "hidden"
},
"group": "default",
"messages": [],
"meta": {},
"type": "input"
},
{
"attributes": {
"disabled": false,
"name": "traits.website",
"node_type": "input",
"type": "text"
},
"group": "profile",
"messages": [],
"meta": {},
"type": "input"
},
{
"attributes": {
"disabled": false,
"name": "traits.email",
"node_type": "input",
"type": "text"
},
"group": "profile",
"messages": [],
"meta": {},
"type": "input"
},
{
"attributes": {
"disabled": false,
"name": "traits.subject",
"node_type": "input",
"type": "text"
},
"group": "profile",
"messages": [],
"meta": {},
"type": "input"
},
{
"attributes": {
"disabled": false,
"name": "method",
"node_type": "input",
"type": "submit",
"value": "profile"
},
"group": "profile",
"messages": [],
"meta": {
"label": {
"id": 1070003,
"text": "Save",
"type": "info"
}
},
"type": "input"
},
{
"attributes": {
"async": true,
"crossorigin": "anonymous",
"id": "webauthn_script",
"integrity": "sha512-YzOFTy1y50T/3vPo0kEOcZASjzaclfJEHdP52e8Tq5g2n8B9ybVa5VdtX1YBBysvFluHihEzXoSFpEF/mRtBKQ==",
"node_type": "script",
"referrerpolicy": "no-referrer",
"type": "text/javascript"
},
"group": "webauthn",
"messages": [],
"meta": {},
"type": "script"
}
]
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"totp_url": "otpauth://totp/issuer.ory.sh:6e11a9a7-62fd-4c88-871a-097f18f0306f?algorithm=SHA1&digits=6&issuer=issuer.ory.sh&period=30&secret=2F43HRJNMUW67EDMRR7AKQYRZP3AI6IG",
"webauthn_session_data": {
"passkey_session_data": {
"challenge": "UlxHSTkuMvtVDoV9y5lhu9OyNUP8P7MP0RYAT6Im_rY",
"user_id": "bhGpp2L9TIiHGgl/GPAwbw==",
"userVerification": ""
Expand Down
Loading

0 comments on commit 41f28f0

Please sign in to comment.