Skip to content

Commit

Permalink
Merge pull request #30 from sangeetha5491/CI-5618
Browse files Browse the repository at this point in the history
Update registration methods to use V2 API
  • Loading branch information
sangeetha5491 authored Oct 6, 2022
2 parents 0587d1f + 6cc5908 commit c49990a
Show file tree
Hide file tree
Showing 8 changed files with 916 additions and 346 deletions.
172 changes: 149 additions & 23 deletions README.md

Large diffs are not rendered by default.

41 changes: 19 additions & 22 deletions e2e/e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ const accessToken = process.env.EVENTS_JWT_TOKEN
const consumerOrgId = process.env.EVENTS_CONSUMER_ORG_ID
const workspaceId = process.env.EVENTS_WORKSPACE_ID
const projectId = process.env.EVENTS_PROJECT_ID
const integrationId = process.env.EVENTS_INTEGRATION_ID
const httpOptions = { retries: 3 }
const randomNumber = Math.round(Math.random() * 100000)

Expand Down Expand Up @@ -77,26 +76,25 @@ test('test create event metadata', async () => {

test('test register journalling endpoint', async () => {
// create journal registration
journalReg = await sdkClient.createWebhookRegistration(consumerOrgId,
integrationId, {
name: 'Test Events SDK ' + randomNumber,
description: 'Test Events SDK ' + randomNumber,
client_id: apiKey,
delivery_type: 'JOURNAL',
events_of_interest: [
{
event_code: eventCode,
provider_id: providerId
}
]
})
expect(journalReg.status).toBe('VERIFIED')
expect(journalReg.integration_status).toBe('ENABLED')
journalReg = await sdkClient.createRegistration(consumerOrgId, projectId, workspaceId, {
name: 'Test Events SDK ' + randomNumber,
description: 'Test Events SDK ' + randomNumber,
client_id: apiKey,
delivery_type: 'journal',
events_of_interest: [
{
event_code: eventCode,
provider_id: providerId
}
]
})
expect(journalReg.webhook_status).toBe('verified')
expect(journalReg.enabled).toBe(true)
})

test('test fetch journalling position', async () => {
const journallingUrl = journalReg.events_url
logger.info('Journal endpoint has been registered')
const journallingUrl = journalReg._links['rel:events'].href
logger.info('Journal endpoint ' + journallingUrl + ' has been registered')

// sleep for one min
await sleep(60000)
Expand Down Expand Up @@ -124,7 +122,7 @@ test('test publish event', async () => {
})

test('test event received in journalling endpoint', async () => {
var count = 0
let count = 0
let nextLink = journalling.link.next
// retry to fetch from journalling 3 times ( 30 seconds )
while (count < 3 && journalling.retryAfter && journalling.events === undefined) {
Expand All @@ -141,8 +139,7 @@ test('test event received in journalling endpoint', async () => {
})

test('delete webhook registration', async () => {
await sdkClient.deleteWebhookRegistration(consumerOrgId,
integrationId, journalReg.registration_id)
await sdkClient.deleteRegistration(consumerOrgId, projectId, workspaceId, journalReg.registration_id)
journalReg = undefined
})

Expand All @@ -161,7 +158,7 @@ test('delete provider', async () => {
afterAll(async () => {
// delete webhook registration
if (journalReg) {
await sdkClient.deleteWebhookRegistration(consumerOrgId, integrationId,
await sdkClient.deleteRegistration(consumerOrgId, projectId, workspaceId,
journalReg.registration_id)
}

Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"unit-tests": "jest --config test/jest.config.js --maxWorkers=2",
"e2e": "jest --config e2e/jest.config.js",
"typings": "jsdoc -t node_modules/tsd-jsdoc/dist -r src/index.js -d .",
"generate-docs": "jsdoc2md -t ./docs/readme_template.md ./src/index.js > README.md"
"generate-docs": "npm run typings && npm run jsdoc",
"jsdoc": "jsdoc2md -t ./docs/readme_template.md ./src/index.js > README.md"
},
"dependencies": {
"@adobe/aio-lib-core-errors": "^3.1.1",
Expand Down Expand Up @@ -48,7 +49,7 @@
"jest-junit": "^10.0.0",
"jest-plugin-fs": "^2.9.0",
"jsdoc": "^3.6.7",
"jsdoc-to-markdown": "^5.0.3",
"jsdoc-to-markdown": "^7.1.1",
"openapi-schema-validator": "^3.0.3",
"querystring": "^0.2.0",
"stdout-stderr": "^0.1.13",
Expand Down
2 changes: 2 additions & 0 deletions src/SDKErrors.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,10 @@ E('ERROR_UPDATE_EVENTMETADATA', '%s')
E('ERROR_DELETE_ALL_EVENTMETADATA', '%s')
E('ERROR_DELETE_EVENTMETADATA', '%s')
E('ERROR_CREATE_REGISTRATION', '%s')
E('ERROR_UPDATE_REGISTRATION', '%s')
E('ERROR_GET_REGISTRATION', '%s')
E('ERROR_GET_ALL_REGISTRATION', '%s')
E('ERROR_GET_ALL_REGISTRATIONS_FOR_ORG', '%s')
E('ERROR_DELETE_REGISTRATION', '%s')
E('ERROR_GET_JOURNAL_DATA', '%s')
E('ERROR_PUBLISH_EVENT', '%s')
150 changes: 115 additions & 35 deletions src/index.js

Large diffs are not rendered by default.

145 changes: 94 additions & 51 deletions test/index.test.js

Large diffs are not rendered by default.

Loading

0 comments on commit c49990a

Please sign in to comment.