From 588271eb03e3a3c3ea0497082ca62b18e6bf995d Mon Sep 17 00:00:00 2001 From: TheoPouletSouchard Date: Tue, 7 Jan 2025 17:10:20 +0100 Subject: [PATCH] Add available user roles listing endpoint --- src/Users/index.ts | 10 ++++++++++ test/Users/index.test.js | 11 +++++++++++ 2 files changed, 21 insertions(+) diff --git a/src/Users/index.ts b/src/Users/index.ts index 2ce5c226..517e0001 100644 --- a/src/Users/index.ts +++ b/src/Users/index.ts @@ -64,6 +64,16 @@ export class Users { .post(`/users/delete/${deletionId}/confirm`, { deletion: params }), ); } + + /** + * List all known roles. + */ + roles(): Promise { + return unpackData( + this._client.authApiClient().get("/users/roles"), + "roles", + ); + } } export default Users; diff --git a/test/Users/index.test.js b/test/Users/index.test.js index adec5383..b52afd22 100644 --- a/test/Users/index.test.js +++ b/test/Users/index.test.js @@ -62,3 +62,14 @@ describe("Users#confirmAccountDeletion", () => { }, ); }); + +describe("Users#roles", () => { + testGetter( + "https://auth.scalingo.com/v1/users/roles", + null, + "roles", + (client) => { + return new Users(client).roles(); + }, + ); +});