Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: wso2 api subscription #59

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
30 changes: 30 additions & 0 deletions lib/src/wso2/__tests__/wso2-utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { GetSecretValueCommand, SecretsManagerClient } from '@aws-sdk/client-secrets-manager';
import { mockClient } from 'aws-sdk-client-mock';
import nock from 'nock';

export const nockBasicWso2SDK = (baseWso2Url: string): void => {
const secretMock = mockClient(SecretsManagerClient);
secretMock.on(GetSecretValueCommand).resolves({
SecretBinary: Buffer.from(JSON.stringify({ user: 'user1', pwd: 'pwd1' })),
});

// register client mock
nock(baseWso2Url).post('/client-registration/v0.17/register').reply(200, {
clientId: 'clientId1',
clientSecret: 'clientSecret1',
});

// get token mock
nock(baseWso2Url).post('/oauth2/token').reply(200, {
// eslint-disable-next-line camelcase
access_token: '1111-1111-1111',
});

// mock server check
nock(baseWso2Url)
.get('/services/Version')
.reply(
200,
'<ns:getVersionResponse xmlns:ns="http://version.services.core.carbon.wso2.org"><return>WSO2 API Manager-3.2.0</return></ns:getVersionResponse>',
);
};
Loading