Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ACNA-1741 - invalid config error #565

Merged
merged 7 commits into from
Aug 23, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion schema/config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,12 @@
"oauthsinglepageapp"
]
},
"oauth2": { "$ref": "#/definitions/oauth2" },
"jwt": { "$ref": "#/definitions/jwt" }
},
"required": [ "id", "name" ],
"if": { "properties": { "integration_type": { "const": "apikey" } } },
"then": { "properties": { "oauth2": { "$ref": "#/definitions/apikey" } } },
"else": { "properties": { "oauth2": { "$ref": "#/definitions/oauth2" } } },
"oneOf": [
{ "required": ["oauth2"] },
{ "required": ["jwt"] }
Expand Down Expand Up @@ -172,6 +174,13 @@
},
"required": [ "client_id", "client_secret", "redirect_uri", "defaultRedirectUri" ]
},
"apikey": {
"type": "object",
"properties": {
"client_id": { "type": "string" }
},
"required": [ "client_id" ]
},
"jwt": {
"type": "object",
"properties": {
Expand Down
5 changes: 5 additions & 0 deletions test/__fixtures__/existing.merged.aio
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@
"name": "PröjectB",
"integration_type": "service"
},
{
"id": "17561139",
"name": "Projéct_C",
"integration_type": "apikey"
},
{
"id": "17950",
"name": "New_Test_Intégration_8",
Expand Down
1 change: 1 addition & 0 deletions test/__fixtures__/existing.merged.env
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ AIO_ims_contexts_PröjectB_technical__account__email=XTXTXTXTXTX@techacct.adobe.
AIO_ims_contexts_PröjectB_technical__account__id=IDIDIDIDID@techacct.adobe.com
AIO_ims_contexts_PröjectB_meta__scopes=["ent_smartcontent_sdk","ent_adobeio_sdk"]
AIO_ims_contexts_PröjectB_ims__org__id=XOXOXOXOXOXOX@AdobeOrg
AIO_ims_contexts_Projéct__C_client__id=XYXYXYXYXYXYXYXYX
AIO_ims_contexts_New__Test__Intégration__8_client__id=XRXRXRXRXRXRXRXRXR
AIO_ims_contexts_New__Test__Intégration__8_client__secret=XRXRXRXRXRXRXRXRXRX
AIO_ims_contexts_New__Test__Intégration__8_redirect__uri=["https://abc123/foo"]
Expand Down
8 changes: 8 additions & 0 deletions test/__fixtures__/invalid.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@
]
}
},
{
"id": "17561138",
"name": "Projéct C",
"integration_type": "apikey",
"oauth2": {
"client_secret": "XYXYXYXYZZZZZZ"
}
},
{
"id": "17950",
"name": "NewTestIntegration8",
Expand Down
5 changes: 5 additions & 0 deletions test/__fixtures__/valid.config.aio
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@
"name": "PröjectB",
"integration_type": "service"
},
{
"id": "17561139",
"name": "Projéct_C",
"integration_type": "apikey"
},
{
"id": "17950",
"name": "New_Test_Intégration_8",
Expand Down
1 change: 1 addition & 0 deletions test/__fixtures__/valid.config.env
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ AIO_ims_contexts_PröjectB_technical__account__email=XTXTXTXTXTX@techacct.adobe.
AIO_ims_contexts_PröjectB_technical__account__id=IDIDIDIDID@techacct.adobe.com
AIO_ims_contexts_PröjectB_meta__scopes=["ent_smartcontent_sdk","ent_adobeio_sdk"]
AIO_ims_contexts_PröjectB_ims__org__id=XOXOXOXOXOXOX@AdobeOrg
AIO_ims_contexts_Projéct__C_client__id=XYXYXYXYXYXYXYXYX
AIO_ims_contexts_New__Test__Intégration__8_client__id=XRXRXRXRXRXRXRXRXR
AIO_ims_contexts_New__Test__Intégration__8_client__secret=XRXRXRXRXRXRXRXRXRX
AIO_ims_contexts_New__Test__Intégration__8_redirect__uri=["https://abc123/foo"]
Expand Down
8 changes: 8 additions & 0 deletions test/__fixtures__/valid.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@
]
}
},
{
"id": "17561139",
"name": "Projéct C",
"integration_type": "apikey",
"oauth2": {
"client_id": "XYXYXYXYXYXYXYXYX"
}
},
{
"id": "17950",
"name": "New Test Intégration 8",
Expand Down
5 changes: 3 additions & 2 deletions test/schema.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ test('validate failure', () => {
const ajv = new Ajv({ allErrors: true })
const validate = ajv.compile(schema)
const valid = validate(fixtureJson('invalid.config.json'))
// the 4 errors are the missing name properties, and techacct migration to two new properties
expect(validate.errors.length).toEqual(4)
// the 4 errors are the missing name properties, techacct migration to two new properties
// the rest 2 are missing client_id and failing keyword `then`
expect(validate.errors.length).toEqual(6)
expect(valid).toBeFalsy()
})