Skip to content

Commit

Permalink
mark user_id as required for grants.deleteByUserId (#930)
Browse files Browse the repository at this point in the history
Co-authored-by: Adam Mcgrath <[email protected]>
  • Loading branch information
frederikprijck and adamjmcgrath authored Sep 11, 2023
1 parent 7a43260 commit f1c6646
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/management/__generated/managers/grants-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,11 @@ export class GrantsManager extends BaseAPI {
* @throws {RequiredError}
*/
async deleteByUserId(
requestParameters: DeleteGrantsByUserIdRequest = {},
requestParameters: DeleteGrantsByUserIdRequest,
initOverrides?: InitOverride
): Promise<ApiResponse<void>> {
runtime.validateRequiredRequestParams(requestParameters, ['user_id']);

const queryParameters = runtime.applyQueryParams(requestParameters, [
{
key: 'user_id',
Expand Down
2 changes: 1 addition & 1 deletion src/management/__generated/models/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12774,7 +12774,7 @@ export interface DeleteGrantsByUserIdRequest {
* user_id of the grant to delete.
*
*/
user_id?: string;
user_id: string;
}
/**
*
Expand Down
27 changes: 26 additions & 1 deletion test/management/grants.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
});
});
});
});

0 comments on commit f1c6646

Please sign in to comment.