-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add webhook signing secrets to legacy and plain client interfac…
…es [EXT-4817] (#2029) * feat: add webhook signing secrets plain client interface * feat: add plain client methods for webhook signing secrets * test: add unit tests for webhook signing secrets * docs: add new types to exported types for docs * refactor: make upsertSigningSecret payload required * feat: add webhook signing secrets to legacy client interface * fix: docs typos
- Loading branch information
Showing
8 changed files
with
243 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { expect } from 'chai' | ||
import { describe, test } from 'mocha' | ||
import sinon from 'sinon' | ||
import { createClient } from '../../../lib/contentful-management' | ||
import setupRestAdapter from '../adapters/REST/helpers/setupRestAdapter' | ||
import crypto from 'crypto' | ||
|
||
describe('Webhook', () => { | ||
const spaceId = 'space-id' | ||
|
||
test('getSigningSecret', async () => { | ||
const { httpMock, adapterMock } = setupRestAdapter( | ||
Promise.resolve({ data: { redactedValue: 'abcd' } }) | ||
) | ||
const plainClient = createClient({ apiAdapter: adapterMock }, { type: 'plain' }) | ||
const response = await plainClient.webhook.getSigningSecret({ spaceId }) | ||
|
||
expect(response).to.be.an('object') | ||
expect(response.redactedValue).to.equal('abcd') | ||
|
||
sinon.assert.calledWith(httpMock.get, `/spaces/space-id/webhook_settings/signing_secret`) | ||
}) | ||
|
||
test('upsertSigningSecret', async () => { | ||
const { httpMock, adapterMock } = setupRestAdapter( | ||
Promise.resolve({ data: { redactedValue: 'abcd' } }) | ||
) | ||
const plainClient = createClient({ apiAdapter: adapterMock }, { type: 'plain' }) | ||
|
||
const payload = { value: crypto.randomBytes(32).toString('hex') } | ||
const response = await plainClient.webhook.upsertSigningSecret({ spaceId }, payload) | ||
|
||
expect(response).to.be.an('object') | ||
expect(response.redactedValue).to.equal('abcd') | ||
|
||
sinon.assert.calledWith( | ||
httpMock.put, | ||
`/spaces/space-id/webhook_settings/signing_secret`, | ||
payload | ||
) | ||
}) | ||
|
||
test('deleteSigningSecret', async () => { | ||
const { httpMock, adapterMock } = setupRestAdapter(Promise.resolve({ data: '' })) | ||
const plainClient = createClient({ apiAdapter: adapterMock }, { type: 'plain' }) | ||
await plainClient.webhook.deleteSigningSecret({ spaceId }) | ||
|
||
sinon.assert.calledWith(httpMock.delete, `/spaces/space-id/webhook_settings/signing_secret`) | ||
}) | ||
}) |