Skip to content

Commit

Permalink
e2e Fixes (#28)
Browse files Browse the repository at this point in the history
* Fix issue with env var name to fetch env token
* Fix e2e tests

Co-authored-by: Shazron Abdullah <shaz@adobe.com>
  • Loading branch information
sandeep-paliwal and shazron committed Jul 12, 2021
1 parent 12749f9 commit 985b0a1
Showing 1 changed file with 6 additions and 16 deletions.
22 changes: 6 additions & 16 deletions e2e/e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ let sdkClient = {}
const tenantId = process.env.CUSTOMER_PROFILE_API_TENANT_ID
const iMSOrgId = process.env.CUSTOMER_PROFILE_API_IMS_ORG_ID
const apiKey = process.env.CUSTOMER_PROFILE_API_API_KEY
const accessToken = process.env.CUSTOMER_PROFILE_ACCESS_TOKEN
const accessToken = process.env.CUSTOMER_PROFILE_API_ACCESS_TOKEN

beforeAll(async () => {
sdkClient = await sdk.init(tenantId, iMSOrgId, apiKey, accessToken)
Expand All @@ -33,7 +33,9 @@ test('sdk init test', async () => {
})

const requiredParam = {
'schema.name': '_xdm.context.profile'
'schema.name': '_xdm.context.profile',
entityId: 'spaliwal@adobe.com',
entityIdNS: 'email'
}

test('test bad access token', async () => {
Expand All @@ -49,23 +51,11 @@ test('test bad api key', async () => {
const promise = _sdkClient.getAccessEntities(requiredParam)

// just match the error message
return expect(promise).rejects.toThrow('401')
})

test('test bad tenant id', async () => {
const _sdkClient = await sdk.init('bad_tenant_id', iMSOrgId, apiKey, accessToken)
const promise = _sdkClient.getAccessEntities(requiredParam)

// just match the error message
return expect(promise).rejects.toThrow('401')
return expect(promise).rejects.toThrow('[CustomerProfileAPISDK:ERROR_ENTITIES] Error 403 - Forbidden ({"error_code":"403003","message":"Api Key is invalid"})')
})

test('test getAccessEntities API', async () => {
// check success response
const res = await sdkClient.getAccessEntities({
entityId: '1',
'schema.name': '_xdm.context.profile',
entityIdNS: '1'
})
const res = await sdkClient.getAccessEntities(requiredParam)
expect(res.ok).toBeTruthy()
})

0 comments on commit 985b0a1

Please sign in to comment.