From 228518b2700483fcd81dd3e48b21ff6b44e001fe Mon Sep 17 00:00:00 2001 From: Hari K Arla Date: Sun, 28 Jun 2026 18:22:13 +0530 Subject: [PATCH] feat(identity): enable idp sharing Signed-off-by: Hari K Arla --- examples/iam-identity.v1.test.js | 429 +++++- iam-identity/v1.ts | 1690 ++++++++++++++++++++- test/integration/iam-identity.v1.test.js | 244 ++++ test/unit/iam-identity.v1.test.js | 1704 ++++++++++++++++++++++ 4 files changed, 4065 insertions(+), 2 deletions(-) diff --git a/examples/iam-identity.v1.test.js b/examples/iam-identity.v1.test.js index d587512a..ca3eb6d1 100644 --- a/examples/iam-identity.v1.test.js +++ b/examples/iam-identity.v1.test.js @@ -117,6 +117,9 @@ describe('IamIdentityV1', () => { let accountSettingsTemplateAssignmentEtag; let accountSettingsTemplateName = 'Node-SDK-IT-Example-AccountSettings-Template-' + now + let idpId; + let idpEtag; + test('createApiKey request example', async () => { consoleLogMock.mockImplementation(output => { @@ -763,7 +766,7 @@ test('createApiKey request example', async () => { // begin-create_profile const params = { - name: 'profileName', + name: 'Node-SDK-Example-Profile-${Date.now()}', description: 'Example Profile', accountId, }; @@ -2811,6 +2814,430 @@ test('createApiKey request example', async () => { // end-bulkListAccountEntityConsumption }); + + test('createIdp request example', async () => { + consoleLogMock.mockImplementation((output) => { + originalLog(output); + }); + consoleWarnMock.mockImplementation((output) => { + originalWarn(output); + expect(true).toBeFalsy(); + }); + + originalLog('createIdp() result:'); + // begin-createIdp + + const idpProperties = { + idp: { + entity_id: 'http://www.okta.com/abcdefg', + redirect_binding_url: 'https://trial-12345.okta.com/app/trial-6789/abcdefg/sso/saml', + want_request_signed: true, + }, + sp: { + want_assertion_signed: true, + want_response_signed: true, + encrypt_response: true, + idp_initiated_login_enabled: true, + logout_url_enabled_when_available: true, + }, + }; + + const idpSecrets = { + idp: {}, + sp: {}, + }; + + const params = { + accountId, + name: 'My Identity Provider', + type: 'saml', + active: true, + properties: idpProperties, + secrets: idpSecrets, + }; + + try { + const res = await iamIdentityService.createIdp(params); + idpId = res.result.idp_id; + console.log(JSON.stringify(res.result, null, 2)); + } catch (err) { + console.warn(err); + } + + // end-createIdp + }); + + test('listIdps request example', async () => { + consoleLogMock.mockImplementation((output) => { + originalLog(output); + }); + consoleWarnMock.mockImplementation((output) => { + originalWarn(output); + expect(true).toBeFalsy(); + }); + + originalLog('listIdps() result:'); + // begin-listIdps + + const params = { + accountId, + }; + + let res; + try { + res = await iamIdentityService.listIdps(params); + console.log(JSON.stringify(res.result, null, 2)); + } catch (err) { + console.warn(err); + } + + // end-listIdps + }); + + test('getIdp request example', async () => { + consoleLogMock.mockImplementation((output) => { + originalLog(output); + }); + consoleWarnMock.mockImplementation((output) => { + originalWarn(output); + expect(true).toBeFalsy(); + }); + + expect(idpId).toBeDefined(); + + originalLog('getIdp() result:'); + // begin-getIdp + + const params = { + idpId, + }; + + let res; + try { + res = await iamIdentityService.getIdp(params); + idpEtag = res.headers['etag']; + console.log(JSON.stringify(res.result, null, 2)); + } catch (err) { + console.warn(err); + } + + // end-getIdp + }); + + test('updateIdp request example', async () => { + consoleLogMock.mockImplementation((output) => { + originalLog(output); + }); + consoleWarnMock.mockImplementation((output) => { + originalWarn(output); + expect(true).toBeFalsy(); + }); + + expect(idpId).toBeDefined(); + expect(idpEtag).toBeDefined(); + + originalLog('updateIdp() result:'); + // begin-updateIdp + + const updatedProperties = { + idp: { + entity_id: 'http://www.okta.com/abcdefgijk', + redirect_binding_url: 'https://trial-12345.okta.com/app/trial-6789/abcdefgijk/sso/saml', + want_request_signed: false, + }, + sp: { + want_assertion_signed: false, + want_response_signed: false, + encrypt_response: true, + idp_initiated_login_enabled: false, + logout_url_enabled_when_available: true, + }, + }; + + const params = { + idpId, + ifMatch: idpEtag, + uiSetupCompleted: true, + active: true, + properties: updatedProperties, + forceShareScopeUpdate: true, + }; + + let res; + try { + res = await iamIdentityService.updateIdp(params); + console.log(JSON.stringify(res.result, null, 2)); + } catch (err) { + console.warn(err); + } + + // end-updateIdp + }); + + test('listConsumerAccounts request example', async () => { + consoleLogMock.mockImplementation((output) => { + originalLog(output); + }); + consoleWarnMock.mockImplementation((output) => { + originalWarn(output); + expect(true).toBeFalsy(); + }); + + expect(idpId).toBeDefined(); + + originalLog('listConsumerAccounts() result:'); + // begin-listConsumerAccounts + + const params = { + idpId, + }; + + let res; + try { + res = await iamIdentityService.listConsumerAccounts(params); + console.log(JSON.stringify(res.result, null, 2)); + } catch (err) { + console.warn(err); + } + + // end-listConsumerAccounts + }); + + test('getLoginSettings request example', async () => { + consoleLogMock.mockImplementation((output) => { + originalLog(output); + }); + consoleWarnMock.mockImplementation((output) => { + originalWarn(output); + expect(true).toBeFalsy(); + }); + + originalLog('getLoginSettings() result:'); + // begin-getLoginSettings + + const params = { + accountId, + }; + + let res; + try { + res = await iamIdentityService.getLoginSettings(params); + console.log(JSON.stringify(res.result, null, 2)); + } catch (err) { + console.warn(err); + } + + // end-getLoginSettings + }); + + test('updateLoginSettings request example', async () => { + consoleLogMock.mockImplementation((output) => { + originalLog(output); + }); + consoleWarnMock.mockImplementation((output) => { + originalWarn(output); + expect(true).toBeFalsy(); + }); + + originalLog('updateLoginSettings() result:'); + // begin-updateLoginSettings + + const params = { + accountId, + alias: 'my_alias_update_test', + }; + + let res; + try { + res = await iamIdentityService.updateLoginSettings(params); + console.log(JSON.stringify(res.result, null, 2)); + } catch (err) { + console.warn(err); + } + + // end-updateLoginSettings + }); + + test('listIdPSettings request example', async () => { + consoleLogMock.mockImplementation((output) => { + originalLog(output); + }); + consoleWarnMock.mockImplementation((output) => { + originalWarn(output); + expect(true).toBeFalsy(); + }); + + originalLog('listIdPSettings() result:'); + // begin-listIdPSettings + + const params = { + accountId, + type: 'consumable', + includeIdpMetadata: 'true', + }; + + let res; + try { + res = await iamIdentityService.listIdPSettings(params); + console.log(JSON.stringify(res.result, null, 2)); + } catch (err) { + console.warn(err); + } + + // end-listIdPSettings + }); + + test('addIdPSetting request example', async () => { + consoleLogMock.mockImplementation((output) => { + originalLog(output); + }); + consoleWarnMock.mockImplementation((output) => { + originalWarn(output); + expect(true).toBeFalsy(); + }); + + expect(idpId).toBeDefined(); + + originalLog('addIdPSetting() result:'); + // begin-addIdPSetting + + const params = { + accountId, + idpId, + cloudUserStrategy: 'STATIC', + active: true, + uiDefault: true, + }; + + let res; + try { + res = await iamIdentityService.addIdPSetting(params); + console.log(JSON.stringify(res.result, null, 2)); + } catch (err) { + console.warn(err); + } + + // end-addIdPSetting + }); + + test('getIdPSetting request example', async () => { + consoleLogMock.mockImplementation((output) => { + originalLog(output); + }); + consoleWarnMock.mockImplementation((output) => { + originalWarn(output); + expect(true).toBeFalsy(); + }); + + expect(idpId).toBeDefined(); + + originalLog('getIdPSetting() result:'); + // begin-getIdPSetting + + const params = { + accountId, + idpId, + }; + + let res; + try { + res = await iamIdentityService.getIdPSetting(params); + console.log(JSON.stringify(res.result, null, 2)); + } catch (err) { + console.warn(err); + } + + // end-getIdPSetting + }); + + test('updateIdPSetting request example', async () => { + consoleLogMock.mockImplementation((output) => { + originalLog(output); + }); + consoleWarnMock.mockImplementation((output) => { + originalWarn(output); + expect(true).toBeFalsy(); + }); + + expect(idpId).toBeDefined(); + + originalLog('updateIdPSetting() result:'); + // begin-updateIdPSetting + + const params = { + accountId, + idpId, + cloudUserStrategy: 'STATIC', + active: true, + uiDefault: false, + }; + + let res; + try { + res = await iamIdentityService.updateIdPSetting(params); + console.log(JSON.stringify(res.result, null, 2)); + } catch (err) { + console.warn(err); + } + + // end-updateIdPSetting + }); + + test('removeIdPSetting request example', async () => { + consoleLogMock.mockImplementation((output) => { + originalLog(output); + }); + consoleWarnMock.mockImplementation((output) => { + originalWarn(output); + expect(true).toBeFalsy(); + }); + + expect(idpId).toBeDefined(); + + // begin-removeIdPSetting + + const params = { + accountId, + idpId, + }; + + try { + await iamIdentityService.removeIdPSetting(params); + } catch (err) { + console.warn(err); + } + + // end-removeIdPSetting + }); + + test('deleteIdp request example', async () => { + consoleLogMock.mockImplementation((output) => { + originalLog(output); + }); + consoleWarnMock.mockImplementation((output) => { + originalWarn(output); + expect(true).toBeFalsy(); + }); + + expect(idpId).toBeDefined(); + + // begin-deleteIdp + + const params = { + idpId, + }; + + try { + await iamIdentityService.deleteIdp(params); + idpId = undefined; + } catch (err) { + console.warn(err); + } + + // end-deleteIdp + }); + + function isFinishedEx(status) { return ("succeeded" === status.toLowerCase() || "failed" === status.toLowerCase()); } diff --git a/iam-identity/v1.ts b/iam-identity/v1.ts index a496fec0..c28ee0d1 100644 --- a/iam-identity/v1.ts +++ b/iam-identity/v1.ts @@ -15,7 +15,7 @@ */ /** - * IBM OpenAPI SDK Code Generator Version: 3.113.1-d76630af-20260320-135953 + * IBM OpenAPI SDK Code Generator Version: 3.113.0-3f9df07a-20260317-160650 */ import * as extend from 'extend'; @@ -5985,6 +5985,1023 @@ class IamIdentityV1 extends BaseService { }), }; + return this.createRequest(parameters); + } + /************************* + * iDPManagement + ************************/ + + /** + * List IdPs. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.accountId - Account id to query. + * @param {string} [params.includeHistory] - include history of the idp. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public listIdps( + params: IamIdentityV1.ListIdpsParams + ): Promise> { + const _params = { ...params }; + const _requiredParams = ['accountId']; + const _validParams = ['accountId', 'includeHistory', 'signal', 'headers']; + const _validationErrors = validateParams(_params, _requiredParams, _validParams); + if (_validationErrors) { + return Promise.reject(_validationErrors); + } + + const query = { + 'account_id': _params.accountId, + 'include_history': _params.includeHistory, + }; + + const sdkHeaders = getSdkHeaders(IamIdentityV1.DEFAULT_SERVICE_NAME, 'v1', 'listIdps'); + + const parameters = { + options: { + url: '/v1/idps/', + method: 'GET', + qs: query, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend( + true, + sdkHeaders, + this.baseOptions.headers, + { + 'Accept': 'application/json', + }, + _params.headers + ), + axiosOptions: { + signal: _params.signal, + }, + }), + }; + + return this.createRequest(parameters); + } + + /** + * Create IdP. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.accountId - Account where the IdP resides in. + * @param {string} params.name - Speaking name of the Identity Provider. + * @param {string} params.type - Type of the IDP. + * @param {boolean} [params.active] - Defines if the IDP is active (enabled) for all accounts (including those who + * consumed the IdP). Default during creation is true. + * @param {CreateIdpRequestProperties} [params.properties] - Properties of the IDP. Will be stored plain-text. + * @param {CreateIdpRequestSecrets} [params.secrets] - Secrets of the IDP. Will be stored encrypted. + * @param {ShareScope[]} [params.shareScope] - List of targets which can consume the IdP. + * @param {string} [params.automation] - boolean to flag if IdP is created via automation. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public createIdp( + params: IamIdentityV1.CreateIdpParams + ): Promise> { + const _params = { ...params }; + const _requiredParams = ['accountId', 'name', 'type']; + const _validParams = [ + 'accountId', + 'name', + 'type', + 'active', + 'properties', + 'secrets', + 'shareScope', + 'automation', + 'signal', + 'headers', + ]; + const _validationErrors = validateParams(_params, _requiredParams, _validParams); + if (_validationErrors) { + return Promise.reject(_validationErrors); + } + + const body = { + 'account_id': _params.accountId, + 'name': _params.name, + 'type': _params.type, + 'active': _params.active, + 'properties': _params.properties, + 'secrets': _params.secrets, + 'share_scope': _params.shareScope, + }; + + const query = { + 'automation': _params.automation, + }; + + const sdkHeaders = getSdkHeaders(IamIdentityV1.DEFAULT_SERVICE_NAME, 'v1', 'createIdp'); + + const parameters = { + options: { + url: '/v1/idps/', + method: 'POST', + body, + qs: query, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend( + true, + sdkHeaders, + this.baseOptions.headers, + { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + }, + _params.headers + ), + axiosOptions: { + signal: _params.signal, + }, + }), + }; + + return this.createRequest(parameters); + } + + /** + * Get IdP. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.idpId - ID of the IDP. + * @param {string} [params.includeHistory] - include history of the idp. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public getIdp( + params: IamIdentityV1.GetIdpParams + ): Promise> { + const _params = { ...params }; + const _requiredParams = ['idpId']; + const _validParams = ['idpId', 'includeHistory', 'signal', 'headers']; + const _validationErrors = validateParams(_params, _requiredParams, _validParams); + if (_validationErrors) { + return Promise.reject(_validationErrors); + } + + const query = { + 'include_history': _params.includeHistory, + }; + + const path = { + 'idp_id': _params.idpId, + }; + + const sdkHeaders = getSdkHeaders(IamIdentityV1.DEFAULT_SERVICE_NAME, 'v1', 'getIdp'); + + const parameters = { + options: { + url: '/v1/idps/{idp_id}', + method: 'GET', + qs: query, + path, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend( + true, + sdkHeaders, + this.baseOptions.headers, + { + 'Accept': 'application/json', + }, + _params.headers + ), + axiosOptions: { + signal: _params.signal, + }, + }), + }; + + return this.createRequest(parameters); + } + + /** + * Update IdP. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.idpId - ID of the IDP. + * @param {string} params.ifMatch - Version of the account IdP settings to be updated. Specify the version that you + * retrieved as entity_tag (ETag header) when reading the account. This value helps identifying parallel usage of this + * API. Pass * to indicate to update any version available. This might result in stale updates. + * @param {boolean} [params.uiSetupCompleted] - Defines if the IDP setup was finished in the UI. + * @param {string} [params.name] - Speaking name of the Identity Provider. + * @param {boolean} [params.active] - Defines if the IDP is active (enabled) for all accounts (including those who + * consumed the IdP). + * @param {UpdateIdPRequestProperties} [params.properties] - Properties of the IDP. Will be stored plain-text. + * @param {UpdateIdPRequestSecrets} [params.secrets] - Secrets of the IDP. Will be stored encrypted. + * @param {ShareScope[]} [params.shareScope] - List of targets which can consume the IdP. + * @param {boolean} [params.forceShareScopeUpdate] - Enforces sharescope update even if active consumers are removed + * from the share scope. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public updateIdp( + params: IamIdentityV1.UpdateIdpParams + ): Promise> { + const _params = { ...params }; + const _requiredParams = ['idpId', 'ifMatch']; + const _validParams = [ + 'idpId', + 'ifMatch', + 'uiSetupCompleted', + 'name', + 'active', + 'properties', + 'secrets', + 'shareScope', + 'forceShareScopeUpdate', + 'signal', + 'headers', + ]; + const _validationErrors = validateParams(_params, _requiredParams, _validParams); + if (_validationErrors) { + return Promise.reject(_validationErrors); + } + + const body = { + 'ui_setup_completed': _params.uiSetupCompleted, + 'name': _params.name, + 'active': _params.active, + 'properties': _params.properties, + 'secrets': _params.secrets, + 'share_scope': _params.shareScope, + }; + + const query = { + 'force_share_scope_update': _params.forceShareScopeUpdate, + }; + + const path = { + 'idp_id': _params.idpId, + }; + + const sdkHeaders = getSdkHeaders(IamIdentityV1.DEFAULT_SERVICE_NAME, 'v1', 'updateIdp'); + + const parameters = { + options: { + url: '/v1/idps/{idp_id}', + method: 'PUT', + body, + qs: query, + path, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend( + true, + sdkHeaders, + this.baseOptions.headers, + { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + 'If-Match': _params.ifMatch, + }, + _params.headers + ), + axiosOptions: { + signal: _params.signal, + }, + }), + }; + + return this.createRequest(parameters); + } + + /** + * Delete IdP. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.idpId - ID of the IDP. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public deleteIdp( + params: IamIdentityV1.DeleteIdpParams + ): Promise> { + const _params = { ...params }; + const _requiredParams = ['idpId']; + const _validParams = ['idpId', 'signal', 'headers']; + const _validationErrors = validateParams(_params, _requiredParams, _validParams); + if (_validationErrors) { + return Promise.reject(_validationErrors); + } + + const path = { + 'idp_id': _params.idpId, + }; + + const sdkHeaders = getSdkHeaders(IamIdentityV1.DEFAULT_SERVICE_NAME, 'v1', 'deleteIdp'); + + const parameters = { + options: { + url: '/v1/idps/{idp_id}', + method: 'DELETE', + path, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend(true, sdkHeaders, this.baseOptions.headers, {}, _params.headers), + axiosOptions: { + signal: _params.signal, + }, + }), + }; + + return this.createRequest(parameters); + } + + /** + * Get consumers of IdP. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.idpId - ID of the IDP. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public listConsumerAccounts( + params: IamIdentityV1.ListConsumerAccountsParams + ): Promise> { + const _params = { ...params }; + const _requiredParams = ['idpId']; + const _validParams = ['idpId', 'signal', 'headers']; + const _validationErrors = validateParams(_params, _requiredParams, _validParams); + if (_validationErrors) { + return Promise.reject(_validationErrors); + } + + const path = { + 'idp_id': _params.idpId, + }; + + const sdkHeaders = getSdkHeaders( + IamIdentityV1.DEFAULT_SERVICE_NAME, + 'v1', + 'listConsumerAccounts' + ); + + const parameters = { + options: { + url: '/v1/idps/{idp_id}/consumers', + method: 'GET', + path, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend( + true, + sdkHeaders, + this.baseOptions.headers, + { + 'Accept': 'application/json', + }, + _params.headers + ), + axiosOptions: { + signal: _params.signal, + }, + }), + }; + + return this.createRequest(parameters); + } + + /** + * Export SAML IdP metadata. + * + * Returns the Service Provider (SP) SAML metadata document for the specified Identity Provider. + * + * The generated metadata contains the SP entity ID, signing certificate, supported NameID formats, and Assertion + * Consumer Service endpoints derived from the Identity Provider configuration. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.idpId - ID of the IDP. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public exportSamlMetadata( + params: IamIdentityV1.ExportSamlMetadataParams + ): Promise> { + const _params = { ...params }; + const _requiredParams = ['idpId']; + const _validParams = ['idpId', 'signal', 'headers']; + const _validationErrors = validateParams(_params, _requiredParams, _validParams); + if (_validationErrors) { + return Promise.reject(_validationErrors); + } + + const path = { + 'idp_id': _params.idpId, + }; + + const sdkHeaders = getSdkHeaders( + IamIdentityV1.DEFAULT_SERVICE_NAME, + 'v1', + 'exportSamlMetadata' + ); + + const parameters = { + options: { + url: '/v1/idps/{idp_id}/saml/metadata', + method: 'GET', + path, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend( + true, + sdkHeaders, + this.baseOptions.headers, + { + 'Accept': 'text/xml', + }, + _params.headers + ), + axiosOptions: { + signal: _params.signal, + }, + }), + }; + + return this.createRequest(parameters); + } + + /** + * Import SAML IdP metadata. + * + * Import a metadata.xml originating from the federated SAML Identity Provider. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.idpId - ID of the IDP. + * @param {NodeJS.ReadableStream | Buffer | string} params.body - + * @param {boolean} [params.parseOnly] - If true, validates and parses the metadata without updating the Identity + * Provider. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public importSamlIdpMetadata( + params: IamIdentityV1.ImportSamlIdpMetadataParams + ): Promise> { + const _params = { ...params }; + const _requiredParams = ['idpId', 'body']; + const _validParams = ['idpId', 'body', 'parseOnly', 'signal', 'headers']; + const _validationErrors = validateParams(_params, _requiredParams, _validParams); + if (_validationErrors) { + return Promise.reject(_validationErrors); + } + + const { body } = _params; + const query = { + 'parse_only': _params.parseOnly, + }; + + const path = { + 'idp_id': _params.idpId, + }; + + const sdkHeaders = getSdkHeaders( + IamIdentityV1.DEFAULT_SERVICE_NAME, + 'v1', + 'importSamlIdpMetadata' + ); + + const parameters = { + options: { + url: '/v1/idps/{idp_id}/saml/metadata', + method: 'PUT', + body, + qs: query, + path, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend( + true, + sdkHeaders, + this.baseOptions.headers, + { + 'Accept': 'application/json', + 'Content-Type': 'text/xml', + }, + _params.headers + ), + axiosOptions: { + signal: _params.signal, + }, + }), + }; + + return this.createRequest(parameters); + } + + /** + * Get IdP test results. + * + * Get IDP test record. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.idpId - ID of the IDP. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public getIdpTestResult( + params: IamIdentityV1.GetIdpTestResultParams + ): Promise> { + const _params = { ...params }; + const _requiredParams = ['idpId']; + const _validParams = ['idpId', 'signal', 'headers']; + const _validationErrors = validateParams(_params, _requiredParams, _validParams); + if (_validationErrors) { + return Promise.reject(_validationErrors); + } + + const path = { + 'idp_id': _params.idpId, + }; + + const sdkHeaders = getSdkHeaders(IamIdentityV1.DEFAULT_SERVICE_NAME, 'v1', 'getIdpTestResult'); + + const parameters = { + options: { + url: '/v1/idps/{idp_id}/test', + method: 'GET', + path, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend( + true, + sdkHeaders, + this.baseOptions.headers, + { + 'Accept': 'application/json', + }, + _params.headers + ), + axiosOptions: { + signal: _params.signal, + }, + }), + }; + + return this.createRequest(parameters); + } + + /** + * Trigger IdP configuration test. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.idpId - ID of the IDP. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public testIdp( + params: IamIdentityV1.TestIdpParams + ): Promise> { + const _params = { ...params }; + const _requiredParams = ['idpId']; + const _validParams = ['idpId', 'signal', 'headers']; + const _validationErrors = validateParams(_params, _requiredParams, _validParams); + if (_validationErrors) { + return Promise.reject(_validationErrors); + } + + const path = { + 'idp_id': _params.idpId, + }; + + const sdkHeaders = getSdkHeaders(IamIdentityV1.DEFAULT_SERVICE_NAME, 'v1', 'testIdp'); + + const parameters = { + options: { + url: '/v1/idps/{idp_id}/test', + method: 'POST', + path, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend( + true, + sdkHeaders, + this.baseOptions.headers, + { + 'Accept': 'application/json', + }, + _params.headers + ), + axiosOptions: { + signal: _params.signal, + }, + }), + }; + + return this.createRequest(parameters); + } + /************************* + * accountSettingsForIdP + ************************/ + + /** + * Get account login settings. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.accountId - Account which is bound to the alias. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public getLoginSettings( + params: IamIdentityV1.GetLoginSettingsParams + ): Promise> { + const _params = { ...params }; + const _requiredParams = ['accountId']; + const _validParams = ['accountId', 'signal', 'headers']; + const _validationErrors = validateParams(_params, _requiredParams, _validParams); + if (_validationErrors) { + return Promise.reject(_validationErrors); + } + + const path = { + 'account_id': _params.accountId, + }; + + const sdkHeaders = getSdkHeaders(IamIdentityV1.DEFAULT_SERVICE_NAME, 'v1', 'getLoginSettings'); + + const parameters = { + options: { + url: '/v2/loginsettings/{account_id}', + method: 'GET', + path, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend( + true, + sdkHeaders, + this.baseOptions.headers, + { + 'Accept': 'application/json', + }, + _params.headers + ), + axiosOptions: { + signal: _params.signal, + }, + }), + }; + + return this.createRequest(parameters); + } + + /** + * Update account login settings. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.accountId - Account which is bound to the alias. + * @param {string} [params.alias] - Alias of the account. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public updateLoginSettings( + params: IamIdentityV1.UpdateLoginSettingsParams + ): Promise> { + const _params = { ...params }; + const _requiredParams = ['accountId']; + const _validParams = ['accountId', 'alias', 'signal', 'headers']; + const _validationErrors = validateParams(_params, _requiredParams, _validParams); + if (_validationErrors) { + return Promise.reject(_validationErrors); + } + + const body = { + 'alias': _params.alias, + }; + + const path = { + 'account_id': _params.accountId, + }; + + const sdkHeaders = getSdkHeaders( + IamIdentityV1.DEFAULT_SERVICE_NAME, + 'v1', + 'updateLoginSettings' + ); + + const parameters = { + options: { + url: '/v2/loginsettings/{account_id}', + method: 'PUT', + body, + path, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend( + true, + sdkHeaders, + this.baseOptions.headers, + { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + }, + _params.headers + ), + axiosOptions: { + signal: _params.signal, + }, + }), + }; + + return this.createRequest(parameters); + } + + /** + * List IdP Settings. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.accountId - Account which is bound to the IDP. + * @param {string} params.type - Type of IDP. + * @param {string} [params.includeIdpMetadata] - Flag if meta-information about account and idp should be included. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public listIdPSettings( + params: IamIdentityV1.ListIdPSettingsParams + ): Promise> { + const _params = { ...params }; + const _requiredParams = ['accountId', 'type']; + const _validParams = ['accountId', 'type', 'includeIdpMetadata', 'signal', 'headers']; + const _validationErrors = validateParams(_params, _requiredParams, _validParams); + if (_validationErrors) { + return Promise.reject(_validationErrors); + } + + const query = { + 'type': _params.type, + 'include_idp_metadata': _params.includeIdpMetadata, + }; + + const path = { + 'account_id': _params.accountId, + }; + + const sdkHeaders = getSdkHeaders(IamIdentityV1.DEFAULT_SERVICE_NAME, 'v1', 'listIdPSettings'); + + const parameters = { + options: { + url: '/v2/loginsettings/{account_id}/idps', + method: 'GET', + qs: query, + path, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend( + true, + sdkHeaders, + this.baseOptions.headers, + { + 'Accept': 'application/json', + }, + _params.headers + ), + axiosOptions: { + signal: _params.signal, + }, + }), + }; + + return this.createRequest(parameters); + } + + /** + * Get IdP setting. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.accountId - Account which is bound to the IDP. + * @param {string} params.idpId - Identity provider ID. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public getIdPSetting( + params: IamIdentityV1.GetIdPSettingParams + ): Promise> { + const _params = { ...params }; + const _requiredParams = ['accountId', 'idpId']; + const _validParams = ['accountId', 'idpId', 'signal', 'headers']; + const _validationErrors = validateParams(_params, _requiredParams, _validParams); + if (_validationErrors) { + return Promise.reject(_validationErrors); + } + + const path = { + 'account_id': _params.accountId, + 'idp_id': _params.idpId, + }; + + const sdkHeaders = getSdkHeaders(IamIdentityV1.DEFAULT_SERVICE_NAME, 'v1', 'getIdPSetting'); + + const parameters = { + options: { + url: '/v2/loginsettings/{account_id}/idps/{idp_id}', + method: 'GET', + path, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend( + true, + sdkHeaders, + this.baseOptions.headers, + { + 'Accept': 'application/json', + }, + _params.headers + ), + axiosOptions: { + signal: _params.signal, + }, + }), + }; + + return this.createRequest(parameters); + } + + /** + * Add IdP Setting. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.accountId - Account which is bound to the IDP. + * @param {string} params.idpId - Identity provider ID. + * @param {string} params.cloudUserStrategy - Strategy how Cloud User representives for the IdP users are handled. + * @param {boolean} params.active - Specifies if the IdP is enabled for usage in the given account context. + * @param {boolean} params.uiDefault - Specifies if the IdP is used as default in the given account context. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public addIdPSetting( + params: IamIdentityV1.AddIdPSettingParams + ): Promise> { + const _params = { ...params }; + const _requiredParams = ['accountId', 'idpId', 'cloudUserStrategy', 'active', 'uiDefault']; + const _validParams = [ + 'accountId', + 'idpId', + 'cloudUserStrategy', + 'active', + 'uiDefault', + 'signal', + 'headers', + ]; + const _validationErrors = validateParams(_params, _requiredParams, _validParams); + if (_validationErrors) { + return Promise.reject(_validationErrors); + } + + const body = { + 'cloud_user_strategy': _params.cloudUserStrategy, + 'active': _params.active, + 'ui_default': _params.uiDefault, + }; + + const path = { + 'account_id': _params.accountId, + 'idp_id': _params.idpId, + }; + + const sdkHeaders = getSdkHeaders(IamIdentityV1.DEFAULT_SERVICE_NAME, 'v1', 'addIdPSetting'); + + const parameters = { + options: { + url: '/v2/loginsettings/{account_id}/idps/{idp_id}', + method: 'POST', + body, + path, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend( + true, + sdkHeaders, + this.baseOptions.headers, + { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + }, + _params.headers + ), + axiosOptions: { + signal: _params.signal, + }, + }), + }; + + return this.createRequest(parameters); + } + + /** + * Update IdP Setting. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.accountId - Account which is bound to the IDP. + * @param {string} params.idpId - Identity provider ID. + * @param {string} [params.cloudUserStrategy] - Strategy how Cloud User representives for the IdP users are handled. + * @param {boolean} [params.active] - Specifies if the IdP is enabled for usage in the given account context. + * @param {boolean} [params.uiDefault] - Specifies if the IdP is used as default in the given account context. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public updateIdPSetting( + params: IamIdentityV1.UpdateIdPSettingParams + ): Promise> { + const _params = { ...params }; + const _requiredParams = ['accountId', 'idpId']; + const _validParams = [ + 'accountId', + 'idpId', + 'cloudUserStrategy', + 'active', + 'uiDefault', + 'signal', + 'headers', + ]; + const _validationErrors = validateParams(_params, _requiredParams, _validParams); + if (_validationErrors) { + return Promise.reject(_validationErrors); + } + + const body = { + 'cloud_user_strategy': _params.cloudUserStrategy, + 'active': _params.active, + 'ui_default': _params.uiDefault, + }; + + const path = { + 'account_id': _params.accountId, + 'idp_id': _params.idpId, + }; + + const sdkHeaders = getSdkHeaders(IamIdentityV1.DEFAULT_SERVICE_NAME, 'v1', 'updateIdPSetting'); + + const parameters = { + options: { + url: '/v2/loginsettings/{account_id}/idps/{idp_id}', + method: 'PUT', + body, + path, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend( + true, + sdkHeaders, + this.baseOptions.headers, + { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + }, + _params.headers + ), + axiosOptions: { + signal: _params.signal, + }, + }), + }; + + return this.createRequest(parameters); + } + + /** + * Remove IdP Setting. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.accountId - Account which is bound to the IDP. + * @param {string} params.idpId - Identity provider ID. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public removeIdPSetting( + params: IamIdentityV1.RemoveIdPSettingParams + ): Promise> { + const _params = { ...params }; + const _requiredParams = ['accountId', 'idpId']; + const _validParams = ['accountId', 'idpId', 'signal', 'headers']; + const _validationErrors = validateParams(_params, _requiredParams, _validParams); + if (_validationErrors) { + return Promise.reject(_validationErrors); + } + + const path = { + 'account_id': _params.accountId, + 'idp_id': _params.idpId, + }; + + const sdkHeaders = getSdkHeaders(IamIdentityV1.DEFAULT_SERVICE_NAME, 'v1', 'removeIdPSetting'); + + const parameters = { + options: { + url: '/v2/loginsettings/{account_id}/idps/{idp_id}', + method: 'DELETE', + path, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend(true, sdkHeaders, this.baseOptions.headers, {}, _params.headers), + axiosOptions: { + signal: _params.signal, + }, + }), + }; + return this.createRequest(parameters); } } @@ -7484,6 +8501,215 @@ namespace IamIdentityV1 { crRulesPerProfile?: string[]; } + /** Parameters for the `listIdps` operation. */ + export interface ListIdpsParams extends DefaultParams { + /** Account id to query. */ + accountId: string; + /** include history of the idp. */ + includeHistory?: string; + } + + /** Parameters for the `createIdp` operation. */ + export interface CreateIdpParams extends DefaultParams { + /** Account where the IdP resides in. */ + accountId: string; + /** Speaking name of the Identity Provider. */ + name: string; + /** Type of the IDP. */ + type: CreateIdpConstants.Type | string; + /** Defines if the IDP is active (enabled) for all accounts (including those who consumed the IdP). Default + * during creation is true. + */ + active?: boolean; + /** Properties of the IDP. Will be stored plain-text. */ + properties?: CreateIdpRequestProperties; + /** Secrets of the IDP. Will be stored encrypted. */ + secrets?: CreateIdpRequestSecrets; + /** List of targets which can consume the IdP. */ + shareScope?: ShareScope[]; + /** boolean to flag if IdP is created via automation. */ + automation?: string; + } + + /** Constants for the `createIdp` operation. */ + export namespace CreateIdpConstants { + /** Type of the IDP. */ + export enum Type { + LDAP = 'ldap', + APPID = 'appid', + SAML = 'saml', + } + } + + /** Parameters for the `getIdp` operation. */ + export interface GetIdpParams extends DefaultParams { + /** ID of the IDP. */ + idpId: string; + /** include history of the idp. */ + includeHistory?: string; + } + + /** Parameters for the `updateIdp` operation. */ + export interface UpdateIdpParams extends DefaultParams { + /** ID of the IDP. */ + idpId: string; + /** Version of the account IdP settings to be updated. Specify the version that you retrieved as entity_tag + * (ETag header) when reading the account. This value helps identifying parallel usage of this API. Pass * to + * indicate to update any version available. This might result in stale updates. + */ + ifMatch: string; + /** Defines if the IDP setup was finished in the UI. */ + uiSetupCompleted?: boolean; + /** Speaking name of the Identity Provider. */ + name?: string; + /** Defines if the IDP is active (enabled) for all accounts (including those who consumed the IdP). */ + active?: boolean; + /** Properties of the IDP. Will be stored plain-text. */ + properties?: UpdateIdPRequestProperties; + /** Secrets of the IDP. Will be stored encrypted. */ + secrets?: UpdateIdPRequestSecrets; + /** List of targets which can consume the IdP. */ + shareScope?: ShareScope[]; + /** Enforces sharescope update even if active consumers are removed from the share scope. */ + forceShareScopeUpdate?: boolean; + } + + /** Parameters for the `deleteIdp` operation. */ + export interface DeleteIdpParams extends DefaultParams { + /** ID of the IDP. */ + idpId: string; + } + + /** Parameters for the `listConsumerAccounts` operation. */ + export interface ListConsumerAccountsParams extends DefaultParams { + /** ID of the IDP. */ + idpId: string; + } + + /** Parameters for the `exportSamlMetadata` operation. */ + export interface ExportSamlMetadataParams extends DefaultParams { + /** ID of the IDP. */ + idpId: string; + } + + /** Parameters for the `importSamlIdpMetadata` operation. */ + export interface ImportSamlIdpMetadataParams extends DefaultParams { + /** ID of the IDP. */ + idpId: string; + body: NodeJS.ReadableStream | Buffer | string; + /** If true, validates and parses the metadata without updating the Identity Provider. */ + parseOnly?: boolean; + } + + /** Parameters for the `getIdpTestResult` operation. */ + export interface GetIdpTestResultParams extends DefaultParams { + /** ID of the IDP. */ + idpId: string; + } + + /** Parameters for the `testIdp` operation. */ + export interface TestIdpParams extends DefaultParams { + /** ID of the IDP. */ + idpId: string; + } + + /** Parameters for the `getLoginSettings` operation. */ + export interface GetLoginSettingsParams extends DefaultParams { + /** Account which is bound to the alias. */ + accountId: string; + } + + /** Parameters for the `updateLoginSettings` operation. */ + export interface UpdateLoginSettingsParams extends DefaultParams { + /** Account which is bound to the alias. */ + accountId: string; + /** Alias of the account. */ + alias?: string; + } + + /** Parameters for the `listIdPSettings` operation. */ + export interface ListIdPSettingsParams extends DefaultParams { + /** Account which is bound to the IDP. */ + accountId: string; + /** Type of IDP. */ + type: ListIdPSettingsConstants.Type | string; + /** Flag if meta-information about account and idp should be included. */ + includeIdpMetadata?: string; + } + + /** Constants for the `listIdPSettings` operation. */ + export namespace ListIdPSettingsConstants { + /** Type of IDP. */ + export enum Type { + CONSUMABLE = 'consumable', + CONSUMED = 'consumed', + } + } + + /** Parameters for the `getIdPSetting` operation. */ + export interface GetIdPSettingParams extends DefaultParams { + /** Account which is bound to the IDP. */ + accountId: string; + /** Identity provider ID. */ + idpId: string; + } + + /** Parameters for the `addIdPSetting` operation. */ + export interface AddIdPSettingParams extends DefaultParams { + /** Account which is bound to the IDP. */ + accountId: string; + /** Identity provider ID. */ + idpId: string; + /** Strategy how Cloud User representives for the IdP users are handled. */ + cloudUserStrategy: AddIdPSettingConstants.CloudUserStrategy | string; + /** Specifies if the IdP is enabled for usage in the given account context. */ + active: boolean; + /** Specifies if the IdP is used as default in the given account context. */ + uiDefault: boolean; + } + + /** Constants for the `addIdPSetting` operation. */ + export namespace AddIdPSettingConstants { + /** Strategy how Cloud User representives for the IdP users are handled. */ + export enum CloudUserStrategy { + STATIC = 'STATIC', + DYNAMIC = 'DYNAMIC', + NEVER = 'NEVER', + } + } + + /** Parameters for the `updateIdPSetting` operation. */ + export interface UpdateIdPSettingParams extends DefaultParams { + /** Account which is bound to the IDP. */ + accountId: string; + /** Identity provider ID. */ + idpId: string; + /** Strategy how Cloud User representives for the IdP users are handled. */ + cloudUserStrategy?: UpdateIdPSettingConstants.CloudUserStrategy | string; + /** Specifies if the IdP is enabled for usage in the given account context. */ + active?: boolean; + /** Specifies if the IdP is used as default in the given account context. */ + uiDefault?: boolean; + } + + /** Constants for the `updateIdPSetting` operation. */ + export namespace UpdateIdPSettingConstants { + /** Strategy how Cloud User representives for the IdP users are handled. */ + export enum CloudUserStrategy { + STATIC = 'STATIC', + DYNAMIC = 'DYNAMIC', + NEVER = 'NEVER', + } + } + + /** Parameters for the `removeIdPSetting` operation. */ + export interface RemoveIdPSettingParams extends DefaultParams { + /** Account which is bound to the IDP. */ + accountId: string; + /** Identity provider ID. */ + idpId: string; + } + /************************* * model interfaces ************************/ @@ -7509,6 +8735,37 @@ namespace IamIdentityV1 { complies: boolean; } + /** + * AccountIdpSettings. + */ + export interface AccountIdpSettings { + idp_id?: string; + owner_account?: string; + owner_account_name?: string; + idp_name?: string; + idp_type?: string; + cloud_user_strategy?: AccountIdpSettings.Constants.CloudUserStrategy | string; + active?: boolean; + ui_default?: boolean; + } + export namespace AccountIdpSettings { + export namespace Constants { + /** CloudUserStrategy */ + export enum CloudUserStrategy { + STATIC = 'STATIC', + DYNAMIC = 'DYNAMIC', + NEVER = 'NEVER', + } + } + } + + /** + * AccountLoginSettings. + */ + export interface AccountLoginSettings { + alias?: string; + } + /** * Input body parameters for the Account Settings REST request. */ @@ -8165,6 +9422,171 @@ namespace IamIdentityV1 { restrictions?: AccountSettingsUserDomainRestriction[]; } + /** + * ConsumersResponse. + */ + export interface ConsumersResponse { + idp_id?: string; + consumers?: ConsumersResponseConsumersItem[]; + } + + /** + * ConsumersResponseConsumersItem. + */ + export interface ConsumersResponseConsumersItem { + account_id?: string; + share_scope?: ShareScope[]; + } + + /** + * Properties of the IDP. Will be stored plain-text. + */ + export interface CreateIdpRequestProperties { + /** Identity Provider configuration. */ + idp?: CreateIdpRequestPropertiesIdp; + /** Service Provider configuration. */ + sp?: CreateIdpRequestPropertiesSp; + } + + /** + * Identity Provider configuration. + */ + export interface CreateIdpRequestPropertiesIdp { + /** Flag indicating if IdP should be imported from metadata.xml. */ + xml_import?: boolean; + /** SAML IDP entity ID (required when not using xml_import). */ + entity_id?: string; + /** Redirect binding URL (required when not using xml_import). */ + redirect_binding_url?: string; + /** Indicates if IDP wants requests to be signed. */ + want_request_signed?: boolean; + /** SAML IDP logout URL (optional). */ + logout_url?: string; + } + + /** + * Service Provider configuration. + */ + export interface CreateIdpRequestPropertiesSp { + /** Indicates if SP wants assertions to be signed. */ + want_assertion_signed?: boolean; + /** Indicates if SP wants responses to be signed. */ + want_response_signed?: boolean; + /** Indicates if responses should be encrypted. */ + encrypt_response?: boolean; + /** Enables IDP-initiated login. */ + idp_initiated_login_enabled?: boolean; + /** Enables logout URL when available. */ + logout_url_enabled_when_available?: boolean; + /** URLs for IDP-initiated login (only when IdP initiated login is used). */ + idp_initiated_urls?: string[]; + /** Authentication context configuration (can be left empty to apply default). */ + authn_context?: CreateIdpRequestPropertiesSpAuthnContext; + /** Custom mapping between SAML assertions and IAM claims (can be left empty when no custom mapping is needed). */ + claims?: JsonObject; + } + + /** + * Authentication context configuration (can be left empty to apply default). + */ + export interface CreateIdpRequestPropertiesSpAuthnContext { + /** Requested authentication context classes. */ + request?: string[]; + /** Accepted authentication context classes. */ + accept?: string[]; + } + + /** + * Secrets of the IDP. Will be stored encrypted. + */ + export interface CreateIdpRequestSecrets { + /** Identity Provider secrets. */ + idp?: CreateIdpRequestSecretsIdp; + /** Service Provider secrets (can be left empty to auto-generate SP certs). */ + sp?: CreateIdpRequestSecretsSp; + } + + /** + * Identity Provider secrets. + */ + export interface CreateIdpRequestSecretsIdp { + /** Flag indicating if secrets should be imported from metadata.xml. */ + xml_import?: boolean; + /** IDP signing certificates (required when not using xml_import). */ + signing?: CreateIdpRequestSecretsIdpSigningItem[]; + /** IDP encrypting certificates (optional). */ + encrypting?: CreateIdpRequestSecretsIdpEncryptingItem[]; + } + + /** + * CreateIdpRequestSecretsIdpEncryptingItem. + */ + export interface CreateIdpRequestSecretsIdpEncryptingItem { + /** Certificate value. */ + value?: string; + /** Certificate type. */ + type?: CreateIdpRequestSecretsIdpEncryptingItem.Constants.Type | string; + } + export namespace CreateIdpRequestSecretsIdpEncryptingItem { + export namespace Constants { + /** Certificate type. */ + export enum Type { + PRIMARY = 'primary', + SECONDARY = 'secondary', + } + } + } + + /** + * CreateIdpRequestSecretsIdpSigningItem. + */ + export interface CreateIdpRequestSecretsIdpSigningItem { + /** Certificate value in PEM format. */ + value?: string; + /** Certificate type. */ + type?: CreateIdpRequestSecretsIdpSigningItem.Constants.Type | string; + } + export namespace CreateIdpRequestSecretsIdpSigningItem { + export namespace Constants { + /** Certificate type. */ + export enum Type { + PRIMARY = 'primary', + SECONDARY = 'secondary', + } + } + } + + /** + * Service Provider secrets (can be left empty to auto-generate SP certs). + */ + export interface CreateIdpRequestSecretsSp { + /** SP signing certificates. */ + signing?: CreateIdpRequestSecretsSpSigningItem[]; + } + + /** + * CreateIdpRequestSecretsSpSigningItem. + */ + export interface CreateIdpRequestSecretsSpSigningItem { + /** Certificate value in PEM format. */ + certificate_value?: string; + /** Private key value. */ + key_value?: string; + /** Key encoding format (e.g., pkcs8). */ + key_encoding?: string; + /** Certificate type. */ + type?: CreateIdpRequestSecretsSpSigningItem.Constants.Type | string; + } + export namespace CreateIdpRequestSecretsSpSigningItem { + export namespace Constants { + /** Certificate type. */ + export enum Type { + PRIMARY = 'primary', + SECONDARY = 'secondary', + } + } + } + /** * Link details. */ @@ -8486,6 +9908,23 @@ namespace IamIdentityV1 { preferences: IdentityPreferenceResponse[]; } + /** + * Idp. + */ + export interface Idp { + idp_id?: string; + entity_tag?: string; + account_id?: string; + name?: string; + type?: string; + properties?: JsonObject; + secrets?: JsonObject; + share_scope?: ShareScope[]; + active?: boolean; + created_at?: string; + modified_at?: string; + } + /** * Limit and current usage count for a resource. */ @@ -8496,6 +9935,20 @@ namespace IamIdentityV1 { count?: number; } + /** + * ListIdPSettingsResponse. + */ + export interface ListIdPSettingsResponse { + idps?: AccountIdpSettings[]; + } + + /** + * ListIdpsResponse. + */ + export interface ListIdpsResponse { + idps?: Idp[]; + } + /** * MfaEnrollmentTypeStatus. */ @@ -8779,6 +10232,49 @@ namespace IamIdentityV1 { cluster_name?: string; } + /** + * SamlMetadataImportResponse. + */ + export interface SamlMetadataImportResponse { + /** Realm ID of the Identity Provider. */ + idp_id: string; + /** Version information used for optimistic locking. */ + entity_tag: string; + /** Creation timestamp. */ + created_at: string; + /** Last modification timestamp. */ + modified_at: string; + /** Account that owns the Identity Provider. */ + account_id: string; + /** User-friendly name of the Identity Provider. */ + name: string; + type: SamlMetadataImportResponse.Constants.Type | string; + /** Type-specific Identity Provider configuration. */ + properties: JsonObject; + /** Type-specific secret configuration. */ + secrets: JsonObject; + /** History entries for the Identity Provider. */ + history?: JsonObject[]; + /** Accounts, enterprises, or account groups allowed to consume the IdP. */ + share_scope?: ShareScope[]; + /** Indicates whether the Identity Provider is enabled. If disabled, the IdP cannot be used by the owner account + * or any consumer accounts. + */ + active: boolean; + /** Internal flag used by the UI to determine whether the Identity Provider should be opened in the setup wizard + * or the edit dialog. + */ + ui_setup_completed?: boolean; + } + export namespace SamlMetadataImportResponse { + export namespace Constants { + /** Type */ + export enum Type { + SAML = 'saml', + } + } + } + /** * Response body format for service ID V1 REST requests. */ @@ -8892,6 +10388,23 @@ namespace IamIdentityV1 { serviceids: ServiceId[]; } + /** + * ShareScope. + */ + export interface ShareScope { + id?: string; + type?: ShareScope.Constants.Type | string; + } + export namespace ShareScope { + export namespace Constants { + /** Type */ + export enum Type { + ACCOUNT = 'account', + ENTERPRISE = 'enterprise', + } + } + } + /** * Input body parameters for the Account Settings REST request. */ @@ -9184,6 +10697,36 @@ namespace IamIdentityV1 { identities?: ProfileIdentityResponse[]; } + /** + * TestResult. + */ + export interface TestResult { + idp_id?: string; + entity_tag?: string; + started_at?: number; + modified_at?: string; + idp_version?: string; + steps?: TestResultStepsItem[]; + } + + /** + * TestResultStepsItem. + */ + export interface TestResultStepsItem { + sequence?: number; + name?: string; + state?: string; + result?: string; + } + + /** + * TestTriggerResponse. + */ + export interface TestTriggerResponse { + result?: string; + test_url?: string; + } + /** * Response body format for trusted profile V1 REST requests. */ @@ -9348,6 +10891,151 @@ namespace IamIdentityV1 { profiles: TrustedProfile[]; } + /** + * Properties of the IDP. Will be stored plain-text. + */ + export interface UpdateIdPRequestProperties { + /** Identity Provider configuration. */ + idp?: UpdateIdPRequestPropertiesIdp; + /** Service Provider configuration. */ + sp?: UpdateIdPRequestPropertiesSp; + } + + /** + * Identity Provider configuration. + */ + export interface UpdateIdPRequestPropertiesIdp { + /** SAML IDP entity ID. */ + entity_id?: string; + /** Redirect binding URL. */ + redirect_binding_url?: string; + /** Indicates if IDP wants requests to be signed. */ + want_request_signed?: boolean; + /** SAML IDP logout URL (optional). */ + logout_url?: string; + } + + /** + * Service Provider configuration. + */ + export interface UpdateIdPRequestPropertiesSp { + /** Indicates if SP wants assertions to be signed. */ + want_assertion_signed?: boolean; + /** Indicates if SP wants responses to be signed. */ + want_response_signed?: boolean; + /** Indicates if responses should be encrypted. */ + encrypt_response?: boolean; + /** Enables IDP-initiated login. */ + idp_initiated_login_enabled?: boolean; + /** Enables logout URL when available. */ + logout_url_enabled_when_available?: boolean; + /** URLs for IDP-initiated login. */ + idp_initiated_urls?: string[]; + /** Authentication context configuration. */ + authn_context?: UpdateIdPRequestPropertiesSpAuthnContext; + /** Custom mapping between SAML assertions and IAM claims. */ + claims?: JsonObject; + } + + /** + * Authentication context configuration. + */ + export interface UpdateIdPRequestPropertiesSpAuthnContext { + /** Requested authentication context classes. */ + request?: string[]; + /** Accepted authentication context classes. */ + accept?: string[]; + } + + /** + * Secrets of the IDP. Will be stored encrypted. + */ + export interface UpdateIdPRequestSecrets { + /** Identity Provider secrets. */ + idp?: UpdateIdPRequestSecretsIdp; + /** Service Provider secrets. */ + sp?: UpdateIdPRequestSecretsSp; + } + + /** + * Identity Provider secrets. + */ + export interface UpdateIdPRequestSecretsIdp { + /** IDP signing certificates. */ + signing?: UpdateIdPRequestSecretsIdpSigningItem[]; + /** IDP encrypting certificates. */ + encrypting?: UpdateIdPRequestSecretsIdpEncryptingItem[]; + } + + /** + * UpdateIdPRequestSecretsIdpEncryptingItem. + */ + export interface UpdateIdPRequestSecretsIdpEncryptingItem { + /** Certificate value. */ + value?: string; + /** Certificate type. */ + type?: UpdateIdPRequestSecretsIdpEncryptingItem.Constants.Type | string; + } + export namespace UpdateIdPRequestSecretsIdpEncryptingItem { + export namespace Constants { + /** Certificate type. */ + export enum Type { + PRIMARY = 'primary', + SECONDARY = 'secondary', + } + } + } + + /** + * UpdateIdPRequestSecretsIdpSigningItem. + */ + export interface UpdateIdPRequestSecretsIdpSigningItem { + /** Certificate value in PEM format. */ + value?: string; + /** Certificate type. */ + type?: UpdateIdPRequestSecretsIdpSigningItem.Constants.Type | string; + } + export namespace UpdateIdPRequestSecretsIdpSigningItem { + export namespace Constants { + /** Certificate type. */ + export enum Type { + PRIMARY = 'primary', + SECONDARY = 'secondary', + } + } + } + + /** + * Service Provider secrets. + */ + export interface UpdateIdPRequestSecretsSp { + /** SP signing certificates. */ + signing?: UpdateIdPRequestSecretsSpSigningItem[]; + } + + /** + * UpdateIdPRequestSecretsSpSigningItem. + */ + export interface UpdateIdPRequestSecretsSpSigningItem { + /** Certificate value in PEM format. */ + certificate_value?: string; + /** Private key value. */ + key_value?: string; + /** Key encoding format (e.g., pkcs8). */ + key_encoding?: string; + /** Certificate type. */ + type?: UpdateIdPRequestSecretsSpSigningItem.Constants.Type | string; + } + export namespace UpdateIdPRequestSecretsSpSigningItem { + export namespace Constants { + /** Certificate type. */ + export enum Type { + PRIMARY = 'primary', + SECONDARY = 'secondary', + } + } + } + /** * UserActivity. */ diff --git a/test/integration/iam-identity.v1.test.js b/test/integration/iam-identity.v1.test.js index 81816c12..5dc1882c 100644 --- a/test/integration/iam-identity.v1.test.js +++ b/test/integration/iam-identity.v1.test.js @@ -94,6 +94,9 @@ let accountSettingsTemplateAssignmentId; let accountSettingsTemplateAssignmentEtag; let accountSettingsTemplateScenarioComplete = false; +let idpId; +let idpEtag; + describe('IamIdentityV1_integration', () => { jest.setTimeout(timeout); @@ -2637,6 +2640,229 @@ describe('IamIdentityV1_integration', () => { expect(res.result).toBeDefined(); }); + // IDP (Identity Provider) tests + + test('createIdp()', async () => { + const idpProperties = { + idp: { + entity_id: 'http://www.okta.com/abcdefg', + redirect_binding_url: 'https://trial-12345.okta.com/app/trial-6789/abcdefg/sso/saml', + want_request_signed: true, + }, + sp: { + want_assertion_signed: true, + want_response_signed: true, + encrypt_response: true, + idp_initiated_login_enabled: true, + logout_url_enabled_when_available: true, + }, + }; + + const idpSecrets = { + idp: {}, + sp: {}, + }; + + const params = { + accountId, + name: 'My Identity Provider', + type: 'saml', + active: true, + properties: idpProperties, + secrets: idpSecrets, + }; + + const res = await iamIdentityService.createIdp(params); + expect(res).not.toBeNull(); + expect(res.status).toEqual(201); + expect(res.result).toBeDefined(); + idpId = res.result.idp_id; + expect(idpId).toBeDefined(); + }); + + test('listIdps()', async () => { + const params = { + accountId, + }; + + const res = await iamIdentityService.listIdps(params); + expect(res).not.toBeNull(); + expect(res.status).toEqual(200); + expect(res.result).toBeDefined(); + }); + + test('getIdp()', async () => { + expect(idpId).toBeDefined(); + + const params = { + idpId, + }; + + const res = await iamIdentityService.getIdp(params); + expect(res).not.toBeNull(); + expect(res.status).toEqual(200); + expect(res.result).toBeDefined(); + idpEtag = res.headers.etag;; + expect(idpEtag).toBeDefined(); + }); + + test('updateIdp()', async () => { + expect(idpId).toBeDefined(); + expect(idpEtag).toBeDefined(); + + const updatedProperties = { + idp: { + entity_id: 'http://www.okta.com/abcdefgijk', + redirect_binding_url: 'https://trial-12345.okta.com/app/trial-6789/abcdefgijk/sso/saml', + want_request_signed: false, + }, + sp: { + want_assertion_signed: false, + want_response_signed: false, + encrypt_response: true, + idp_initiated_login_enabled: false, + logout_url_enabled_when_available: true, + }, + }; + + const params = { + idpId, + ifMatch: idpEtag, + uiSetupCompleted: true, + active: true, + properties: updatedProperties, + forceShareScopeUpdate: true, + }; + + const res = await iamIdentityService.updateIdp(params); + expect(res).not.toBeNull(); + expect(res.status).toEqual(200); + expect(res.result).toBeDefined(); + }); + + test('listConsumerAccounts()', async () => { + expect(idpId).toBeDefined(); + + const params = { + idpId, + }; + + const res = await iamIdentityService.listConsumerAccounts(params); + expect(res).not.toBeNull(); + expect(res.status).toEqual(200); + expect(res.result).toBeDefined(); + }); + + test('getLoginSettings()', async () => { + const params = { + accountId, + }; + + const res = await iamIdentityService.getLoginSettings(params); + expect(res).not.toBeNull(); + expect(res.status).toEqual(200); + expect(res.result).toBeDefined(); + }); + + test('updateLoginSettings()', async () => { + const params = { + accountId, + alias: 'my_alias_update_test', + }; + + const res = await iamIdentityService.updateLoginSettings(params); + expect(res).not.toBeNull(); + expect(res.status).toEqual(200); + expect(res.result).toBeDefined(); + }); + + test('listIdPSettings()', async () => { + const params = { + accountId, + type: 'consumable', + includeIdpMetadata: 'true', + }; + + const res = await iamIdentityService.listIdPSettings(params); + expect(res).not.toBeNull(); + expect(res.status).toEqual(200); + expect(res.result).toBeDefined(); + }); + + test('addIdPSetting()', async () => { + expect(idpId).toBeDefined(); + + const params = { + accountId, + idpId, + cloudUserStrategy: 'STATIC', + active: true, + uiDefault: true, + }; + + const res = await iamIdentityService.addIdPSetting(params); + expect(res).not.toBeNull(); + expect(res.status).toEqual(200); + expect(res.result).toBeDefined(); + }); + + test('getIdPSetting()', async () => { + expect(idpId).toBeDefined(); + + const params = { + accountId, + idpId, + }; + + const res = await iamIdentityService.getIdPSetting(params); + expect(res).not.toBeNull(); + expect(res.status).toEqual(200); + expect(res.result).toBeDefined(); + }); + + test('updateIdPSetting()', async () => { + expect(idpId).toBeDefined(); + + const params = { + accountId, + idpId, + cloudUserStrategy: 'STATIC', + active: true, + uiDefault: false, + }; + + const res = await iamIdentityService.updateIdPSetting(params); + expect(res).not.toBeNull(); + expect(res.status).toEqual(200); + expect(res.result).toBeDefined(); + }); + + test('removeIdPSetting()', async () => { + expect(idpId).toBeDefined(); + + const params = { + accountId, + idpId, + }; + + const res = await iamIdentityService.removeIdPSetting(params); + expect(res).not.toBeNull(); + expect(res.status).toEqual(204); + }); + + test('deleteIdp()', async () => { + expect(idpId).toBeDefined(); + + const params = { + idpId, + }; + + const res = await iamIdentityService.deleteIdp(params); + expect(res).not.toBeNull(); + expect(res.status).toEqual(204); + idpId = undefined; + }); + function getPageTokenFromURL(urlstring) { let pageToken = null; if (urlstring) { @@ -2945,6 +3171,24 @@ describe('IamIdentityV1_integration', () => { } } + // clean up any IdPs created during testing + const listIdpsParams = { + accountId, + }; + const listIdpsResponse = await iamIdentityService.listIdps(listIdpsParams); + const listIdpsResult = listIdpsResponse.result; + if (listIdpsResult.idps) { + for (const elem of listIdpsResult.idps) { + if (elem.name === 'My Identity Provider') { + console.log('Cleaning IdP: ', elem.idp_id); + const deleteIdpParams = { + idpId: elem.idp_id, + }; + await iamIdentityService.deleteIdp(deleteIdpParams); + } + } + } + console.log('Finished cleaning resources!'); } catch (err) { console.log(err); diff --git a/test/unit/iam-identity.v1.test.js b/test/unit/iam-identity.v1.test.js index 50fc0510..56269f54 100644 --- a/test/unit/iam-identity.v1.test.js +++ b/test/unit/iam-identity.v1.test.js @@ -8468,4 +8468,1708 @@ describe('IamIdentityV1', () => { }); }); }); + + describe('listIdps', () => { + describe('positive tests', () => { + function __listIdpsTest() { + // Construct the params object for operation listIdps + const accountId = 'testString'; + const includeHistory = 'testString'; + const listIdpsParams = { + accountId, + includeHistory, + }; + + const listIdpsResult = iamIdentityService.listIdps(listIdpsParams); + + // all methods should return a Promise + expectToBePromise(listIdpsResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const mockRequestOptions = getOptions(createRequestMock); + + checkUrlAndMethod(mockRequestOptions, '/v1/idps/', 'GET'); + const expectedAccept = 'application/json'; + const expectedContentType = undefined; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(mockRequestOptions.qs.account_id).toEqual(accountId); + expect(mockRequestOptions.qs.include_history).toEqual(includeHistory); + } + + test('should pass the right params to createRequest with enable and disable retries', () => { + // baseline test + __listIdpsTest(); + + // enable retries and test again + createRequestMock.mockClear(); + iamIdentityService.enableRetries(); + __listIdpsTest(); + + // disable retries and test again + createRequestMock.mockClear(); + iamIdentityService.disableRetries(); + __listIdpsTest(); + }); + + test('should prioritize user-given headers', () => { + // parameters + const accountId = 'testString'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const listIdpsParams = { + accountId, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + iamIdentityService.listIdps(listIdpsParams); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async () => { + let err; + try { + await iamIdentityService.listIdps({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + + test('should reject promise when required params are not given', async () => { + let err; + try { + await iamIdentityService.listIdps(); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + }); + }); + + describe('createIdp', () => { + describe('positive tests', () => { + // Request models needed by this operation. + + // CreateIdpRequestPropertiesIdp + const createIdpRequestPropertiesIdpModel = { + xml_import: true, + entity_id: 'testString', + redirect_binding_url: 'testString', + want_request_signed: true, + logout_url: 'testString', + }; + + // CreateIdpRequestPropertiesSpAuthnContext + const createIdpRequestPropertiesSpAuthnContextModel = { + request: ['testString'], + accept: ['testString'], + }; + + // CreateIdpRequestPropertiesSp + const createIdpRequestPropertiesSpModel = { + want_assertion_signed: true, + want_response_signed: true, + encrypt_response: true, + idp_initiated_login_enabled: true, + logout_url_enabled_when_available: true, + idp_initiated_urls: ['testString'], + authn_context: createIdpRequestPropertiesSpAuthnContextModel, + claims: { 'key1': 'testString' }, + }; + + // CreateIdpRequestProperties + const createIdpRequestPropertiesModel = { + idp: createIdpRequestPropertiesIdpModel, + sp: createIdpRequestPropertiesSpModel, + }; + + // CreateIdpRequestSecretsIdpSigningItem + const createIdpRequestSecretsIdpSigningItemModel = { + value: 'testString', + type: 'primary', + }; + + // CreateIdpRequestSecretsIdpEncryptingItem + const createIdpRequestSecretsIdpEncryptingItemModel = { + value: 'testString', + type: 'primary', + }; + + // CreateIdpRequestSecretsIdp + const createIdpRequestSecretsIdpModel = { + xml_import: true, + signing: [createIdpRequestSecretsIdpSigningItemModel], + encrypting: [createIdpRequestSecretsIdpEncryptingItemModel], + }; + + // CreateIdpRequestSecretsSpSigningItem + const createIdpRequestSecretsSpSigningItemModel = { + certificate_value: 'testString', + key_value: 'testString', + key_encoding: 'testString', + type: 'primary', + }; + + // CreateIdpRequestSecretsSp + const createIdpRequestSecretsSpModel = { + signing: [createIdpRequestSecretsSpSigningItemModel], + }; + + // CreateIdpRequestSecrets + const createIdpRequestSecretsModel = { + idp: createIdpRequestSecretsIdpModel, + sp: createIdpRequestSecretsSpModel, + }; + + // ShareScope + const shareScopeModel = { + id: 'testString', + type: 'account', + }; + + function __createIdpTest() { + // Construct the params object for operation createIdp + const accountId = 'testString'; + const name = 'testString'; + const type = 'ldap'; + const active = true; + const properties = createIdpRequestPropertiesModel; + const secrets = createIdpRequestSecretsModel; + const shareScope = [shareScopeModel]; + const automation = 'testString'; + const createIdpParams = { + accountId, + name, + type, + active, + properties, + secrets, + shareScope, + automation, + }; + + const createIdpResult = iamIdentityService.createIdp(createIdpParams); + + // all methods should return a Promise + expectToBePromise(createIdpResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const mockRequestOptions = getOptions(createRequestMock); + + checkUrlAndMethod(mockRequestOptions, '/v1/idps/', 'POST'); + const expectedAccept = 'application/json'; + const expectedContentType = 'application/json'; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(mockRequestOptions.body.account_id).toEqual(accountId); + expect(mockRequestOptions.body.name).toEqual(name); + expect(mockRequestOptions.body.type).toEqual(type); + expect(mockRequestOptions.body.active).toEqual(active); + expect(mockRequestOptions.body.properties).toEqual(properties); + expect(mockRequestOptions.body.secrets).toEqual(secrets); + expect(mockRequestOptions.body.share_scope).toEqual(shareScope); + expect(mockRequestOptions.qs.automation).toEqual(automation); + } + + test('should pass the right params to createRequest with enable and disable retries', () => { + // baseline test + __createIdpTest(); + + // enable retries and test again + createRequestMock.mockClear(); + iamIdentityService.enableRetries(); + __createIdpTest(); + + // disable retries and test again + createRequestMock.mockClear(); + iamIdentityService.disableRetries(); + __createIdpTest(); + }); + + test('should prioritize user-given headers', () => { + // parameters + const accountId = 'testString'; + const name = 'testString'; + const type = 'ldap'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const createIdpParams = { + accountId, + name, + type, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + iamIdentityService.createIdp(createIdpParams); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async () => { + let err; + try { + await iamIdentityService.createIdp({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + + test('should reject promise when required params are not given', async () => { + let err; + try { + await iamIdentityService.createIdp(); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + }); + }); + + describe('getIdp', () => { + describe('positive tests', () => { + function __getIdpTest() { + // Construct the params object for operation getIdp + const idpId = 'testString'; + const includeHistory = 'testString'; + const getIdpParams = { + idpId, + includeHistory, + }; + + const getIdpResult = iamIdentityService.getIdp(getIdpParams); + + // all methods should return a Promise + expectToBePromise(getIdpResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const mockRequestOptions = getOptions(createRequestMock); + + checkUrlAndMethod(mockRequestOptions, '/v1/idps/{idp_id}', 'GET'); + const expectedAccept = 'application/json'; + const expectedContentType = undefined; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(mockRequestOptions.qs.include_history).toEqual(includeHistory); + expect(mockRequestOptions.path.idp_id).toEqual(idpId); + } + + test('should pass the right params to createRequest with enable and disable retries', () => { + // baseline test + __getIdpTest(); + + // enable retries and test again + createRequestMock.mockClear(); + iamIdentityService.enableRetries(); + __getIdpTest(); + + // disable retries and test again + createRequestMock.mockClear(); + iamIdentityService.disableRetries(); + __getIdpTest(); + }); + + test('should prioritize user-given headers', () => { + // parameters + const idpId = 'testString'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const getIdpParams = { + idpId, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + iamIdentityService.getIdp(getIdpParams); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async () => { + let err; + try { + await iamIdentityService.getIdp({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + + test('should reject promise when required params are not given', async () => { + let err; + try { + await iamIdentityService.getIdp(); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + }); + }); + + describe('updateIdp', () => { + describe('positive tests', () => { + // Request models needed by this operation. + + // UpdateIdPRequestPropertiesIdp + const updateIdPRequestPropertiesIdpModel = { + entity_id: 'testString', + redirect_binding_url: 'testString', + want_request_signed: true, + logout_url: 'testString', + }; + + // UpdateIdPRequestPropertiesSpAuthnContext + const updateIdPRequestPropertiesSpAuthnContextModel = { + request: ['testString'], + accept: ['testString'], + }; + + // UpdateIdPRequestPropertiesSp + const updateIdPRequestPropertiesSpModel = { + want_assertion_signed: true, + want_response_signed: true, + encrypt_response: true, + idp_initiated_login_enabled: true, + logout_url_enabled_when_available: true, + idp_initiated_urls: ['testString'], + authn_context: updateIdPRequestPropertiesSpAuthnContextModel, + claims: { 'key1': 'testString' }, + }; + + // UpdateIdPRequestProperties + const updateIdPRequestPropertiesModel = { + idp: updateIdPRequestPropertiesIdpModel, + sp: updateIdPRequestPropertiesSpModel, + }; + + // UpdateIdPRequestSecretsIdpSigningItem + const updateIdPRequestSecretsIdpSigningItemModel = { + value: 'testString', + type: 'primary', + }; + + // UpdateIdPRequestSecretsIdpEncryptingItem + const updateIdPRequestSecretsIdpEncryptingItemModel = { + value: 'testString', + type: 'primary', + }; + + // UpdateIdPRequestSecretsIdp + const updateIdPRequestSecretsIdpModel = { + signing: [updateIdPRequestSecretsIdpSigningItemModel], + encrypting: [updateIdPRequestSecretsIdpEncryptingItemModel], + }; + + // UpdateIdPRequestSecretsSpSigningItem + const updateIdPRequestSecretsSpSigningItemModel = { + certificate_value: 'testString', + key_value: 'testString', + key_encoding: 'testString', + type: 'primary', + }; + + // UpdateIdPRequestSecretsSp + const updateIdPRequestSecretsSpModel = { + signing: [updateIdPRequestSecretsSpSigningItemModel], + }; + + // UpdateIdPRequestSecrets + const updateIdPRequestSecretsModel = { + idp: updateIdPRequestSecretsIdpModel, + sp: updateIdPRequestSecretsSpModel, + }; + + // ShareScope + const shareScopeModel = { + id: 'testString', + type: 'account', + }; + + function __updateIdpTest() { + // Construct the params object for operation updateIdp + const idpId = 'testString'; + const ifMatch = 'testString'; + const uiSetupCompleted = true; + const name = 'testString'; + const active = true; + const properties = updateIdPRequestPropertiesModel; + const secrets = updateIdPRequestSecretsModel; + const shareScope = [shareScopeModel]; + const forceShareScopeUpdate = true; + const updateIdpParams = { + idpId, + ifMatch, + uiSetupCompleted, + name, + active, + properties, + secrets, + shareScope, + forceShareScopeUpdate, + }; + + const updateIdpResult = iamIdentityService.updateIdp(updateIdpParams); + + // all methods should return a Promise + expectToBePromise(updateIdpResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const mockRequestOptions = getOptions(createRequestMock); + + checkUrlAndMethod(mockRequestOptions, '/v1/idps/{idp_id}', 'PUT'); + const expectedAccept = 'application/json'; + const expectedContentType = 'application/json'; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + checkUserHeader(createRequestMock, 'If-Match', ifMatch); + expect(mockRequestOptions.body.ui_setup_completed).toEqual(uiSetupCompleted); + expect(mockRequestOptions.body.name).toEqual(name); + expect(mockRequestOptions.body.active).toEqual(active); + expect(mockRequestOptions.body.properties).toEqual(properties); + expect(mockRequestOptions.body.secrets).toEqual(secrets); + expect(mockRequestOptions.body.share_scope).toEqual(shareScope); + expect(mockRequestOptions.qs.force_share_scope_update).toEqual(forceShareScopeUpdate); + expect(mockRequestOptions.path.idp_id).toEqual(idpId); + } + + test('should pass the right params to createRequest with enable and disable retries', () => { + // baseline test + __updateIdpTest(); + + // enable retries and test again + createRequestMock.mockClear(); + iamIdentityService.enableRetries(); + __updateIdpTest(); + + // disable retries and test again + createRequestMock.mockClear(); + iamIdentityService.disableRetries(); + __updateIdpTest(); + }); + + test('should prioritize user-given headers', () => { + // parameters + const idpId = 'testString'; + const ifMatch = 'testString'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const updateIdpParams = { + idpId, + ifMatch, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + iamIdentityService.updateIdp(updateIdpParams); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async () => { + let err; + try { + await iamIdentityService.updateIdp({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + + test('should reject promise when required params are not given', async () => { + let err; + try { + await iamIdentityService.updateIdp(); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + }); + }); + + describe('deleteIdp', () => { + describe('positive tests', () => { + function __deleteIdpTest() { + // Construct the params object for operation deleteIdp + const idpId = 'testString'; + const deleteIdpParams = { + idpId, + }; + + const deleteIdpResult = iamIdentityService.deleteIdp(deleteIdpParams); + + // all methods should return a Promise + expectToBePromise(deleteIdpResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const mockRequestOptions = getOptions(createRequestMock); + + checkUrlAndMethod(mockRequestOptions, '/v1/idps/{idp_id}', 'DELETE'); + const expectedAccept = undefined; + const expectedContentType = undefined; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(mockRequestOptions.path.idp_id).toEqual(idpId); + } + + test('should pass the right params to createRequest with enable and disable retries', () => { + // baseline test + __deleteIdpTest(); + + // enable retries and test again + createRequestMock.mockClear(); + iamIdentityService.enableRetries(); + __deleteIdpTest(); + + // disable retries and test again + createRequestMock.mockClear(); + iamIdentityService.disableRetries(); + __deleteIdpTest(); + }); + + test('should prioritize user-given headers', () => { + // parameters + const idpId = 'testString'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const deleteIdpParams = { + idpId, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + iamIdentityService.deleteIdp(deleteIdpParams); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async () => { + let err; + try { + await iamIdentityService.deleteIdp({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + + test('should reject promise when required params are not given', async () => { + let err; + try { + await iamIdentityService.deleteIdp(); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + }); + }); + + describe('listConsumerAccounts', () => { + describe('positive tests', () => { + function __listConsumerAccountsTest() { + // Construct the params object for operation listConsumerAccounts + const idpId = 'testString'; + const listConsumerAccountsParams = { + idpId, + }; + + const listConsumerAccountsResult = iamIdentityService.listConsumerAccounts(listConsumerAccountsParams); + + // all methods should return a Promise + expectToBePromise(listConsumerAccountsResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const mockRequestOptions = getOptions(createRequestMock); + + checkUrlAndMethod(mockRequestOptions, '/v1/idps/{idp_id}/consumers', 'GET'); + const expectedAccept = 'application/json'; + const expectedContentType = undefined; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(mockRequestOptions.path.idp_id).toEqual(idpId); + } + + test('should pass the right params to createRequest with enable and disable retries', () => { + // baseline test + __listConsumerAccountsTest(); + + // enable retries and test again + createRequestMock.mockClear(); + iamIdentityService.enableRetries(); + __listConsumerAccountsTest(); + + // disable retries and test again + createRequestMock.mockClear(); + iamIdentityService.disableRetries(); + __listConsumerAccountsTest(); + }); + + test('should prioritize user-given headers', () => { + // parameters + const idpId = 'testString'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const listConsumerAccountsParams = { + idpId, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + iamIdentityService.listConsumerAccounts(listConsumerAccountsParams); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async () => { + let err; + try { + await iamIdentityService.listConsumerAccounts({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + + test('should reject promise when required params are not given', async () => { + let err; + try { + await iamIdentityService.listConsumerAccounts(); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + }); + }); + + describe('exportSamlMetadata', () => { + describe('positive tests', () => { + function __exportSamlMetadataTest() { + // Construct the params object for operation exportSamlMetadata + const idpId = 'testString'; + const exportSamlMetadataParams = { + idpId, + }; + + const exportSamlMetadataResult = iamIdentityService.exportSamlMetadata(exportSamlMetadataParams); + + // all methods should return a Promise + expectToBePromise(exportSamlMetadataResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const mockRequestOptions = getOptions(createRequestMock); + + checkUrlAndMethod(mockRequestOptions, '/v1/idps/{idp_id}/saml/metadata', 'GET'); + const expectedAccept = 'text/xml'; + const expectedContentType = undefined; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(mockRequestOptions.path.idp_id).toEqual(idpId); + } + + test('should pass the right params to createRequest with enable and disable retries', () => { + // baseline test + __exportSamlMetadataTest(); + + // enable retries and test again + createRequestMock.mockClear(); + iamIdentityService.enableRetries(); + __exportSamlMetadataTest(); + + // disable retries and test again + createRequestMock.mockClear(); + iamIdentityService.disableRetries(); + __exportSamlMetadataTest(); + }); + + test('should prioritize user-given headers', () => { + // parameters + const idpId = 'testString'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const exportSamlMetadataParams = { + idpId, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + iamIdentityService.exportSamlMetadata(exportSamlMetadataParams); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async () => { + let err; + try { + await iamIdentityService.exportSamlMetadata({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + + test('should reject promise when required params are not given', async () => { + let err; + try { + await iamIdentityService.exportSamlMetadata(); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + }); + }); + + describe('importSamlIdpMetadata', () => { + describe('positive tests', () => { + function __importSamlIdpMetadataTest() { + // Construct the params object for operation importSamlIdpMetadata + const idpId = 'testString'; + const body = Buffer.from('This is a mock file.'); + const parseOnly = false; + const importSamlIdpMetadataParams = { + idpId, + body, + parseOnly, + }; + + const importSamlIdpMetadataResult = iamIdentityService.importSamlIdpMetadata(importSamlIdpMetadataParams); + + // all methods should return a Promise + expectToBePromise(importSamlIdpMetadataResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const mockRequestOptions = getOptions(createRequestMock); + + checkUrlAndMethod(mockRequestOptions, '/v1/idps/{idp_id}/saml/metadata', 'PUT'); + const expectedAccept = 'application/json'; + const expectedContentType = 'text/xml'; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(mockRequestOptions.body).toEqual(body); + expect(mockRequestOptions.qs.parse_only).toEqual(parseOnly); + expect(mockRequestOptions.path.idp_id).toEqual(idpId); + } + + test('should pass the right params to createRequest with enable and disable retries', () => { + // baseline test + __importSamlIdpMetadataTest(); + + // enable retries and test again + createRequestMock.mockClear(); + iamIdentityService.enableRetries(); + __importSamlIdpMetadataTest(); + + // disable retries and test again + createRequestMock.mockClear(); + iamIdentityService.disableRetries(); + __importSamlIdpMetadataTest(); + }); + + test('should prioritize user-given headers', () => { + // parameters + const idpId = 'testString'; + const body = Buffer.from('This is a mock file.'); + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const importSamlIdpMetadataParams = { + idpId, + body, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + iamIdentityService.importSamlIdpMetadata(importSamlIdpMetadataParams); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async () => { + let err; + try { + await iamIdentityService.importSamlIdpMetadata({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + + test('should reject promise when required params are not given', async () => { + let err; + try { + await iamIdentityService.importSamlIdpMetadata(); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + }); + }); + + describe('getIdpTestResult', () => { + describe('positive tests', () => { + function __getIdpTestResultTest() { + // Construct the params object for operation getIdpTestResult + const idpId = 'testString'; + const getIdpTestResultParams = { + idpId, + }; + + const getIdpTestResultResult = iamIdentityService.getIdpTestResult(getIdpTestResultParams); + + // all methods should return a Promise + expectToBePromise(getIdpTestResultResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const mockRequestOptions = getOptions(createRequestMock); + + checkUrlAndMethod(mockRequestOptions, '/v1/idps/{idp_id}/test', 'GET'); + const expectedAccept = 'application/json'; + const expectedContentType = undefined; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(mockRequestOptions.path.idp_id).toEqual(idpId); + } + + test('should pass the right params to createRequest with enable and disable retries', () => { + // baseline test + __getIdpTestResultTest(); + + // enable retries and test again + createRequestMock.mockClear(); + iamIdentityService.enableRetries(); + __getIdpTestResultTest(); + + // disable retries and test again + createRequestMock.mockClear(); + iamIdentityService.disableRetries(); + __getIdpTestResultTest(); + }); + + test('should prioritize user-given headers', () => { + // parameters + const idpId = 'testString'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const getIdpTestResultParams = { + idpId, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + iamIdentityService.getIdpTestResult(getIdpTestResultParams); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async () => { + let err; + try { + await iamIdentityService.getIdpTestResult({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + + test('should reject promise when required params are not given', async () => { + let err; + try { + await iamIdentityService.getIdpTestResult(); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + }); + }); + + describe('testIdp', () => { + describe('positive tests', () => { + function __testIdpTest() { + // Construct the params object for operation testIdp + const idpId = 'testString'; + const testIdpParams = { + idpId, + }; + + const testIdpResult = iamIdentityService.testIdp(testIdpParams); + + // all methods should return a Promise + expectToBePromise(testIdpResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const mockRequestOptions = getOptions(createRequestMock); + + checkUrlAndMethod(mockRequestOptions, '/v1/idps/{idp_id}/test', 'POST'); + const expectedAccept = 'application/json'; + const expectedContentType = undefined; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(mockRequestOptions.path.idp_id).toEqual(idpId); + } + + test('should pass the right params to createRequest with enable and disable retries', () => { + // baseline test + __testIdpTest(); + + // enable retries and test again + createRequestMock.mockClear(); + iamIdentityService.enableRetries(); + __testIdpTest(); + + // disable retries and test again + createRequestMock.mockClear(); + iamIdentityService.disableRetries(); + __testIdpTest(); + }); + + test('should prioritize user-given headers', () => { + // parameters + const idpId = 'testString'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const testIdpParams = { + idpId, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + iamIdentityService.testIdp(testIdpParams); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async () => { + let err; + try { + await iamIdentityService.testIdp({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + + test('should reject promise when required params are not given', async () => { + let err; + try { + await iamIdentityService.testIdp(); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + }); + }); + + describe('getLoginSettings', () => { + describe('positive tests', () => { + function __getLoginSettingsTest() { + // Construct the params object for operation getLoginSettings + const accountId = 'testString'; + const getLoginSettingsParams = { + accountId, + }; + + const getLoginSettingsResult = iamIdentityService.getLoginSettings(getLoginSettingsParams); + + // all methods should return a Promise + expectToBePromise(getLoginSettingsResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const mockRequestOptions = getOptions(createRequestMock); + + checkUrlAndMethod(mockRequestOptions, '/v2/loginsettings/{account_id}', 'GET'); + const expectedAccept = 'application/json'; + const expectedContentType = undefined; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(mockRequestOptions.path.account_id).toEqual(accountId); + } + + test('should pass the right params to createRequest with enable and disable retries', () => { + // baseline test + __getLoginSettingsTest(); + + // enable retries and test again + createRequestMock.mockClear(); + iamIdentityService.enableRetries(); + __getLoginSettingsTest(); + + // disable retries and test again + createRequestMock.mockClear(); + iamIdentityService.disableRetries(); + __getLoginSettingsTest(); + }); + + test('should prioritize user-given headers', () => { + // parameters + const accountId = 'testString'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const getLoginSettingsParams = { + accountId, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + iamIdentityService.getLoginSettings(getLoginSettingsParams); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async () => { + let err; + try { + await iamIdentityService.getLoginSettings({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + + test('should reject promise when required params are not given', async () => { + let err; + try { + await iamIdentityService.getLoginSettings(); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + }); + }); + + describe('updateLoginSettings', () => { + describe('positive tests', () => { + function __updateLoginSettingsTest() { + // Construct the params object for operation updateLoginSettings + const accountId = 'testString'; + const alias = 'testString'; + const updateLoginSettingsParams = { + accountId, + alias, + }; + + const updateLoginSettingsResult = iamIdentityService.updateLoginSettings(updateLoginSettingsParams); + + // all methods should return a Promise + expectToBePromise(updateLoginSettingsResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const mockRequestOptions = getOptions(createRequestMock); + + checkUrlAndMethod(mockRequestOptions, '/v2/loginsettings/{account_id}', 'PUT'); + const expectedAccept = 'application/json'; + const expectedContentType = 'application/json'; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(mockRequestOptions.body.alias).toEqual(alias); + expect(mockRequestOptions.path.account_id).toEqual(accountId); + } + + test('should pass the right params to createRequest with enable and disable retries', () => { + // baseline test + __updateLoginSettingsTest(); + + // enable retries and test again + createRequestMock.mockClear(); + iamIdentityService.enableRetries(); + __updateLoginSettingsTest(); + + // disable retries and test again + createRequestMock.mockClear(); + iamIdentityService.disableRetries(); + __updateLoginSettingsTest(); + }); + + test('should prioritize user-given headers', () => { + // parameters + const accountId = 'testString'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const updateLoginSettingsParams = { + accountId, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + iamIdentityService.updateLoginSettings(updateLoginSettingsParams); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async () => { + let err; + try { + await iamIdentityService.updateLoginSettings({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + + test('should reject promise when required params are not given', async () => { + let err; + try { + await iamIdentityService.updateLoginSettings(); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + }); + }); + + describe('listIdPSettings', () => { + describe('positive tests', () => { + function __listIdPSettingsTest() { + // Construct the params object for operation listIdPSettings + const accountId = 'testString'; + const type = 'consumable'; + const includeIdpMetadata = 'testString'; + const listIdPSettingsParams = { + accountId, + type, + includeIdpMetadata, + }; + + const listIdPSettingsResult = iamIdentityService.listIdPSettings(listIdPSettingsParams); + + // all methods should return a Promise + expectToBePromise(listIdPSettingsResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const mockRequestOptions = getOptions(createRequestMock); + + checkUrlAndMethod(mockRequestOptions, '/v2/loginsettings/{account_id}/idps', 'GET'); + const expectedAccept = 'application/json'; + const expectedContentType = undefined; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(mockRequestOptions.qs.type).toEqual(type); + expect(mockRequestOptions.qs.include_idp_metadata).toEqual(includeIdpMetadata); + expect(mockRequestOptions.path.account_id).toEqual(accountId); + } + + test('should pass the right params to createRequest with enable and disable retries', () => { + // baseline test + __listIdPSettingsTest(); + + // enable retries and test again + createRequestMock.mockClear(); + iamIdentityService.enableRetries(); + __listIdPSettingsTest(); + + // disable retries and test again + createRequestMock.mockClear(); + iamIdentityService.disableRetries(); + __listIdPSettingsTest(); + }); + + test('should prioritize user-given headers', () => { + // parameters + const accountId = 'testString'; + const type = 'consumable'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const listIdPSettingsParams = { + accountId, + type, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + iamIdentityService.listIdPSettings(listIdPSettingsParams); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async () => { + let err; + try { + await iamIdentityService.listIdPSettings({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + + test('should reject promise when required params are not given', async () => { + let err; + try { + await iamIdentityService.listIdPSettings(); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + }); + }); + + describe('getIdPSetting', () => { + describe('positive tests', () => { + function __getIdPSettingTest() { + // Construct the params object for operation getIdPSetting + const accountId = 'testString'; + const idpId = 'testString'; + const getIdPSettingParams = { + accountId, + idpId, + }; + + const getIdPSettingResult = iamIdentityService.getIdPSetting(getIdPSettingParams); + + // all methods should return a Promise + expectToBePromise(getIdPSettingResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const mockRequestOptions = getOptions(createRequestMock); + + checkUrlAndMethod(mockRequestOptions, '/v2/loginsettings/{account_id}/idps/{idp_id}', 'GET'); + const expectedAccept = 'application/json'; + const expectedContentType = undefined; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(mockRequestOptions.path.account_id).toEqual(accountId); + expect(mockRequestOptions.path.idp_id).toEqual(idpId); + } + + test('should pass the right params to createRequest with enable and disable retries', () => { + // baseline test + __getIdPSettingTest(); + + // enable retries and test again + createRequestMock.mockClear(); + iamIdentityService.enableRetries(); + __getIdPSettingTest(); + + // disable retries and test again + createRequestMock.mockClear(); + iamIdentityService.disableRetries(); + __getIdPSettingTest(); + }); + + test('should prioritize user-given headers', () => { + // parameters + const accountId = 'testString'; + const idpId = 'testString'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const getIdPSettingParams = { + accountId, + idpId, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + iamIdentityService.getIdPSetting(getIdPSettingParams); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async () => { + let err; + try { + await iamIdentityService.getIdPSetting({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + + test('should reject promise when required params are not given', async () => { + let err; + try { + await iamIdentityService.getIdPSetting(); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + }); + }); + + describe('addIdPSetting', () => { + describe('positive tests', () => { + function __addIdPSettingTest() { + // Construct the params object for operation addIdPSetting + const accountId = 'testString'; + const idpId = 'testString'; + const cloudUserStrategy = 'STATIC'; + const active = true; + const uiDefault = true; + const addIdPSettingParams = { + accountId, + idpId, + cloudUserStrategy, + active, + uiDefault, + }; + + const addIdPSettingResult = iamIdentityService.addIdPSetting(addIdPSettingParams); + + // all methods should return a Promise + expectToBePromise(addIdPSettingResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const mockRequestOptions = getOptions(createRequestMock); + + checkUrlAndMethod(mockRequestOptions, '/v2/loginsettings/{account_id}/idps/{idp_id}', 'POST'); + const expectedAccept = 'application/json'; + const expectedContentType = 'application/json'; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(mockRequestOptions.body.cloud_user_strategy).toEqual(cloudUserStrategy); + expect(mockRequestOptions.body.active).toEqual(active); + expect(mockRequestOptions.body.ui_default).toEqual(uiDefault); + expect(mockRequestOptions.path.account_id).toEqual(accountId); + expect(mockRequestOptions.path.idp_id).toEqual(idpId); + } + + test('should pass the right params to createRequest with enable and disable retries', () => { + // baseline test + __addIdPSettingTest(); + + // enable retries and test again + createRequestMock.mockClear(); + iamIdentityService.enableRetries(); + __addIdPSettingTest(); + + // disable retries and test again + createRequestMock.mockClear(); + iamIdentityService.disableRetries(); + __addIdPSettingTest(); + }); + + test('should prioritize user-given headers', () => { + // parameters + const accountId = 'testString'; + const idpId = 'testString'; + const cloudUserStrategy = 'STATIC'; + const active = true; + const uiDefault = true; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const addIdPSettingParams = { + accountId, + idpId, + cloudUserStrategy, + active, + uiDefault, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + iamIdentityService.addIdPSetting(addIdPSettingParams); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async () => { + let err; + try { + await iamIdentityService.addIdPSetting({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + + test('should reject promise when required params are not given', async () => { + let err; + try { + await iamIdentityService.addIdPSetting(); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + }); + }); + + describe('updateIdPSetting', () => { + describe('positive tests', () => { + function __updateIdPSettingTest() { + // Construct the params object for operation updateIdPSetting + const accountId = 'testString'; + const idpId = 'testString'; + const cloudUserStrategy = 'STATIC'; + const active = true; + const uiDefault = true; + const updateIdPSettingParams = { + accountId, + idpId, + cloudUserStrategy, + active, + uiDefault, + }; + + const updateIdPSettingResult = iamIdentityService.updateIdPSetting(updateIdPSettingParams); + + // all methods should return a Promise + expectToBePromise(updateIdPSettingResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const mockRequestOptions = getOptions(createRequestMock); + + checkUrlAndMethod(mockRequestOptions, '/v2/loginsettings/{account_id}/idps/{idp_id}', 'PUT'); + const expectedAccept = 'application/json'; + const expectedContentType = 'application/json'; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(mockRequestOptions.body.cloud_user_strategy).toEqual(cloudUserStrategy); + expect(mockRequestOptions.body.active).toEqual(active); + expect(mockRequestOptions.body.ui_default).toEqual(uiDefault); + expect(mockRequestOptions.path.account_id).toEqual(accountId); + expect(mockRequestOptions.path.idp_id).toEqual(idpId); + } + + test('should pass the right params to createRequest with enable and disable retries', () => { + // baseline test + __updateIdPSettingTest(); + + // enable retries and test again + createRequestMock.mockClear(); + iamIdentityService.enableRetries(); + __updateIdPSettingTest(); + + // disable retries and test again + createRequestMock.mockClear(); + iamIdentityService.disableRetries(); + __updateIdPSettingTest(); + }); + + test('should prioritize user-given headers', () => { + // parameters + const accountId = 'testString'; + const idpId = 'testString'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const updateIdPSettingParams = { + accountId, + idpId, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + iamIdentityService.updateIdPSetting(updateIdPSettingParams); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async () => { + let err; + try { + await iamIdentityService.updateIdPSetting({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + + test('should reject promise when required params are not given', async () => { + let err; + try { + await iamIdentityService.updateIdPSetting(); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + }); + }); + + describe('removeIdPSetting', () => { + describe('positive tests', () => { + function __removeIdPSettingTest() { + // Construct the params object for operation removeIdPSetting + const accountId = 'testString'; + const idpId = 'testString'; + const removeIdPSettingParams = { + accountId, + idpId, + }; + + const removeIdPSettingResult = iamIdentityService.removeIdPSetting(removeIdPSettingParams); + + // all methods should return a Promise + expectToBePromise(removeIdPSettingResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const mockRequestOptions = getOptions(createRequestMock); + + checkUrlAndMethod(mockRequestOptions, '/v2/loginsettings/{account_id}/idps/{idp_id}', 'DELETE'); + const expectedAccept = undefined; + const expectedContentType = undefined; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(mockRequestOptions.path.account_id).toEqual(accountId); + expect(mockRequestOptions.path.idp_id).toEqual(idpId); + } + + test('should pass the right params to createRequest with enable and disable retries', () => { + // baseline test + __removeIdPSettingTest(); + + // enable retries and test again + createRequestMock.mockClear(); + iamIdentityService.enableRetries(); + __removeIdPSettingTest(); + + // disable retries and test again + createRequestMock.mockClear(); + iamIdentityService.disableRetries(); + __removeIdPSettingTest(); + }); + + test('should prioritize user-given headers', () => { + // parameters + const accountId = 'testString'; + const idpId = 'testString'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const removeIdPSettingParams = { + accountId, + idpId, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + iamIdentityService.removeIdPSetting(removeIdPSettingParams); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async () => { + let err; + try { + await iamIdentityService.removeIdPSetting({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + + test('should reject promise when required params are not given', async () => { + let err; + try { + await iamIdentityService.removeIdPSetting(); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + }); + }); });