From bfeb62ac98e38a1332f2de10d884eaebbe63afed Mon Sep 17 00:00:00 2001 From: frederikprijck Date: Sun, 10 Sep 2023 22:42:07 +0200 Subject: [PATCH 1/3] mark user_id as required for grants.deleteByUserId --- src/management/__generated/managers/grants-manager.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/management/__generated/managers/grants-manager.ts b/src/management/__generated/managers/grants-manager.ts index 33f8609b1..485edfd0d 100644 --- a/src/management/__generated/managers/grants-manager.ts +++ b/src/management/__generated/managers/grants-manager.ts @@ -45,9 +45,11 @@ export class GrantsManager extends BaseAPI { * @throws {RequiredError} */ async deleteByUserId( - requestParameters: DeleteGrantsByUserIdRequest = {}, + requestParameters: DeleteGrantsByUserIdRequest, initOverrides?: InitOverride ): Promise> { + runtime.validateRequiredRequestParams(requestParameters, ['user_id']); + const queryParameters = runtime.applyQueryParams(requestParameters, [ { key: 'user_id', From c044fcabfbfbede2df16bed66809aed8a413284e Mon Sep 17 00:00:00 2001 From: frederikprijck Date: Sun, 10 Sep 2023 23:01:23 +0200 Subject: [PATCH 2/3] add tests --- test/management/grants.test.ts | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/test/management/grants.test.ts b/test/management/grants.test.ts index d4d3b4687..b437347c7 100644 --- a/test/management/grants.test.ts +++ b/test/management/grants.test.ts @@ -2,7 +2,7 @@ import nock from 'nock'; const API_URL = 'https://tenant.auth0.com/api/v2'; -import { GrantsManager, ManagementClient } from '../../src/index.js'; +import { GrantsManager, ManagementClient, RequiredError } from '../../src/index.js'; describe('GrantsManager', () => { let grants: GrantsManager; @@ -148,5 +148,30 @@ describe('GrantsManager', () => { done(); }); }); + + describe('#deleteByUserId', () => { + const user_id = '5'; + let request: nock.Scope; + + beforeEach(() => { + request = nock(API_URL).delete(`/grants/?user_id=${user_id}`).reply(200, {}); + }); + + it('should return a promise when no callback is given', (done) => { + grants.deleteByUserId({ user_id }).then(done.bind(null, null)); + }); + + it(`should perform a DELETE request to /grants/${id}`, (done) => { + grants.deleteByUserId({ user_id }).then(() => { + expect(request.isDone()).toBe(true); + + done(); + }); + }); + + it('should return an error when client_id is not sent', async () => { + await expect(grants.deleteByUserId({} as any)).rejects.toThrowError(RequiredError); + }); + }); }); }); From 91048fc58faa45faadc61bac98e0491e50e6a230 Mon Sep 17 00:00:00 2001 From: frederikprijck Date: Sun, 10 Sep 2023 23:07:59 +0200 Subject: [PATCH 3/3] update types --- src/management/__generated/models/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/management/__generated/models/index.ts b/src/management/__generated/models/index.ts index 3cbcb36d7..83466dff8 100644 --- a/src/management/__generated/models/index.ts +++ b/src/management/__generated/models/index.ts @@ -12812,7 +12812,7 @@ export interface DeleteGrantsByUserIdRequest { * user_id of the grant to delete. * */ - user_id?: string; + user_id: string; } /** *