From 4e7e33c403648dfc4666037194752dd504afd6e2 Mon Sep 17 00:00:00 2001 From: Oleksandr Pravosudko Date: Tue, 30 Nov 2021 13:41:39 +0000 Subject: [PATCH] fix: set correct ancestor for DeviceAccessPolicyRuleCondition OKTA-447641 <<>> Artifact: okta-sdk-nodejs Files changed count: 10 PR Link: "https://github.com/okta/okta-sdk-nodejs/pull/293" --- CHANGELOG.md | 6 +++ package.json | 4 +- src/models/AccessPolicyRuleConditions.js | 5 +++ src/models/DeviceAccessPolicyRuleCondition.js | 6 +-- .../models/AccessPolicyRuleConditions.d.ts | 2 + .../DeviceAccessPolicyRuleCondition.d.ts | 4 +- templates/helpers/operation.js | 1 - test/it/authenticators-update.ts | 43 +++++++++++++++++++ .../access-policy-rule-condition.test-d.ts | 10 +++++ yarn.lock | 8 ++-- 10 files changed, 77 insertions(+), 12 deletions(-) create mode 100644 test/it/authenticators-update.ts create mode 100644 test/type/access-policy-rule-condition.test-d.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 9960d8e29..98b439276 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Okta Node SDK Changelog +## 6.0.1 + +### Bug Fixes + +- [#293](https://github.com/okta/okta-sdk-nodejs/pull/293) Sets correct parent class for `DeviceAccessPolicyRuleCondition` + ## 6.0.0 ### Features diff --git a/package.json b/package.json index 6f3c34423..c1624a0d8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@okta/okta-sdk-nodejs", - "version": "6.0.0", + "version": "6.0.1", "description": "Okta API wrapper for Node.js", "engines": { "node": ">=12.0" @@ -42,7 +42,7 @@ "safe-flat": "^2.0.2" }, "devDependencies": { - "@okta/openapi": "^2.9.1", + "@okta/openapi": "^2.9.2", "@types/chai": "^4.2.22", "@types/mocha": "^9.0.0", "@types/node-fetch": "^2.5.8", diff --git a/src/models/AccessPolicyRuleConditions.js b/src/models/AccessPolicyRuleConditions.js index 0703248f9..ac7eca6dc 100644 --- a/src/models/AccessPolicyRuleConditions.js +++ b/src/models/AccessPolicyRuleConditions.js @@ -14,18 +14,23 @@ /* THIS FILE IS AUTO-GENERATED - SEE CONTRIBUTOR DOCUMENTATION */ var PolicyRuleConditions = require('./PolicyRuleConditions'); +const DeviceAccessPolicyRuleCondition = require('./DeviceAccessPolicyRuleCondition'); const AccessPolicyRuleCustomCondition = require('./AccessPolicyRuleCustomCondition'); const UserTypeCondition = require('./UserTypeCondition'); /** * @class AccessPolicyRuleConditions * @extends PolicyRuleConditions + * @property { DeviceAccessPolicyRuleCondition } device * @property { AccessPolicyRuleCustomCondition } elCondition * @property { UserTypeCondition } userType */ class AccessPolicyRuleConditions extends PolicyRuleConditions { constructor(resourceJson, client) { super(resourceJson, client); + if (resourceJson && resourceJson.device) { + this.device = new DeviceAccessPolicyRuleCondition(resourceJson.device); + } if (resourceJson && resourceJson.elCondition) { this.elCondition = new AccessPolicyRuleCustomCondition(resourceJson.elCondition); } diff --git a/src/models/DeviceAccessPolicyRuleCondition.js b/src/models/DeviceAccessPolicyRuleCondition.js index 2f6f4c33c..a0c67a73d 100644 --- a/src/models/DeviceAccessPolicyRuleCondition.js +++ b/src/models/DeviceAccessPolicyRuleCondition.js @@ -13,16 +13,16 @@ /* THIS FILE IS AUTO-GENERATED - SEE CONTRIBUTOR DOCUMENTATION */ -var Resource = require('../resource'); +var DevicePolicyRuleCondition = require('./DevicePolicyRuleCondition'); /** * @class DeviceAccessPolicyRuleCondition - * @extends Resource + * @extends DevicePolicyRuleCondition * @property { boolean } managed * @property { boolean } registered */ -class DeviceAccessPolicyRuleCondition extends Resource { +class DeviceAccessPolicyRuleCondition extends DevicePolicyRuleCondition { constructor(resourceJson, client) { super(resourceJson, client); diff --git a/src/types/models/AccessPolicyRuleConditions.d.ts b/src/types/models/AccessPolicyRuleConditions.d.ts index 1a132b190..0a1b6bc8c 100644 --- a/src/types/models/AccessPolicyRuleConditions.d.ts +++ b/src/types/models/AccessPolicyRuleConditions.d.ts @@ -16,12 +16,14 @@ import { PolicyRuleConditions } from './PolicyRuleConditions'; import { Client } from '../client'; import { OptionalKnownProperties } from '../optional-known-properties-type'; +import { DeviceAccessPolicyRuleCondition } from './DeviceAccessPolicyRuleCondition'; import { AccessPolicyRuleCustomCondition } from './AccessPolicyRuleCustomCondition'; import { UserTypeCondition } from './UserTypeCondition'; declare class AccessPolicyRuleConditions extends PolicyRuleConditions { constructor(resourceJson: Record, client: Client); + device: DeviceAccessPolicyRuleCondition; elCondition: AccessPolicyRuleCustomCondition; userType: UserTypeCondition; diff --git a/src/types/models/DeviceAccessPolicyRuleCondition.d.ts b/src/types/models/DeviceAccessPolicyRuleCondition.d.ts index bb0bfc8f8..8b892c7f7 100644 --- a/src/types/models/DeviceAccessPolicyRuleCondition.d.ts +++ b/src/types/models/DeviceAccessPolicyRuleCondition.d.ts @@ -13,12 +13,12 @@ /* THIS FILE IS AUTO-GENERATED - SEE CONTRIBUTOR DOCUMENTATION */ -import { Resource } from '../resource'; +import { DevicePolicyRuleCondition } from './DevicePolicyRuleCondition'; import { Client } from '../client'; import { OptionalKnownProperties } from '../optional-known-properties-type'; -declare class DeviceAccessPolicyRuleCondition extends Resource { +declare class DeviceAccessPolicyRuleCondition extends DevicePolicyRuleCondition { constructor(resourceJson: Record, client: Client); managed: boolean; diff --git a/templates/helpers/operation.js b/templates/helpers/operation.js index 88e4cf0b8..0ed1dd52c 100644 --- a/templates/helpers/operation.js +++ b/templates/helpers/operation.js @@ -20,7 +20,6 @@ const RESTRICTED_MODEL_PROPERTY_OVERRIDES = { SwaThreeFieldApplication: ['name'], SwaApplication: ['name'], SecurePasswordStoreApplication: ['name'], - AccessPolicyRuleConditions: ['device'], }; // properties which should not be included into request payload diff --git a/test/it/authenticators-update.ts b/test/it/authenticators-update.ts new file mode 100644 index 000000000..0b3e07356 --- /dev/null +++ b/test/it/authenticators-update.ts @@ -0,0 +1,43 @@ +import * as okta from '@okta/okta-sdk-nodejs'; +import { AllowedForEnum } from '@okta/okta-sdk-nodejs'; +import { expect } from 'chai'; +import utils = require('../utils'); +let orgUrl = process.env.OKTA_CLIENT_ORGURL; + +if (process.env.OKTA_USE_MOCK) { + orgUrl = `${orgUrl}/authenticators-update`; +} + +const client = new okta.Client({ + orgUrl: orgUrl, + token: process.env.OKTA_CLIENT_TOKEN, +}); + +describe('Authenticators API tests', () => { + // do not run these tests in a non-OIE context + beforeEach(async function () { + const isOIEOrg = await utils.verifyOrgIsOIE(client); + if (!isOIEOrg) { + this.skip(); + } + }); + + it('should update Authenticator', async () => { + const { value: authenticator} = await client.listAuthenticators().next(); + + let updatedAuthenticator = await client.updateAuthenticator(authenticator.id, { + name: authenticator.name, + settings: { + allowedFor: AllowedForEnum.ANY + } + }); + expect(updatedAuthenticator.settings.allowedFor).to.equal(AllowedForEnum.ANY); + updatedAuthenticator = await client.updateAuthenticator(authenticator.id, { + name: authenticator.name, + settings: { + allowedFor: AllowedForEnum.RECOVERY + } + }); + expect(updatedAuthenticator.settings.allowedFor).to.equal(AllowedForEnum.RECOVERY); + }); +}); diff --git a/test/type/access-policy-rule-condition.test-d.ts b/test/type/access-policy-rule-condition.test-d.ts new file mode 100644 index 000000000..aa35c12b0 --- /dev/null +++ b/test/type/access-policy-rule-condition.test-d.ts @@ -0,0 +1,10 @@ +import { expectType } from 'tsd'; + +import { Client } from '../../src/types/client'; +import { AccessPolicyRuleConditions } from '../../src/types/models/AccessPolicyRuleConditions'; +import { DeviceAccessPolicyRuleCondition } from '../../src/types/models/DeviceAccessPolicyRuleCondition'; + + +const client = new Client(); +const ruleConditions = new AccessPolicyRuleConditions({}, client); +expectType(ruleConditions.device); diff --git a/yarn.lock b/yarn.lock index 32d88db02..5148864dd 100644 --- a/yarn.lock +++ b/yarn.lock @@ -549,10 +549,10 @@ "@nodelib/fs.scandir" "2.1.5" fastq "^1.6.0" -"@okta/openapi@^2.9.1": - version "2.9.1" - resolved "https://registry.yarnpkg.com/@okta/openapi/-/openapi-2.9.1.tgz#7722b9f44b4b44e96166c4e6ade5fe62414d11d7" - integrity sha512-hib3lKNFxQ+oS8ZR+eDTjSwUlGNBYMAKhcmefN3oOJJGyId+iP88r8n9VlydxZe22A0sGu9XYmWX/thG8iTv7g== +"@okta/openapi@^2.9.2": + version "2.9.2" + resolved "https://registry.yarnpkg.com/@okta/openapi/-/openapi-2.9.2.tgz#ab99800eb3d9baecbd81a10331c19f78347ab014" + integrity sha512-GhUDr7gawiGz5yGKETqReSgt6PvbKMHnFOxs4Gu/mG6tQAruJ7d42Y6ZK3JA2e0/6bBlxc7IsNfukaCVcOZALg== dependencies: commander "2.9.0" fs-extra "3.0.1"