1
1
import { describe , test , beforeAll , expect } from '@jest/globals' ;
2
2
import Chance from 'chance' ;
3
- import * as dotenv from 'dotenv' ;
4
3
5
4
import clients from '../../config/clients.json' ;
6
5
import { introspectEndpoint , tokenEndpoint , userInfoEndpoint } from '../../helpers' ;
7
6
import { Client , User } from '../../types' ;
7
+ import { oidcUserManagementUrl } from 'e2e/helpers/endpoints' ;
8
+ import { URL } from 'node:url' ;
8
9
9
10
describe ( 'User management' , ( ) => {
10
11
const chance = new Chance ( ) ;
@@ -19,15 +20,13 @@ describe('User management', () => {
19
20
let token : string ;
20
21
21
22
beforeAll ( ( ) => {
22
- dotenv . config ( ) ;
23
-
24
23
client = clients . find ( c => c . ClientId === 'password-flow-client-id' ) ;
25
24
} ) ;
26
25
27
26
test ( 'Get user from configuration' , async ( ) => {
28
27
const configUserId = 'user_with_all_claim_types' ;
29
28
const configUsername = 'user_with_all_claim_types' ;
30
- const response = await fetch ( ` ${ process . env . OIDC_MANAGE_USERS_URL } /${ configUserId } `) ;
29
+ const response = await fetch ( new URL ( ` /${ configUserId } `, oidcUserManagementUrl ) ) ;
31
30
expect ( response . status ) . toBe ( 200 ) ;
32
31
const receivedUser = ( await response . json ( ) ) as User ;
33
32
expect ( receivedUser ) . toHaveProperty ( 'username' , configUsername ) ;
@@ -61,7 +60,7 @@ describe('User management', () => {
61
60
} ,
62
61
] ,
63
62
} ;
64
- const response = await fetch ( process . env . OIDC_MANAGE_USERS_URL , {
63
+ const response = await fetch ( oidcUserManagementUrl , {
65
64
method : 'POST' ,
66
65
body : JSON . stringify ( user ) ,
67
66
headers : { 'Content-Type' : 'application/json' } ,
@@ -72,7 +71,7 @@ describe('User management', () => {
72
71
} ) ;
73
72
74
73
test ( 'Get user' , async ( ) => {
75
- const response = await fetch ( ` ${ process . env . OIDC_MANAGE_USERS_URL } /${ subjectId } `) ;
74
+ const response = await fetch ( new URL ( ` /${ subjectId } `, oidcUserManagementUrl ) ) ;
76
75
expect ( response . status ) . toBe ( 200 ) ;
77
76
const receivedUser = ( await response . json ( ) ) as User ;
78
77
expect ( receivedUser ) . toHaveProperty ( 'username' , username ) ;
0 commit comments