Skip to content

Commit 3daaca9

Browse files
authored
Multi SSO - admin link support (#436)
1 parent 10d0205 commit 3daaca9

File tree

3 files changed

+35
-1
lines changed

3 files changed

+35
-1
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,7 @@ await descopeClient.management.tenant.configureSettings('my-tenant-id', {
585585
});
586586

587587
// Generate tenant admin self service link for SSO configuration (valid for 24 hours)
588+
// ssoId can be provided for a specific sso configuration
588589
const res = await descopeClient.management.tenant.generateSSOConfigurationLink(
589590
'my-tenant-id',
590591
60 * 60 * 24,

lib/management/tenant.test.ts

+32
Original file line numberDiff line numberDiff line change
@@ -316,5 +316,37 @@ describe('Management Tenant', () => {
316316
response: httpResponse,
317317
});
318318
});
319+
320+
it('should send the correct request and receive correct response with sso id', async () => {
321+
const httpResponse = {
322+
ok: true,
323+
json: () => ({
324+
adminSSOConfigurationLink: 'some link',
325+
}),
326+
clone: () => ({
327+
json: () => Promise.resolve({ adminSSOConfigurationLink: 'some link' }),
328+
}),
329+
status: 200,
330+
};
331+
mockHttpClient.post.mockResolvedValue(httpResponse);
332+
333+
const resp: SdkResponse<GenerateSSOConfigurationLinkResponse> =
334+
await management.tenant.generateSSOConfigurationLink('test', 60 * 60 * 24, 'some-ssoid');
335+
336+
expect(mockHttpClient.post).toHaveBeenCalledWith(
337+
apiPaths.tenant.generateSSOConfigurationLink,
338+
{ tenantId: 'test', expireTime: 60 * 60 * 24, ssoId: 'some-ssoid' },
339+
{
340+
token: 'key',
341+
},
342+
);
343+
344+
expect(resp).toEqual({
345+
code: 200,
346+
data: { adminSSOConfigurationLink: 'some link' },
347+
ok: true,
348+
response: httpResponse,
349+
});
350+
});
319351
});
320352
});

lib/management/tenant.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,12 @@ const withTenant = (sdk: CoreSdk, managementKey?: string) => ({
111111
generateSSOConfigurationLink: (
112112
tenantId: string,
113113
expireDuration: number,
114+
ssoId?: string,
114115
): Promise<SdkResponse<GenerateSSOConfigurationLinkResponse>> =>
115116
transformResponse<GenerateSSOConfigurationLinkResponse, GenerateSSOConfigurationLinkResponse>(
116117
sdk.httpClient.post(
117118
apiPaths.tenant.generateSSOConfigurationLink,
118-
{ tenantId, expireTime: expireDuration },
119+
{ tenantId, expireTime: expireDuration, ssoId },
119120
{
120121
token: managementKey,
121122
},

0 commit comments

Comments
 (0)