File tree Expand file tree Collapse file tree 3 files changed +66
-0
lines changed Expand file tree Collapse file tree 3 files changed +66
-0
lines changed Original file line number Diff line number Diff line change 1+ import { expect , test , describe } from "vitest" ;
2+ import { createJwt } from "./utils" ;
3+ import { allAppRoles } from "../../src/common/roles" ;
4+
5+ const baseEndpoint = `https://core.aws.qa.acmuiuc.org` ;
6+
7+ describe ( "Role checking live API tests" , async ( ) => {
8+ const token = await createJwt ( ) ;
9+ test (
10+ "Test that auth is present on the GET route" ,
11+ { timeout : 10000 } ,
12+ async ( ) => {
13+ const response = await fetch ( `${ baseEndpoint } /api/v1/protected/` , {
14+ method : "GET" ,
15+ } ) ;
16+ expect ( response . status ) . toBe ( 403 ) ;
17+ } ,
18+ ) ;
19+ test ( "Test that getting metadata succeeds" , { timeout : 10000 } , async ( ) => {
20+ const response = await fetch ( `${ baseEndpoint } /api/v1/protected` , {
21+ method : "GET" ,
22+ headers : {
23+ Authorization : `Bearer ${ token } ` ,
24+ } ,
25+ } ) ;
26+ expect ( response . status ) . toBe ( 200 ) ;
27+ const responseBody = await response . json ( ) ;
28+ expect ( responseBody ) . toStrictEqual ( {
29+ 30+ roles : allAppRoles ,
31+ } ) ;
32+ } ) ;
33+ } ) ;
Original file line number Diff line number Diff line change 1+ import { expect , test , describe } from "vitest" ;
2+ import { createJwt } from "./utils" ;
3+
4+ const baseEndpoint = `https://core.aws.qa.acmuiuc.org` ;
5+
6+ describe ( "Tickets live API tests" , async ( ) => {
7+ const token = await createJwt ( ) ;
8+ test (
9+ "Test that auth is present on the GET route" ,
10+ { timeout : 10000 } ,
11+ async ( ) => {
12+ const response = await fetch ( `${ baseEndpoint } /api/v1/tickets/` , {
13+ method : "GET" ,
14+ } ) ;
15+ expect ( response . status ) . toBe ( 403 ) ;
16+ } ,
17+ ) ;
18+ test ( "Test that getting metadata succeeds" , { timeout : 10000 } , async ( ) => {
19+ const response = await fetch ( `${ baseEndpoint } /api/v1/tickets` , {
20+ method : "GET" ,
21+ headers : {
22+ Authorization : `Bearer ${ token } ` ,
23+ } ,
24+ } ) ;
25+ expect ( response . status ) . toBe ( 200 ) ;
26+ const responseBody = await response . json ( ) ;
27+ expect ( responseBody ) . toHaveProperty ( "merch" ) ;
28+ expect ( responseBody ) . toHaveProperty ( "tickets" ) ;
29+ expect ( Array . isArray ( responseBody [ "merch" ] ) ) . toBe ( true ) ;
30+ expect ( Array . isArray ( responseBody [ "tickets" ] ) ) . toBe ( true ) ;
31+ } ) ;
32+ } ) ;
Original file line number Diff line number Diff line change 22 "compilerOptions" : {
33 "target" : " ES2020" ,
44 "module" : " NodeNext" ,
5+ "moduleResolution" : " node" ,
56 "esModuleInterop" : true ,
67 "strict" : true ,
78 "skipLibCheck" : true ,
You can’t perform that action at this time.
0 commit comments