Skip to content

Commit

Permalink
update integration tests to use library root imports
Browse files Browse the repository at this point in the history
  • Loading branch information
oleksandrpravosudko-okta committed May 4, 2021
1 parent 6ef7069 commit cbd6e3a
Show file tree
Hide file tree
Showing 47 changed files with 472 additions and 359 deletions.
3 changes: 1 addition & 2 deletions test/it/application-clone-key.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { expect } from 'chai';

import * as okta from '@okta/okta-sdk-nodejs';
import models = require('../../src/models');
import utils = require('../utils');

let orgUrl = process.env.OKTA_CLIENT_ORGURL;
Expand Down Expand Up @@ -38,7 +37,7 @@ describe.skip('Application.cloneApplicationKey()', () => {
const clonedKey = await createdApplication.cloneApplicationKey(generatedKey.kid, {
targetAid: createdApplication2.id
});
expect(clonedKey).to.be.instanceof(models.JsonWebKey);
expect(clonedKey).to.be.instanceof(okta.JsonWebKey);
expect(clonedKey.kid).to.equal(generatedKey.kid);
} finally {
if (createdApplication) {
Expand Down
3 changes: 1 addition & 2 deletions test/it/application-generate-key.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { expect } from 'chai';

import * as okta from '@okta/okta-sdk-nodejs';
import models = require('../../src/models');
import utils = require('../utils');

let orgUrl = process.env.OKTA_CLIENT_ORGURL;
Expand Down Expand Up @@ -30,7 +29,7 @@ describe.skip('Application.generateApplicationKey()', () => {
const applicationKey = await createdApplication.generateApplicationKey({
validityYears: 2
});
expect(applicationKey).to.be.instanceof(models.JsonWebKey);
expect(applicationKey).to.be.instanceof(okta.JsonWebKey);
} finally {
if (createdApplication) {
await createdApplication.deactivate();
Expand Down
18 changes: 10 additions & 8 deletions test/it/application-grant.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { expect } from 'chai';
import * as okta from '@okta/okta-sdk-nodejs';
import models = require('../../src/models');
import Collection = require('../../src/collection');
import {
Client,
Collection,
DefaultRequestExecutor,
OAuth2ScopeConsentGrant } from '@okta/okta-sdk-nodejs';
import getMockApplication = require('./mocks/application-oidc');

let orgUrl = process.env.OKTA_CLIENT_ORGURL;
Expand All @@ -10,10 +12,10 @@ if (process.env.OKTA_USE_MOCK) {
orgUrl = `${orgUrl}/application-grant`;
}

const client = new okta.Client({
const client = new Client({
orgUrl: orgUrl,
token: process.env.OKTA_CLIENT_TOKEN,
requestExecutor: new okta.DefaultRequestExecutor()
requestExecutor: new DefaultRequestExecutor()
});

describe('Application OAuth2 grant API', () => {
Expand All @@ -33,7 +35,7 @@ describe('Application OAuth2 grant API', () => {
issuer: client.baseUrl,
scopeId: 'okta.users.manage'
});
expect(grant).to.be.instanceOf(models.OAuth2ScopeConsentGrant);
expect(grant).to.be.instanceOf(OAuth2ScopeConsentGrant);
expect(grant.issuer).to.equal(client.baseUrl);
expect(grant.scopeId).to.equal('okta.users.manage');
});
Expand All @@ -56,7 +58,7 @@ describe('Application OAuth2 grant API', () => {
});
expect(grants).to.be.instanceOf(Collection);
await grants.each(grantFromCollection => {
expect(grantFromCollection).to.be.instanceOf(models.OAuth2ScopeConsentGrant);
expect(grantFromCollection).to.be.instanceOf(OAuth2ScopeConsentGrant);
expect(grantFromCollection.id).to.equal(grant.id);
});
});
Expand All @@ -76,7 +78,7 @@ describe('Application OAuth2 grant API', () => {
it('should get grant by id', async () => {
const grantFromGet = await application.getScopeConsentGrant(grant.id);
expect(grantFromGet).to.be.exist;
expect(grantFromGet).to.be.instanceOf(models.OAuth2ScopeConsentGrant);
expect(grantFromGet).to.be.instanceOf(OAuth2ScopeConsentGrant);
});
});

Expand Down
2 changes: 1 addition & 1 deletion test/it/application-token.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from 'chai';
import * as okta from '@okta/okta-sdk-nodejs';
import Collection = require('../../src/collection');
import { Collection } from '@okta/okta-sdk-nodejs';
import getMockApplication = require('./mocks/application-oidc');

let orgUrl = process.env.OKTA_CLIENT_ORGURL;
Expand Down
16 changes: 9 additions & 7 deletions test/it/authserver-claim.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { expect } from 'chai';
import * as okta from '@okta/okta-sdk-nodejs';
import models = require('../../src/models');
import Collection = require('../../src/collection');
import {
Client,
Collection,
DefaultRequestExecutor,
OAuth2Claim } from '@okta/okta-sdk-nodejs';
import getMockAuthorizationServer = require('./mocks/authorization-server');
import mockScope = require('./mocks/scope.json');
import mockClaim = require('./mocks/claim.json');
Expand All @@ -11,10 +13,10 @@ if (process.env.OKTA_USE_MOCK) {
orgUrl = `${orgUrl}/authserver-claim`;
}

const client = new okta.Client({
const client = new Client({
orgUrl: orgUrl,
token: process.env.OKTA_CLIENT_TOKEN,
requestExecutor: new okta.DefaultRequestExecutor()
requestExecutor: new DefaultRequestExecutor()
});

describe('Authorization Server Claim API', () => {
Expand Down Expand Up @@ -46,7 +48,7 @@ describe('Authorization Server Claim API', () => {
expect(claims).is.not.empty;
const claimFindByName = claims.find(c => c.name === mockClaim.name);
expect(claimFindByName).to.be.exist;
expect(claimFindByName).to.be.instanceOf(models.OAuth2Claim);
expect(claimFindByName).to.be.instanceOf(OAuth2Claim);
});
});

Expand Down Expand Up @@ -74,7 +76,7 @@ describe('Authorization Server Claim API', () => {

it('should get claim from auth server by id', async () => {
const claimFromGet = await authServer.getOAuth2Claim(claim.id);
expect(claimFromGet).to.be.instanceOf(models.OAuth2Claim);
expect(claimFromGet).to.be.instanceOf(OAuth2Claim);
expect(claimFromGet.id).to.equal(claim.id);
});
});
Expand Down
16 changes: 9 additions & 7 deletions test/it/authserver-credential.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
import { expect } from 'chai';
import * as okta from '@okta/okta-sdk-nodejs';
import Collection = require('../../src/collection');
import models = require('../../src/models');
import {
Client,
Collection,
DefaultRequestExecutor,
JsonWebKey } from '@okta/okta-sdk-nodejs';
import getMockAuthorizationServer = require('./mocks/authorization-server');
let orgUrl = process.env.OKTA_CLIENT_ORGURL;

if (process.env.OKTA_USE_MOCK) {
orgUrl = `${orgUrl}/authserver-credential`;
}

const client = new okta.Client({
const client = new Client({
orgUrl: orgUrl,
token: process.env.OKTA_CLIENT_TOKEN,
requestExecutor: new okta.DefaultRequestExecutor()
requestExecutor: new DefaultRequestExecutor()
});

describe('Authorization Server Credential API', () => {
Expand All @@ -29,7 +31,7 @@ describe('Authorization Server Credential API', () => {
const collection = await authServer.listKeys();
expect(collection).to.be.instanceOf(Collection);
await collection.each(key => {
expect(key).to.be.instanceOf(models.JsonWebKey);
expect(key).to.be.instanceOf(JsonWebKey);
});
});
});
Expand All @@ -39,7 +41,7 @@ describe('Authorization Server Credential API', () => {
const collection = await authServer.rotateKeys({ use: 'sig' });
expect(collection).to.be.instanceOf(Collection);
await collection.each(key => {
expect(key).to.be.instanceOf(models.JsonWebKey);
expect(key).to.be.instanceOf(JsonWebKey);
});
});
});
Expand Down
16 changes: 9 additions & 7 deletions test/it/authserver-crud.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
import { expect } from 'chai';
import * as okta from '@okta/okta-sdk-nodejs';
import models = require('../../src/models');
import Collection = require('../../src/collection');
import {
Client,
Collection,
DefaultRequestExecutor,
AuthorizationServer } from '@okta/okta-sdk-nodejs';
import getMockAuthorizationServer = require('./mocks/authorization-server');
let orgUrl = process.env.OKTA_CLIENT_ORGURL;

if (process.env.OKTA_USE_MOCK) {
orgUrl = `${orgUrl}/authserver-crud`;
}

const client = new okta.Client({
const client = new Client({
orgUrl: orgUrl,
token: process.env.OKTA_CLIENT_TOKEN,
requestExecutor: new okta.DefaultRequestExecutor()
requestExecutor: new DefaultRequestExecutor()
});

describe('Authorization Server Crud API', () => {
Expand All @@ -26,7 +28,7 @@ describe('Authorization Server Crud API', () => {
it('should return correct model', async () => {
const mockAuthorizationServer = getMockAuthorizationServer();
authServer = await client.createAuthorizationServer(mockAuthorizationServer);
expect(authServer).to.be.instanceOf(models.AuthorizationServer);
expect(authServer).to.be.instanceOf(AuthorizationServer);
expect(authServer.id).to.be.exist;
expect(authServer.name).to.be.equal(mockAuthorizationServer.name);
});
Expand Down Expand Up @@ -65,7 +67,7 @@ describe('Authorization Server Crud API', () => {

it('should get Authorization Server by id', async () => {
const authServerFromGet = await client.getAuthorizationServer(authServer.id);
expect(authServerFromGet).to.be.instanceOf(models.AuthorizationServer);
expect(authServerFromGet).to.be.instanceOf(AuthorizationServer);
expect(authServerFromGet.name).to.equal(authServer.name);
});
});
Expand Down
16 changes: 9 additions & 7 deletions test/it/authserver-policy.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { expect } from 'chai';
import * as okta from '@okta/okta-sdk-nodejs';
import models = require('../../src/models');
import Collection = require('../../src/collection');
import {
Client,
Collection,
DefaultRequestExecutor,
Policy } from '@okta/okta-sdk-nodejs';
import getMockAuthorizationServer = require('./mocks/authorization-server');
import getMockPolicy = require('./mocks/policy-oauth-authorization');
let orgUrl = process.env.OKTA_CLIENT_ORGURL;
Expand All @@ -10,10 +12,10 @@ if (process.env.OKTA_USE_MOCK) {
orgUrl = `${orgUrl}/authserver-policy`;
}

const client = new okta.Client({
const client = new Client({
orgUrl: orgUrl,
token: process.env.OKTA_CLIENT_TOKEN,
requestExecutor: new okta.DefaultRequestExecutor()
requestExecutor: new DefaultRequestExecutor()
});

describe('Authorization Server Policies API', () => {
Expand Down Expand Up @@ -43,7 +45,7 @@ describe('Authorization Server Policies API', () => {
expect(policies).is.not.empty;
const policyFindByName = policies.find(p => p.name === policy.name);
expect(policyFindByName).to.be.exist;
expect(policyFindByName).to.be.instanceOf(models.Policy);
expect(policyFindByName).to.be.instanceOf(Policy);
});
});

Expand Down Expand Up @@ -72,7 +74,7 @@ describe('Authorization Server Policies API', () => {

it('should get policy from auth server by id', async () => {
const policyFromGet = await authServer.getPolicy(policy.id);
expect(policyFromGet).to.be.instanceOf(models.Policy);
expect(policyFromGet).to.be.instanceOf(Policy);
expect(policyFromGet.id).to.equal(policy.id);
});
});
Expand Down
16 changes: 9 additions & 7 deletions test/it/authserver-scope.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { expect } from 'chai';
import * as okta from '@okta/okta-sdk-nodejs';
import models = require('../../src/models');
import Collection = require('../../src/collection');
import {
Client,
Collection,
DefaultRequestExecutor,
OAuth2Scope } from '@okta/okta-sdk-nodejs';
import getMockAuthorizationServer = require('./mocks/authorization-server');
import mockScope = require('./mocks/scope.json');
let orgUrl = process.env.OKTA_CLIENT_ORGURL;
Expand All @@ -10,10 +12,10 @@ if (process.env.OKTA_USE_MOCK) {
orgUrl = `${orgUrl}/authserver-scope`;
}

const client = new okta.Client({
const client = new Client({
orgUrl: orgUrl,
token: process.env.OKTA_CLIENT_TOKEN,
requestExecutor: new okta.DefaultRequestExecutor()
requestExecutor: new DefaultRequestExecutor()
});

describe('Authorization Server Scope API', () => {
Expand Down Expand Up @@ -43,7 +45,7 @@ describe('Authorization Server Scope API', () => {
expect(scopes).is.not.empty;
const scopeFindByName = scopes.find(s => s.name === mockScope.name);
expect(scopeFindByName).to.be.exist;
expect(scopeFindByName).to.be.instanceOf(models.OAuth2Scope);
expect(scopeFindByName).to.be.instanceOf(OAuth2Scope);
});
});

Expand Down Expand Up @@ -71,7 +73,7 @@ describe('Authorization Server Scope API', () => {

it('should get scope from auth server by id', async () => {
const scopeFromGet = await authServer.getOAuth2Scope(scope.id);
expect(scopeFromGet).to.be.instanceOf(models.OAuth2Scope);
expect(scopeFromGet).to.be.instanceOf(OAuth2Scope);
expect(scopeFromGet.id).to.equal(scope.id);
});
});
Expand Down
12 changes: 7 additions & 5 deletions test/it/client-assign-user-to-application.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { expect } from 'chai';

import * as okta from '@okta/okta-sdk-nodejs';
import models = require('../../src/models');
import {
Client,
DefaultRequestExecutor,
AppUser } from '@okta/okta-sdk-nodejs';
import utils = require('../utils');

let orgUrl = process.env.OKTA_CLIENT_ORGURL;
Expand All @@ -10,11 +12,11 @@ if (process.env.OKTA_USE_MOCK) {
orgUrl = `${orgUrl}/application-assign-user`;
}

const client = new okta.Client({
const client = new Client({
scopes: ['okta.clients.manage', 'okta.apps.manage', 'okta.users.manage'],
orgUrl: orgUrl,
token: process.env.OKTA_CLIENT_TOKEN,
requestExecutor: new okta.DefaultRequestExecutor()
requestExecutor: new DefaultRequestExecutor()
});

describe('client.assignUserToApplication()', () => {
Expand All @@ -41,7 +43,7 @@ describe('client.assignUserToApplication()', () => {
createdAppUser = await client.assignUserToApplication(createdApplication.id, {
id: createdUser.id
});
expect(createdAppUser).to.be.instanceof(models.AppUser);
expect(createdAppUser).to.be.instanceof(AppUser);
expect(createdAppUser._links.user.href).to.contain(createdUser.id);
} finally {
if (createdApplication) {
Expand Down
12 changes: 7 additions & 5 deletions test/it/client-clone-application-key.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { expect } from 'chai';

import * as okta from '@okta/okta-sdk-nodejs';
import models = require('../../src/models');
import {
Client,
DefaultRequestExecutor,
JsonWebKey } from '@okta/okta-sdk-nodejs';
import utils = require('../utils');

let orgUrl = process.env.OKTA_CLIENT_ORGURL;
Expand All @@ -10,11 +12,11 @@ if (process.env.OKTA_USE_MOCK) {
orgUrl = `${orgUrl}/client-clone-application-key`;
}

const client = new okta.Client({
const client = new Client({
scopes: ['okta.clients.manage', 'okta.apps.manage'],
orgUrl: orgUrl,
token: process.env.OKTA_CLIENT_TOKEN,
requestExecutor: new okta.DefaultRequestExecutor()
requestExecutor: new DefaultRequestExecutor()
});

describe.skip('client.cloneApplicationKey()', () => {
Expand Down Expand Up @@ -49,7 +51,7 @@ describe.skip('client.cloneApplicationKey()', () => {
const clonedKey = await client.cloneApplicationKey(createdApplication.id, generatedKey.kid, {
targetAid: createdApplication2.id
});
expect(clonedKey).to.be.instanceof(models.JsonWebKey);
expect(clonedKey).to.be.instanceof(JsonWebKey);
expect(clonedKey.kid).to.equal(generatedKey.kid);
} finally {
if (createdApplication) {
Expand Down
Loading

0 comments on commit cbd6e3a

Please sign in to comment.