Skip to content

Commit

Permalink
use token issuer user for Subscription tests
Browse files Browse the repository at this point in the history
  • Loading branch information
oleksandrpravosudko-okta committed Jul 27, 2022
1 parent 4ee7ae7 commit bd14a72
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 18 deletions.
2 changes: 2 additions & 0 deletions scripts/e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ export OKTA_CLIENT_ORGURL=https://node-sdk-oie.oktapreview.com
get_vault_secret_key devex/okta-sdk-nodejs-vars api_key OKTA_CLIENT_TOKEN
export OKTA_CLIENT_CLIENTID=0oa1q34stxthm0zbJ1d7
get_vault_secret_key devex/okta-sdk-nodejs-vars private_key OKTA_CLIENT_PRIVATEKEY
get_vault_secret_key devex/okta-sdk-nodejs-vars username ORG_USER


export TEST_SUITE_TYPE="junit"
export TEST_RESULT_FILE_DIR="${REPO}/test-reports"
Expand Down
29 changes: 11 additions & 18 deletions test/it/subscription-user.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { expect } from 'chai';

import { Client, v3 } from '@okta/okta-sdk-nodejs';
import utils = require('../utils');

let orgUrl = process.env.OKTA_CLIENT_ORGURL;
const orgUser = process.env.ORG_USER;

if (process.env.OKTA_USE_MOCK) {
orgUrl = `${orgUrl}/subsctiption-user`;
Expand All @@ -15,27 +15,20 @@ const client = new Client({
});

// User Subscription API endpoints can only be queried by API Token owner
xdescribe('Subscription API', () => {
describe('Subscription API', () => {
let user;
const userOptions = {
profile: utils.getMockProfile('subscription-user'),
credentials: {
password: { value: 'Abcd1234#@' }
}
};

beforeEach(async () => {
await utils.cleanup(client, userOptions);
user = await client.createUser(userOptions);
});

afterEach(async () => {
await utils.cleanup(client, userOptions);
before(async () => {
for await (const usr of await client.listUsers({search: `profile.login eq "${orgUser}"`})) {
if (usr.profile.login === orgUser) {
user = usr;
}
}
});

it('provides method for listing user\'s notification subscriptions', async () => {
const subscriptions: v3.Subscription[] = [];
for await (const subscription of (await client.listUserSubscriptions(userOptions.profile.email))) {
for await (const subscription of (await client.listUserSubscriptions(user.id))) {
subscriptions.push(subscription);
}
expect(subscriptions).to.be.an('array').which.is.not.empty;
Expand All @@ -50,10 +43,10 @@ xdescribe('Subscription API', () => {
let response = await client.unsubscribeUserSubscriptionByNotificationType(user.id, 'OKTA_ISSUE');
expect(response).to.be.undefined;
let subscription = await client.getUserSubscriptionByNotificationType(user.id, 'OKTA_ISSUE');
expect(subscription.status).to.equal('UNSUBSCRIBED');
expect(subscription.status).to.equal('unsubscribed');
response = await client.subscribeUserSubscriptionByNotificationType(user.id, 'OKTA_ISSUE');
expect(response).to.be.undefined;
subscription = await client.getUserSubscriptionByNotificationType(user.id, 'OKTA_ISSUE');
expect(subscription.status).to.equal('SUBSCRIBED');
expect(subscription.status).to.equal('subscribed');
});
});

0 comments on commit bd14a72

Please sign in to comment.