diff --git a/schema/config.schema.json b/schema/config.schema.json index 5855c3d7..a5fb09db 100644 --- a/schema/config.schema.json +++ b/schema/config.schema.json @@ -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"] } @@ -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": { diff --git a/test/__fixtures__/existing.merged.aio b/test/__fixtures__/existing.merged.aio index 004759d9..ae41beb0 100644 --- a/test/__fixtures__/existing.merged.aio +++ b/test/__fixtures__/existing.merged.aio @@ -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", diff --git a/test/__fixtures__/existing.merged.env b/test/__fixtures__/existing.merged.env index 103ea33f..cca33652 100644 --- a/test/__fixtures__/existing.merged.env +++ b/test/__fixtures__/existing.merged.env @@ -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"] diff --git a/test/__fixtures__/invalid.config.json b/test/__fixtures__/invalid.config.json index e07cf96b..7f3480a1 100644 --- a/test/__fixtures__/invalid.config.json +++ b/test/__fixtures__/invalid.config.json @@ -41,6 +41,14 @@ ] } }, + { + "id": "17561138", + "name": "Projéct C", + "integration_type": "apikey", + "oauth2": { + "client_secret": "XYXYXYXYZZZZZZ" + } + }, { "id": "17950", "name": "NewTestIntegration8", diff --git a/test/__fixtures__/valid.config.aio b/test/__fixtures__/valid.config.aio index a28ba709..8aaac8a1 100644 --- a/test/__fixtures__/valid.config.aio +++ b/test/__fixtures__/valid.config.aio @@ -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", diff --git a/test/__fixtures__/valid.config.env b/test/__fixtures__/valid.config.env index 65b39b61..b143b9fb 100644 --- a/test/__fixtures__/valid.config.env +++ b/test/__fixtures__/valid.config.env @@ -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"] diff --git a/test/__fixtures__/valid.config.json b/test/__fixtures__/valid.config.json index 9b8aa6a6..592630f1 100644 --- a/test/__fixtures__/valid.config.json +++ b/test/__fixtures__/valid.config.json @@ -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", diff --git a/test/schema.test.js b/test/schema.test.js index 7938bb2c..4435ea00 100644 --- a/test/schema.test.js +++ b/test/schema.test.js @@ -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() })