Skip to content

Commit

Permalink
integrate Subscription API (#351)
Browse files Browse the repository at this point in the history
* use token issuer user for Subscription tests
  • Loading branch information
oleksandrpravosudko-okta authored Jul 28, 2022
1 parent ed9279d commit 4870296
Show file tree
Hide file tree
Showing 21 changed files with 1,052 additions and 162 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
2 changes: 2 additions & 0 deletions src/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const {
SessionApi,
TemplateApi,
PolicyApi,
SubscriptionApi,
} = require('./generated');
const { createConfiguration } = require('./generated/configuration');
const { ServerConfiguration } = require('./generated/servers');
Expand Down Expand Up @@ -145,6 +146,7 @@ class Client extends GeneratedApiClient {
this.sessionApi = new SessionApi(configuration);
this.templateApi = new TemplateApi(configuration);
this.policyApi = new PolicyApi(configuration);
this.subscriptionApi = new SubscriptionApi(configuration);
}
}

Expand Down
118 changes: 8 additions & 110 deletions src/generated-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@

const qs = require('querystring');

const { Collection } = require('./collection');
const models = require('./models');
const { ModelFactory } = require('./model-factory');

/**
* Auto-Generated API client, implements the operations as defined in the OpenaAPI JSON spec
Expand Down Expand Up @@ -4546,13 +4544,7 @@ class GeneratedApiClient {
if (!roleTypeOrRoleId) {
return Promise.reject(new Error('OKTA API listRoleSubscriptions parameter roleTypeOrRoleId is required.'));
}
let url = `${this.baseUrl}/api/v1/roles/${roleTypeOrRoleId}/subscriptions`;

return new Collection(
this.http,
url,
new ModelFactory(models.Subscription, this),
);
return this.subscriptionApi.listRoleSubscriptions(roleTypeOrRoleId);
}

/**
Expand All @@ -4570,19 +4562,7 @@ class GeneratedApiClient {
if (!notificationType) {
return Promise.reject(new Error('OKTA API getRoleSubscriptionByNotificationType parameter notificationType is required.'));
}
let url = `${this.baseUrl}/api/v1/roles/${roleTypeOrRoleId}/subscriptions/${notificationType}`;

const resources = [
`${this.baseUrl}/api/v1/roles/${roleTypeOrRoleId}/subscriptions/${notificationType}`,
`${this.baseUrl}/api/v1/roles/${roleTypeOrRoleId}`
];

const request = this.http.getJson(
url,
null,
{ resources }
);
return request.then(jsonRes => new models.Subscription(jsonRes, this));
return this.subscriptionApi.getRoleSubscriptionByNotificationType(roleTypeOrRoleId, notificationType);
}

/**
Expand All @@ -4599,23 +4579,7 @@ class GeneratedApiClient {
if (!notificationType) {
return Promise.reject(new Error('OKTA API subscribeRoleSubscriptionByNotificationType parameter notificationType is required.'));
}
let url = `${this.baseUrl}/api/v1/roles/${roleTypeOrRoleId}/subscriptions/${notificationType}/subscribe`;

const resources = [
`${this.baseUrl}/api/v1/roles/${roleTypeOrRoleId}/subscriptions/${notificationType}`,
`${this.baseUrl}/api/v1/roles/${roleTypeOrRoleId}`
];

const request = this.http.post(
url,
{
headers: {
'Content-Type': 'application/json', 'Accept': 'application/json',
},
},
{ resources }
);
return request;
return this.subscriptionApi.subscribeRoleSubscriptionByNotificationType(roleTypeOrRoleId, notificationType);
}

/**
Expand All @@ -4632,23 +4596,7 @@ class GeneratedApiClient {
if (!notificationType) {
return Promise.reject(new Error('OKTA API unsubscribeRoleSubscriptionByNotificationType parameter notificationType is required.'));
}
let url = `${this.baseUrl}/api/v1/roles/${roleTypeOrRoleId}/subscriptions/${notificationType}/unsubscribe`;

const resources = [
`${this.baseUrl}/api/v1/roles/${roleTypeOrRoleId}/subscriptions/${notificationType}`,
`${this.baseUrl}/api/v1/roles/${roleTypeOrRoleId}`
];

const request = this.http.post(
url,
{
headers: {
'Content-Type': 'application/json', 'Accept': 'application/json',
},
},
{ resources }
);
return request;
return this.subscriptionApi.unsubscribeRoleSubscriptionByNotificationType(roleTypeOrRoleId, notificationType);
}

/**
Expand Down Expand Up @@ -6191,13 +6139,7 @@ class GeneratedApiClient {
if (!userId) {
return Promise.reject(new Error('OKTA API listUserSubscriptions parameter userId is required.'));
}
let url = `${this.baseUrl}/api/v1/users/${userId}/subscriptions`;

return new Collection(
this.http,
url,
new ModelFactory(models.Subscription, this),
);
return this.subscriptionApi.listUserSubscriptions(userId);
}

/**
Expand All @@ -6215,19 +6157,7 @@ class GeneratedApiClient {
if (!notificationType) {
return Promise.reject(new Error('OKTA API getUserSubscriptionByNotificationType parameter notificationType is required.'));
}
let url = `${this.baseUrl}/api/v1/users/${userId}/subscriptions/${notificationType}`;

const resources = [
`${this.baseUrl}/api/v1/users/${userId}/subscriptions/${notificationType}`,
`${this.baseUrl}/api/v1/users/${userId}`
];

const request = this.http.getJson(
url,
null,
{ resources }
);
return request.then(jsonRes => new models.Subscription(jsonRes, this));
return this.subscriptionApi.getUserSubscriptionByNotificationType(userId, notificationType);
}

/**
Expand All @@ -6244,23 +6174,7 @@ class GeneratedApiClient {
if (!notificationType) {
return Promise.reject(new Error('OKTA API subscribeUserSubscriptionByNotificationType parameter notificationType is required.'));
}
let url = `${this.baseUrl}/api/v1/users/${userId}/subscriptions/${notificationType}/subscribe`;

const resources = [
`${this.baseUrl}/api/v1/users/${userId}/subscriptions/${notificationType}`,
`${this.baseUrl}/api/v1/users/${userId}`
];

const request = this.http.post(
url,
{
headers: {
'Content-Type': 'application/json', 'Accept': 'application/json',
},
},
{ resources }
);
return request;
return this.subscriptionApi.subscribeUserSubscriptionByNotificationType(userId, notificationType);
}

/**
Expand All @@ -6277,23 +6191,7 @@ class GeneratedApiClient {
if (!notificationType) {
return Promise.reject(new Error('OKTA API unsubscribeUserSubscriptionByNotificationType parameter notificationType is required.'));
}
let url = `${this.baseUrl}/api/v1/users/${userId}/subscriptions/${notificationType}/unsubscribe`;

const resources = [
`${this.baseUrl}/api/v1/users/${userId}/subscriptions/${notificationType}`,
`${this.baseUrl}/api/v1/users/${userId}`
];

const request = this.http.post(
url,
{
headers: {
'Content-Type': 'application/json', 'Accept': 'application/json',
},
},
{ resources }
);
return request;
return this.subscriptionApi.unsubscribeUserSubscriptionByNotificationType(userId, notificationType);
}

/**
Expand Down
Loading

0 comments on commit 4870296

Please sign in to comment.