Skip to content

Commit

Permalink
test: additional code credential test case (#4122)
Browse files Browse the repository at this point in the history
  • Loading branch information
aeneasr authored Sep 25, 2024
1 parent 72aae5b commit 4f2c854
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 0 deletions.
14 changes: 14 additions & 0 deletions identity/.snapshots/TestSchemaExtensionCredentials-case=13.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"type": "code",
"config": {
"addresses": [
{
"channel": "email",
"address": "bar@ory.sh"
}
]
},
"version": 0,
"created_at": "0001-01-01T00:00:00Z",
"updated_at": "0001-01-01T00:00:00Z"
}
10 changes: 10 additions & 0 deletions identity/extension_credentials_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,16 @@ func TestSchemaExtensionCredentials(t *testing.T) {
},
ct: identity.CredentialsTypeCodeAuth,
},
{
doc: `{"email":"bar@ory.sh"}`,
schema: "file://./stub/extension/credentials/email.schema.json",
expectedIdentifiers: []string{"bar@ory.sh"},
existing: &identity.Credentials{
Identifiers: []string{"foo@ory.sh"},
Config: sqlxx.JSONRawMessage(`{"addresses":[{"channel":"email","address":"foo@ory.sh"}]}`),
},
ct: identity.CredentialsTypeCodeAuth,
},
} {
t.Run(fmt.Sprintf("case=%d", k), func(t *testing.T) {
c := jsonschema.NewCompiler()
Expand Down
44 changes: 44 additions & 0 deletions identity/stub/extension/credentials/email.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"$id": "https://schemas.ory.sh/presets/kratos/identity.email.schema.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Person",
"type": "object",
"properties": {
"email": {
"type": "string",
"format": "email",
"title": "E-Mail",
"ory.sh/kratos": {
"credentials": {
"password": {
"identifier": true
},
"webauthn": {
"identifier": true
},
"totp": {
"account_name": true
},
"code": {
"identifier": true,
"via": "email"
},
"passkey": {
"display_name": true
}
},
"recovery": {
"via": "email"
},
"verification": {
"via": "email"
}
},
"maxLength": 320
}
},
"required": [
"email"
],
"additionalProperties": false
}

0 comments on commit 4f2c854

Please sign in to comment.