Skip to content

Commit

Permalink
fix: ACNA-1787 - app init error - integration_type oauthsinglepageapp (
Browse files Browse the repository at this point in the history
…#577)

Co-authored-by: Shazron Abdullah <36107+shazron@users.noreply.github.com>
  • Loading branch information
amulyakashyap09 and shazron authored Sep 24, 2022
1 parent bd6cbbd commit 2225901
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 3 deletions.
24 changes: 22 additions & 2 deletions schema/config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,12 @@
]
},
"jwt": { "$ref": "#/definitions/jwt" },
"api_key": { "$ref": "#/definitions/api_key" },
"oauth2": { "$ref": "#/definitions/oauth2" }
"api_key": { "$ref": "#/definitions/api_key" }
},
"required": [ "id", "name" ],
"if": { "properties": { "integration_type": { "const": "oauthsinglepageapp" } } },
"then": { "properties": { "oauth2": { "$ref": "#/definitions/oauthsinglepageapp" } } },
"else": { "properties": { "oauth2": { "$ref": "#/definitions/oauth2" } } },
"oneOf": [
{ "required": ["oauth2"] },
{ "required": ["jwt"] },
Expand Down Expand Up @@ -174,6 +176,24 @@
},
"required": [ "client_id", "client_secret", "redirect_uri", "defaultRedirectUri" ]
},
"oauthsinglepageapp": {
"type": "object",
"properties": {
"client_id": { "type": "string" },
"defaultRedirectUri": {
"type": "string",
"format": "uri"
},
"redirect_uri": {
"type": "array",
"items": {
"type": "string",
"format": "uri"
}
}
},
"required": [ "client_id", "redirect_uri", "defaultRedirectUri" ]
},
"api_key": {
"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 @@ -41,6 +41,11 @@
"name": "Project_C",
"integration_type": "apikey"
},
{
"id": "17656570",
"name": "Project_D",
"integration_type": "oauthsinglepageapp"
},
{
"id": "17950",
"name": "New_Test_Intégration_8",
Expand Down
3 changes: 3 additions & 0 deletions test/__fixtures__/existing.merged.env
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ 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_Project__C_client__id=AKAKAKAKAKAKAKAKAKAKAKAK
AIO_ims_contexts_Project__D_client__id=KAKAKAKAKAKAKAKAKAKAKAKA
AIO_ims_contexts_Project__D_redirect__uri=["https://test123"]
AIO_ims_contexts_Project__D_defaultRedirectUri=https://test123
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
9 changes: 9 additions & 0 deletions test/__fixtures__/invalid.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@
"client_secret": "XYXYXYXYZZZZZZ"
}
},
{
"id": "17656570",
"name": "Project D",
"integration_type": "oauthsinglepageapp",
"oauth2": {
"redirect_uri": [ "https://test123" ],
"defaultRedirectUri": "https://test123"
}
},
{
"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 @@ -33,6 +33,11 @@
"name": "Project_C",
"integration_type": "apikey"
},
{
"id": "17656570",
"name": "Project_D",
"integration_type": "oauthsinglepageapp"
},
{
"id": "17950",
"name": "New_Test_Intégration_8",
Expand Down
3 changes: 3 additions & 0 deletions test/__fixtures__/valid.config.env
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ 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_Project__C_client__id=AKAKAKAKAKAKAKAKAKAKAKAK
AIO_ims_contexts_Project__D_client__id=KAKAKAKAKAKAKAKAKAKAKAKA
AIO_ims_contexts_Project__D_redirect__uri=["https://test123"]
AIO_ims_contexts_Project__D_defaultRedirectUri=https://test123
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
10 changes: 10 additions & 0 deletions test/__fixtures__/valid.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,16 @@
"client_id": "AKAKAKAKAKAKAKAKAKAKAKAK"
}
},
{
"id": "17656570",
"name": "Project D",
"integration_type": "oauthsinglepageapp",
"oauth2": {
"client_id": "KAKAKAKAKAKAKAKAKAKAKAKA",
"redirect_uri": [ "https://test123" ],
"defaultRedirectUri": "https://test123"
}
},
{
"id": "17950",
"name": "New Test Intégration 8",
Expand Down
4 changes: 3 additions & 1 deletion test/schema.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ test('validate failure', () => {
const valid = validate(fixtureJson('invalid.config.json'))
// the 4 errors are the missing name properties, techacct migration to two new properties
// the rest 3 are missing client_id and failing keyword `then`
expect(validate.errors.length).toEqual(7)
// 2 for failing if & else condition
// 1 for failing client_id required criteria
expect(validate.errors.length).toEqual(10)
expect(valid).toBeFalsy()
})

0 comments on commit 2225901

Please sign in to comment.