diff --git a/package-lock.json b/package-lock.json index daf194585..3394e2efc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,11 +10,13 @@ "license": "MIT", "dependencies": { "jose": "^4.13.2", + "lodash-es": "^4.17.21", "undici-types": "^6.15.0", "uuid": "^9.0.0" }, "devDependencies": { "@types/jest": "^29.5.0", + "@types/lodash-es": "^4.17.12", "@types/node": "^16.18.37", "@types/node-fetch": "^2.6.3", "@types/uuid": "^9.0.1", @@ -1462,6 +1464,21 @@ "integrity": "sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==", "dev": true }, + "node_modules/@types/lodash": { + "version": "4.17.7", + "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.17.7.tgz", + "integrity": "sha512-8wTvZawATi/lsmNu10/j2hk1KEP0IvjubqPE3cu1Xz7xfXXt5oCq3SNUz4fMIP4XGF9Ky+Ue2tBA3hcS7LSBlA==", + "dev": true + }, + "node_modules/@types/lodash-es": { + "version": "4.17.12", + "resolved": "https://registry.npmjs.org/@types/lodash-es/-/lodash-es-4.17.12.tgz", + "integrity": "sha512-0NgftHUcV4v34VhXm8QBSftKVXtbkBG3ViCjs6+eJ5a6y6Mi/jiFGPc1sC7QK+9BFhWrURE3EOggmWaSxL9OzQ==", + "dev": true, + "dependencies": { + "@types/lodash": "*" + } + }, "node_modules/@types/node": { "version": "16.18.37", "resolved": "https://registry.npmjs.org/@types/node/-/node-16.18.37.tgz", @@ -5219,6 +5236,11 @@ "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", "dev": true }, + "node_modules/lodash-es": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash-es/-/lodash-es-4.17.21.tgz", + "integrity": "sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw==" + }, "node_modules/lodash.memoize": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-4.1.2.tgz", @@ -8659,6 +8681,21 @@ "integrity": "sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==", "dev": true }, + "@types/lodash": { + "version": "4.17.7", + "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.17.7.tgz", + "integrity": "sha512-8wTvZawATi/lsmNu10/j2hk1KEP0IvjubqPE3cu1Xz7xfXXt5oCq3SNUz4fMIP4XGF9Ky+Ue2tBA3hcS7LSBlA==", + "dev": true + }, + "@types/lodash-es": { + "version": "4.17.12", + "resolved": "https://registry.npmjs.org/@types/lodash-es/-/lodash-es-4.17.12.tgz", + "integrity": "sha512-0NgftHUcV4v34VhXm8QBSftKVXtbkBG3ViCjs6+eJ5a6y6Mi/jiFGPc1sC7QK+9BFhWrURE3EOggmWaSxL9OzQ==", + "dev": true, + "requires": { + "@types/lodash": "*" + } + }, "@types/node": { "version": "16.18.37", "resolved": "https://registry.npmjs.org/@types/node/-/node-16.18.37.tgz", @@ -11415,6 +11452,11 @@ "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", "dev": true }, + "lodash-es": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash-es/-/lodash-es-4.17.21.tgz", + "integrity": "sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw==" + }, "lodash.memoize": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-4.1.2.tgz", diff --git a/package.json b/package.json index 4b93fd61c..fbbab3d6b 100644 --- a/package.json +++ b/package.json @@ -51,8 +51,8 @@ "homepage": "https://github.com/auth0/node-auth0", "dependencies": { "jose": "^4.13.2", - "uuid": "^9.0.0", - "undici-types": "^6.15.0" + "undici-types": "^6.15.0", + "uuid": "^9.0.0" }, "devDependencies": { "@types/jest": "^29.5.0", diff --git a/src/management/__generated/index.ts b/src/management/__generated/index.ts index 2fc3f6bc6..3850ad31b 100644 --- a/src/management/__generated/index.ts +++ b/src/management/__generated/index.ts @@ -28,6 +28,7 @@ import { RolesManager, RulesManager, RulesConfigsManager, + SelfServiceProfilesManager, SessionsManager, StatsManager, TenantsManager, @@ -66,6 +67,7 @@ export abstract class ManagementClientBase { public readonly roles = new RolesManager(this.configuration); public readonly rules = new RulesManager(this.configuration); public readonly rulesConfigs = new RulesConfigsManager(this.configuration); + public readonly selfServiceProfiles = new SelfServiceProfilesManager(this.configuration); public readonly sessions = new SessionsManager(this.configuration); public readonly stats = new StatsManager(this.configuration); public readonly tenants = new TenantsManager(this.configuration); diff --git a/src/management/__generated/managers/index.ts b/src/management/__generated/managers/index.ts index 465cfca91..d169c1eae 100644 --- a/src/management/__generated/managers/index.ts +++ b/src/management/__generated/managers/index.ts @@ -24,6 +24,7 @@ export * from './resource-servers-manager.js'; export * from './roles-manager.js'; export * from './rules-manager.js'; export * from './rules-configs-manager.js'; +export * from './self-service-profiles-manager.js'; export * from './sessions-manager.js'; export * from './stats-manager.js'; export * from './tenants-manager.js'; diff --git a/src/management/__generated/managers/self-service-profiles-manager.ts b/src/management/__generated/managers/self-service-profiles-manager.ts new file mode 100644 index 000000000..d7b9b96de --- /dev/null +++ b/src/management/__generated/managers/self-service-profiles-manager.ts @@ -0,0 +1,184 @@ +import * as runtime from '../../../lib/runtime.js'; +import type { InitOverride, ApiResponse } from '../../../lib/runtime.js'; +import type { + SsProfile, + SsProfileCreate, + SsProfileList, + SsProfileUpdate, + SsoAccessTicketResponse, + SsoTicketRequestJson, + DeleteSelfServiceProfilesByIdRequest, + GetSelfServiceProfilesByIdRequest, + PatchSelfServiceProfilesByIdRequest, + PostSsoTicketRequest, +} from '../models/index.js'; + +const { BaseAPI } = runtime; + +/** + * + */ +export class SelfServiceProfilesManager extends BaseAPI { + /** + * Deletes a self-service profile by Id. + * Delete a self-service profile by Id + * + * @throws {RequiredError} + */ + async deleteSelfServiceProfiles( + requestParameters: DeleteSelfServiceProfilesByIdRequest, + initOverrides?: InitOverride + ): Promise> { + runtime.validateRequiredRequestParams(requestParameters, ['id']); + + const response = await this.request( + { + path: `/self-service-profiles/{id}`.replace( + '{id}', + encodeURIComponent(String(requestParameters.id)) + ), + method: 'DELETE', + }, + initOverrides + ); + + return runtime.VoidApiResponse.fromResponse(response); + } + + /** + * Retrieves self-service profiles. Currently only one profile can be created per tenant. + * Retrieve self-service profiles + * + * @throws {RequiredError} + */ + async getSelfServiceProfiles(initOverrides?: InitOverride): Promise> { + const response = await this.request( + { + path: `/self-service-profiles`, + method: 'GET', + }, + initOverrides + ); + + return runtime.JSONApiResponse.fromResponse(response); + } + + /** + * Retrieves a self-service profile by Id. + * Retrieve a self-service profile by Id + * + * @throws {RequiredError} + */ + async getSelfServiceProfilesById( + requestParameters: GetSelfServiceProfilesByIdRequest, + initOverrides?: InitOverride + ): Promise> { + runtime.validateRequiredRequestParams(requestParameters, ['id']); + + const response = await this.request( + { + path: `/self-service-profiles/{id}`.replace( + '{id}', + encodeURIComponent(String(requestParameters.id)) + ), + method: 'GET', + }, + initOverrides + ); + + return runtime.JSONApiResponse.fromResponse(response); + } + + /** + * Updates a self-service profile. + * Update a self-service profile + * + * @throws {RequiredError} + */ + async patchSelfServiceProfiles( + requestParameters: PatchSelfServiceProfilesByIdRequest, + bodyParameters: SsProfileUpdate, + initOverrides?: InitOverride + ): Promise> { + runtime.validateRequiredRequestParams(requestParameters, ['id']); + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + const response = await this.request( + { + path: `/self-service-profiles/{id}`.replace( + '{id}', + encodeURIComponent(String(requestParameters.id)) + ), + method: 'PATCH', + headers: headerParameters, + body: bodyParameters, + }, + initOverrides + ); + + return runtime.JSONApiResponse.fromResponse(response); + } + + /** + * Creates a self-service profile. Currently only one profile can be created per tenant. + * Create a self-service profile + * + * @throws {RequiredError} + */ + async postSelfServiceProfiles( + bodyParameters: SsProfileCreate, + initOverrides?: InitOverride + ): Promise> { + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + const response = await this.request( + { + path: `/self-service-profiles`, + method: 'POST', + headers: headerParameters, + body: bodyParameters, + }, + initOverrides + ); + + return runtime.JSONApiResponse.fromResponse(response); + } + + /** + * Creates an sso-access ticket to initiate the Self Service SSO Flow using a self-service profile. + * Create an sso-access ticket to initiate the Self Service SSO Flow + * + * @throws {RequiredError} + */ + async postSsoTicket( + requestParameters: PostSsoTicketRequest, + bodyParameters: SsoTicketRequestJson, + initOverrides?: InitOverride + ): Promise> { + runtime.validateRequiredRequestParams(requestParameters, ['id']); + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + const response = await this.request( + { + path: `/self-service-profiles/{id}/sso-ticket`.replace( + '{id}', + encodeURIComponent(String(requestParameters.id)) + ), + method: 'POST', + headers: headerParameters, + body: bodyParameters, + }, + initOverrides + ); + + return runtime.JSONApiResponse.fromResponse(response); + } +} diff --git a/src/management/__generated/models/index.ts b/src/management/__generated/models/index.ts index d534bdf92..be0beb97e 100644 --- a/src/management/__generated/models/index.ts +++ b/src/management/__generated/models/index.ts @@ -11781,6 +11781,182 @@ export interface SnsFactorProvider { */ sns_gcm_platform_application_arn: string | null; } +/** + * + */ +export interface SsProfile { + /** + * The unique ID of the self-service Profile. + * + */ + id: string; + /** + * List of attributes to be mapped that will be shown to the user during the SS-SSO flow. + * + */ + user_attributes: Array; + /** + * The time when this self-service Profile was created. + * + */ + created_at: string; + /** + * The time when this self-service Profile was updated. + * + */ + updated_at: string; + /** + */ + branding: SsProfileBranding; +} +/** + * + */ +export interface SsProfileBranding { + [key: string]: any | any; + /** + */ + logo_url: string; + /** + */ + colors: SsProfileBrandingColors; +} +/** + * + */ +export interface SsProfileBrandingColors { + [key: string]: any | any; + /** + */ + primary: string; +} +/** + * + */ +export interface SsProfileCreate { + /** + * List of attributes to be mapped that will be shown to the user during the SS-SSO flow. + * + */ + user_attributes?: Array; + /** + */ + branding?: SsProfileCreateBranding; +} +/** + * + */ +export interface SsProfileCreateBranding { + [key: string]: any | any; + /** + */ + logo_url?: string; + /** + */ + colors?: SsProfileBrandingColors; +} +/** + * + */ +export interface SsProfileList extends Array {} +/** + * + */ +export interface SsProfileUpdate { + /** + * List of attributes to be mapped that will be shown to the user during the SS-SSO flow. + * + */ + user_attributes?: Array | null; + /** + */ + branding?: SsProfileUpdateBranding | null; +} +/** + * + */ +export interface SsProfileUpdateBranding { + [key: string]: any | any; + /** + */ + logo_url?: string; + /** + */ + colors?: SsProfileBrandingColors; +} +/** + * + */ +export interface SsProfileUserAttributesInner { + /** + * Identifier of this attribute. + * + */ + name: string; + /** + * Description of this attribute. + * + */ + description: string; + /** + * Determines if this attribute is required + * + */ + is_optional: boolean; +} +/** + * + */ +export interface SsoAccessTicketResponse { + /** + * The URL for the created ticket. + * + */ + ticket: string; +} +/** + * + */ +export interface SsoTicketRequestJson { + /** + * If provided, this will allow editing of the provided connection during the SSO Flow + * + */ + connection_id?: string; + /** + */ + connection_config?: SsoTicketRequestJsonConnectionConfig; + /** + * List of client_ids that the connection will be enabled for. + * + */ + enabled_clients?: Array; + /** + * List of organizations that the connection will be enabled for. + * + */ + enabled_organizations?: Array; +} +/** + * If provided, this will create a new connection for the SSO flow with the given configuration + */ +export interface SsoTicketRequestJsonConnectionConfig { + /** + * The name of the connection that will be created as a part of the SSO flow. + * + */ + name: string; +} +/** + * + */ +export interface SsoTicketRequestJsonEnabledOrganizationsInner { + /** + * Organization identifier + * + */ + organization_id: string; +} /** * */ @@ -15404,6 +15580,46 @@ export interface PutRulesConfigsByKeyOperationRequest { */ key: string; } +/** + * + */ +export interface DeleteSelfServiceProfilesByIdRequest { + /** + * The id of the self-service profile to delete + * + */ + id: string; +} +/** + * + */ +export interface GetSelfServiceProfilesByIdRequest { + /** + * The id of the self-service profile to retrieve + * + */ + id: string; +} +/** + * + */ +export interface PatchSelfServiceProfilesByIdRequest { + /** + * The id of the self-service profile to update + * + */ + id: string; +} +/** + * + */ +export interface PostSsoTicketRequest { + /** + * The id of the sso-profile to retrieve + * + */ + id: string; +} /** * */ diff --git a/test/management/self-service-profiles.test.ts b/test/management/self-service-profiles.test.ts new file mode 100644 index 000000000..9b3e4271e --- /dev/null +++ b/test/management/self-service-profiles.test.ts @@ -0,0 +1,314 @@ +import nock from 'nock'; + +const DOMAIN = `tenant.auth0.com`; +const API_URL = `https://${DOMAIN}/api/v2`; + +import { + DeleteSelfServiceProfilesByIdRequest, + GetSelfServiceProfilesByIdRequest, + ManagementClient, + PatchSelfServiceProfilesByIdRequest, + PostSsoTicketRequest, + SelfServiceProfilesManager, + SsoAccessTicketResponse, + SsoTicketRequestJson, + SsProfile, + SsProfileCreate, + SsProfileList, + SsProfileUpdate, +} from '../../src/index.js'; + +describe('SelfServiceProfilesManager', () => { + let selfServiceProfileManager: SelfServiceProfilesManager; + let nockedRequest: nock.Scope; + const token = 'TOKEN'; + + beforeAll(() => { + const client = new ManagementClient({ + domain: DOMAIN, + token: token, + }); + selfServiceProfileManager = client.selfServiceProfiles; + }); + + describe('createSelfServiceProfiles', () => { + const requestBody: SsProfileCreate | any = { + user_attributes: [{ name: 'testAttribute', description: 'testAttribute', is_optional: true }], + branding: { logo_url: 'https://example.com', colors: { primary: '#1c1c1c' } }, + }; + + it('should return a promise if no callback is given', (done) => { + selfServiceProfileManager + .postSelfServiceProfiles(requestBody) + .then(done.bind(null, null)) + .catch(done.bind(null, null)); + }); + + it('should pass any errors to the promise catch handler', () => { + nock.cleanAll(); + + nock(API_URL).post('/self-service-profiles').reply(500, {}); + + return selfServiceProfileManager.postSelfServiceProfiles(requestBody).catch((err) => { + expect(err).toBeDefined(); + }); + }); + + // this test is for the method postSelfServiceProfiles, uses SsProfileCreate as body + it('should return the created self-service profile', async () => { + const nockedResponse: SsProfile = { + id: 'testing_id_123', + user_attributes: [ + { name: 'testAttribute', description: 'testAttribute', is_optional: true }, + ], + created_at: new Date().toISOString(), + updated_at: new Date().toISOString(), + branding: { logo_url: 'https://example.com', colors: { primary: '#1c1c1c' } }, + }; + + // eslint-disable-next-line prettier/prettier + nockedRequest = nock(API_URL) + .post('/self-service-profiles', requestBody) + .reply(200, nockedResponse); + + const createResult = await selfServiceProfileManager.postSelfServiceProfiles(requestBody); + + expect(createResult.data).toEqual(nockedResponse); + }); + }); + + describe('getSelfServiceProfiles', () => { + it('should return a promise if no callback is given', (done) => { + selfServiceProfileManager + .getSelfServiceProfiles() + .then(done.bind(null, null)) + .catch(done.bind(null, null)); + }); + + it('should pass any errors to the promise catch handler', () => { + nock.cleanAll(); + + nock(API_URL).get('/self-service-profiles').reply(500, {}); + + return selfServiceProfileManager.getSelfServiceProfiles().catch((err) => { + expect(err).toBeDefined(); + }); + }); + + // this unit test is for the getSelfServiceProfiles() method + it('should return the list of self-service profiles', async () => { + const exampleData: SsProfile = { + id: 'testing_id_123', + user_attributes: [ + { name: 'testAttribute', description: 'testAttribute', is_optional: true }, + ], + created_at: new Date().toISOString(), + updated_at: new Date().toISOString(), + branding: { logo_url: 'https://example.com', colors: { primary: '#1c1c1c' } }, + }; + + const nockedResponse: SsProfileList = [exampleData]; + + // eslint-disable-next-line prettier/prettier + nockedRequest = nock(API_URL).get('/self-service-profiles').reply(200, nockedResponse); + + const getResult = await selfServiceProfileManager.getSelfServiceProfiles(); + + expect(getResult.data).toEqual(nockedResponse); + expect(getResult.data.length).toBeGreaterThan(0); + }); + }); + + describe('getSelfServiceProfilesById', () => { + const requestParameters: GetSelfServiceProfilesByIdRequest = { + id: 'testing_id_123', + }; + + it('should return a promise if no callback is given', (done) => { + selfServiceProfileManager + .getSelfServiceProfilesById(requestParameters) + .then(done.bind(null, null)) + .catch(done.bind(null, null)); + }); + + it('should pass any errors to the promise catch handler', () => { + nock.cleanAll(); + + nock(API_URL).get(`/self-service-profiles/${requestParameters.id}`).reply(500, {}); + + return selfServiceProfileManager + .getSelfServiceProfilesById(requestParameters) + .catch((err) => { + expect(err).toBeDefined(); + }); + }); + + // this unit test is for the getSelfServiceProfileById() method + it('should return one of self-service profile by id', async () => { + const nockedResponse: SsProfile = { + id: 'testing_id_123', + user_attributes: [ + { name: 'testAttribute', description: 'testAttribute', is_optional: true }, + ], + created_at: new Date().toISOString(), + updated_at: new Date().toISOString(), + branding: { logo_url: 'https://example.com', colors: { primary: '#1c1c1c' } }, + }; + + nock.cleanAll(); + // eslint-disable-next-line prettier/prettier + nockedRequest = nock(API_URL) + .get(`/self-service-profiles/${requestParameters.id}`) + .reply(200, nockedResponse); + + const getResult = await selfServiceProfileManager.getSelfServiceProfilesById( + requestParameters + ); + expect(getResult.data).toEqual(nockedResponse); + }); + }); + + describe('deleteSelfServiceProfiles', () => { + const requestParameters: DeleteSelfServiceProfilesByIdRequest = { + id: 'testing_id_123', + }; + + it('should return a promise if no callback is given', (done) => { + selfServiceProfileManager + .deleteSelfServiceProfiles(requestParameters) + .then(done.bind(null, null)) + .catch(done.bind(null, null)); + }); + + it('should pass any errors to the promise catch handler', () => { + nock.cleanAll(); + + nock(API_URL).get(`/self-service-profiles/${requestParameters.id}`).reply(500, {}); + + return selfServiceProfileManager.deleteSelfServiceProfiles(requestParameters).catch((err) => { + expect(err).toBeDefined(); + }); + }); + + // this unit test is for the deleteSelfServiceProfiles() method + it('should delete one of self-service profile by id', async () => { + // eslint-disable-next-line prettier/prettier + nockedRequest = nock(API_URL) + .delete(`/self-service-profiles/${requestParameters.id}`) + .reply(200); + + await selfServiceProfileManager.deleteSelfServiceProfiles(requestParameters); + + expect(nockedRequest.isDone()).toBe(true); + }); + }); + + describe('patchSelfServiceProfiles', () => { + const requestParameters: PatchSelfServiceProfilesByIdRequest = { + id: 'testing_id_123', + }; + const requestBody: SsProfileUpdate = { + user_attributes: [ + { name: 'modifiedTestAttribute', description: 'modifiedTestAttribute', is_optional: true }, + ], + branding: { logo_url: 'https://example.com', colors: { primary: '#ff00ff' } }, + }; + + it('should return a promise if no callback is given', (done) => { + selfServiceProfileManager + .patchSelfServiceProfiles(requestParameters, requestBody) + .then(done.bind(null, null)) + .catch(done.bind(null, null)); + }); + + it('should pass any errors to the promise catch handler', () => { + nock.cleanAll(); + + nock(API_URL).patch(`/self-service-profiles/${requestParameters.id}`).reply(500, {}); + + return selfServiceProfileManager + .patchSelfServiceProfiles(requestParameters, requestBody) + .catch((err) => { + expect(err).toBeDefined(); + }); + }); + + // this unit test is for the patchSelfServiceProfiles() method + it('should update one of self-service profile by id', async () => { + const nockedResponse: SsProfile = { + id: requestParameters.id, + user_attributes: [ + { + name: 'modifiedTestAttribute', + description: 'modifiedTestAttribute', + is_optional: true, + }, + ], + created_at: new Date().toISOString(), + updated_at: new Date().toISOString(), + branding: { logo_url: 'https://example.com', colors: { primary: '#ff00ff' } }, + }; + + // eslint-disable-next-line prettier/prettier + nockedRequest = nock(API_URL) + .patch(`/self-service-profiles/${requestParameters.id}`) + .reply(200, nockedResponse); + + const patchResult = await selfServiceProfileManager.patchSelfServiceProfiles( + requestParameters, + requestBody + ); + + expect(patchResult.data).toEqual(nockedResponse); + }); + }); + + describe('postSsoTicket', () => { + const requestParameters: PostSsoTicketRequest = { + id: 'testing_id_123', + }; + const requestBody: SsoTicketRequestJson = { + connection_id: 'connection_id', + connection_config: { name: 'test_connection_config' }, + enabled_clients: ['client1'], + enabled_organizations: [{ organization_id: requestParameters.id }], + }; + + it('should return a promise if no callback is given', (done) => { + selfServiceProfileManager + .postSsoTicket(requestParameters, requestBody) + .then(done.bind(null, null)) + .catch(done.bind(null, null)); + }); + + it('should pass any errors to the promise catch handler', () => { + nock.cleanAll(); + + nock(API_URL) + .post(`/self-service-profiles/${requestParameters.id}/sso-ticket`) + .reply(500, {}); + + return selfServiceProfileManager + .postSsoTicket(requestParameters, requestBody) + .catch((err) => { + expect(err).toBeDefined(); + }); + }); + + // this unit test is for the postSsoTicket() method + it('should set sso ticket for one sso profile', async () => { + const nockedResponse: SsoAccessTicketResponse = { + ticket: 'https://example.com/ticket', + }; + + // eslint-disable-next-line prettier/prettier + nockedRequest = nock(API_URL) + .post(`/self-service-profiles/${requestParameters.id}/sso-ticket`) + .reply(200, nockedResponse); + + const result = await selfServiceProfileManager.postSsoTicket(requestParameters, requestBody); + + expect(result.data).toEqual(nockedResponse); + }); + }); +});