@@ -2,12 +2,36 @@ import { expect, test } from "vitest";
22import { createJwt } from "./utils.js" ;
33import {
44 EntraActionResponse ,
5+ GroupGetResponse ,
56 GroupMemberGetResponse ,
67} from "../../src/common/types/iam.js" ;
78import { allAppRoles , AppRoles } from "../../src/common/roles.js" ;
89import { getBaseEndpoint } from "./utils.js" ;
910
1011const baseEndpoint = getBaseEndpoint ( ) ;
12+ test ( "getting groups" , async ( ) => {
13+ const token = await createJwt ( ) ;
14+ const response = await fetch ( `${ baseEndpoint } /api/v1/iam/groups` , {
15+ method : "GET" ,
16+ headers : {
17+ Authorization : `Bearer ${ token } ` ,
18+ "Content-Type" : "application/json" ,
19+ } ,
20+ } ) ;
21+ expect ( response . status ) . toBe ( 200 ) ;
22+ const responseJson = ( await response . json ( ) ) as GroupGetResponse ;
23+ expect ( responseJson . length ) . greaterThan ( 0 ) ;
24+ for ( const item of responseJson ) {
25+ expect ( item ) . toHaveProperty ( "displayName" ) ;
26+ expect ( item ) . toHaveProperty ( "id" ) ;
27+ expect ( item [ "displayName" ] . length ) . greaterThan ( 0 ) ;
28+ expect ( item [ "id" ] . length ) . greaterThan ( 0 ) ;
29+ expect ( item [ "id" ] . length ) . toMatch (
30+ / ^ [ 0 - 9 a - f A - F ] { 8 } - [ 0 - 9 a - f A - F ] { 4 } - 4 [ 0 - 9 a - f A - F ] { 3 } - [ 8 9 a b A B ] [ 0 - 9 a - f A - F ] { 3 } - [ 0 - 9 a - f A - F ] { 12 } $ / ,
31+ ) ;
32+ }
33+ } ) ;
34+
1135test ( "getting members of a group" , async ( ) => {
1236 const token = await createJwt ( ) ;
1337 const response = await fetch (
0 commit comments