Skip to content

Commit

Permalink
chore: reenable and fix schema tests (#737)
Browse files Browse the repository at this point in the history
  • Loading branch information
zepatrik authored and aeneasr committed Oct 9, 2020
1 parent 03f453e commit 2c0e141
Show file tree
Hide file tree
Showing 42 changed files with 290 additions and 168 deletions.
86 changes: 53 additions & 33 deletions .schema/config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,32 @@
"client_id",
"client_secret",
"mapper_url"
]
],
"if": {
"properties": {
"provider": {
"const": "microsoft"
}
},
"required": [
"provider"
]
},
"then": {
"required": [
"tenant"
]
},
"else": {
"not": {
"properties": {
"tenant": {}
},
"required": [
"tenant"
]
}
}
},
"selfServiceAfterSettingsMethod": {
"type": "object",
Expand Down Expand Up @@ -895,12 +920,15 @@
]
}
},
"required": [
"id",
"url"
],
"not": {
"type": "object",
"properties": {
"id": {
"type": "string",
"pattern": "^default$"
"const": "default"
}
},
"additionalProperties": true
Expand Down Expand Up @@ -1049,9 +1077,15 @@
"enabled": {
"const": true
}
}
},
"required": [
"enabled"
]
}
}
},
"required": [
"verification"
]
},
{
"properties": {
Expand All @@ -1060,41 +1094,27 @@
"enabled": {
"const": true
}
}
},
"required": [
"enabled"
]
}
}
},
"required": [
"recovery"
]
}
]
}
}
},
"required": [
"flows"
]
}
}
},
"then": {
},
"required": [
"courier"
"selfservice"
]
}
},
{
"if": {
"properties": {
"selfservice": {
"properties": {
"flows": {
"properties": {
"verification": {
"properties": {
"enabled": {
"const": true
}
}
}
}
}
}
}
}
},
"then": {
"required": [
Expand Down
17 changes: 17 additions & 0 deletions test/schema/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Schema Tests

This test works by validating cases of the payload against a schema.
To add a case, place a file in the `${schemaName}.schema.test.${success|failure}` folder.
A success case should validate, a failure case should throw a validation error.

## Handling of "$ref"

To allow testing definitions on their own, and reduce the size of individual cases,
every `"$ref"` in the schema will be replaced with `"const"` before validation.
This means that a case only has to define the pointer as a string. Example:

```yaml
default_browser_return_url: "#/definitions/defaultReturnTo"
hooks:
- "#/definitions/selfServiceSessionRevokerHook"
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
selfservice:
default_browser_return_url: "#/definitions/defaultReturnTo"

dsn: foo

identity:
default_schema_url: https://example.com
schemas:
- id: default
url: file://path/to/identity.traits.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
selfservice:
default_browser_return_url: "#/definitions/defaultReturnTo"
flows:
recovery:
enabled: true

dsn: foo

identity:
default_schema_url: https://example.com
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
selfservice:
default_browser_return_url: "#/definitions/defaultReturnTo"
flows:
verification:
enabled: true

dsn: foo

identity:
default_schema_url: https://example.com
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
id: 1
provider: unknown
client_id: 1
client_secret: 1
issuer_url: not an URL
auth_url: not an URL
token_url: not an URL
mapper_url: not an URL
scope:
- 1
tenant: 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
id: foo
provider: github
client_id: asdf
client_secret: asdf
mapper_url: file://./mapper_file
tenant: org
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
id: foo
provider: microsoft
client_id: asdf
client_secret: asdf
mapper_url: file://./mapper_file
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
x1.0.0
95 changes: 0 additions & 95 deletions test/schema/fixtures/config.schema.test.success/allKeys.main.yaml

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/dashboard
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
https://my-app.com/dashboard

0 comments on commit 2c0e141

Please sign in to comment.