-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Connector] API for adding OAuth support to ServiceNow connectors (#1…
…31084) * Adding new OAuth fields to ServiceNow ExternalIncidentServiceConfigurationBase and ExternalIncidentServiceSecretConfiguration * Creating new function in ConnectorTokenClient for updating or replacing token * Update servicenow executors to get Oauth access tokens if configured. Still need to update unit tests for services * Creating wrapper function for createService to only create one axios instance * Fixing translation check error * Adding migration for adding isOAuth to service now connectors * Fixing unit tests * Fixing functional test * Not requiring privateKeyPassword * Fixing tests * Adding functional tests for connector creation * Adding functional tests * Fixing functional test * PR feedback * Fixing test * PR feedback Co-authored-by: Kibana Machine <[email protected]>
- Loading branch information
1 parent
cf46ec9
commit 9d15ab1
Showing
33 changed files
with
2,695 additions
and
299 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,8 @@ import { createJWTAssertion } from './create_jwt_assertion'; | |
const jwtSign = jwt.sign as jest.Mock; | ||
const mockLogger = loggingSystemMock.create().get() as jest.Mocked<Logger>; | ||
|
||
Date.now = jest.fn(() => 0); | ||
|
||
describe('createJWTAssertion', () => { | ||
test('creating a JWT token from provided claims with default values', () => { | ||
jwtSign.mockReturnValueOnce('123456qwertyjwttoken'); | ||
|
@@ -27,6 +29,28 @@ describe('createJWTAssertion', () => { | |
subject: '[email protected]', | ||
}); | ||
|
||
expect(jwtSign).toHaveBeenCalledWith( | ||
{ aud: '1', exp: 3600, iat: 0, iss: 'someappid', sub: '[email protected]' }, | ||
{ key: 'test', passphrase: '123456' }, | ||
{ algorithm: 'RS256' } | ||
); | ||
expect(assertion).toMatchInlineSnapshot('"123456qwertyjwttoken"'); | ||
}); | ||
|
||
test('creating a JWT token when private key password is null', () => { | ||
jwtSign.mockReturnValueOnce('123456qwertyjwttoken'); | ||
|
||
const assertion = createJWTAssertion(mockLogger, 'test', null, { | ||
audience: '1', | ||
issuer: 'someappid', | ||
subject: '[email protected]', | ||
}); | ||
|
||
expect(jwtSign).toHaveBeenCalledWith( | ||
{ aud: '1', exp: 3600, iat: 0, iss: 'someappid', sub: '[email protected]' }, | ||
'test', | ||
{ algorithm: 'RS256' } | ||
); | ||
expect(assertion).toMatchInlineSnapshot('"123456qwertyjwttoken"'); | ||
}); | ||
|
||
|
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
Oops, something went wrong.