1
1
import {
2
- MOCK_NONCE_RESPONSE as SDK_MOCK_NONCE_RESPONSE ,
2
+ NONCE_URL ,
3
+ OIDC_TOKEN_URL , PAIR_SOCIAL_IDENTIFIER ,
4
+ SRP_LOGIN_URL ,
5
+ } from '../../../sdk/authentication-jwt-bearer/services' ;
6
+ import {
3
7
MOCK_JWT as SDK_MOCK_JWT ,
4
- MOCK_SRP_LOGIN_RESPONSE as SDK_MOCK_SRP_LOGIN_RESPONSE ,
8
+ MOCK_NONCE_RESPONSE as SDK_MOCK_NONCE_RESPONSE ,
5
9
MOCK_OIDC_TOKEN_RESPONSE as SDK_MOCK_OIDC_TOKEN_RESPONSE ,
6
- MOCK_NONCE_URL ,
7
- MOCK_SRP_LOGIN_URL ,
8
- MOCK_OIDC_TOKEN_URL ,
10
+ MOCK_SRP_LOGIN_RESPONSE as SDK_MOCK_SRP_LOGIN_RESPONSE ,
9
11
} from '../../../sdk/mocks/auth' ;
12
+ import { Env } from '../../../shared/env' ;
10
13
11
14
type MockResponse = {
12
15
url : string ;
13
16
requestMethod : 'GET' | 'POST' | 'PUT' ;
14
17
response : unknown ;
18
+ statusCode ?: number ;
15
19
} ;
16
20
17
21
export const MOCK_NONCE_RESPONSE = SDK_MOCK_NONCE_RESPONSE ;
18
22
export const MOCK_NONCE = MOCK_NONCE_RESPONSE . nonce ;
19
23
export const MOCK_JWT = SDK_MOCK_JWT ;
20
24
21
- export const getMockAuthNonceResponse = ( ) => {
25
+ export const getMockAuthNonceResponse = ( env : Env = Env . PRD ) => {
22
26
return {
23
- url : MOCK_NONCE_URL ,
27
+ url : NONCE_URL ( env ) ,
24
28
requestMethod : 'GET' ,
25
29
response : (
26
30
_ ?: unknown ,
@@ -34,7 +38,7 @@ export const getMockAuthNonceResponse = () => {
34
38
35
39
return {
36
40
...MOCK_NONCE_RESPONSE ,
37
- nonce : e2eIdentifier ?? MOCK_NONCE_RESPONSE . nonce ,
41
+ nonce : e2eIdentifier ?? MOCK_NONCE ,
38
42
identifier : MOCK_NONCE_RESPONSE . identifier ,
39
43
} ;
40
44
} ,
@@ -43,9 +47,9 @@ export const getMockAuthNonceResponse = () => {
43
47
44
48
export const MOCK_LOGIN_RESPONSE = SDK_MOCK_SRP_LOGIN_RESPONSE ;
45
49
46
- export const getMockAuthLoginResponse = ( ) => {
50
+ export const getMockAuthLoginResponse = ( env : Env = Env . PRD ) => {
47
51
return {
48
- url : MOCK_SRP_LOGIN_URL ,
52
+ url : SRP_LOGIN_URL ( env ) ,
49
53
requestMethod : 'POST' ,
50
54
// In case this mock is used in an E2E test, we populate token, profile_id and identifier_id with the e2eIdentifier
51
55
// to make it easier to segregate data in the test environment.
@@ -69,9 +73,9 @@ export const getMockAuthLoginResponse = () => {
69
73
70
74
export const MOCK_OATH_TOKEN_RESPONSE = SDK_MOCK_OIDC_TOKEN_RESPONSE ;
71
75
72
- export const getMockAuthAccessTokenResponse = ( ) => {
76
+ export const getMockAuthAccessTokenResponse = ( env : Env = Env . PRD ) => {
73
77
return {
74
- url : MOCK_OIDC_TOKEN_URL ,
78
+ url : OIDC_TOKEN_URL ( env ) ,
75
79
requestMethod : 'POST' ,
76
80
response : ( requestJsonBody ?: string ) => {
77
81
// We end up setting the access token to the e2eIdentifier in the test environment
@@ -88,3 +92,14 @@ export const getMockAuthAccessTokenResponse = () => {
88
92
} ,
89
93
} satisfies MockResponse ;
90
94
} ;
95
+
96
+ export const getMockPairSocialTokenResponse = ( env : Env = Env . PRD ) => {
97
+ return {
98
+ url : PAIR_SOCIAL_IDENTIFIER ( env ) ,
99
+ requestMethod : 'POST' ,
100
+ response : ( ) => {
101
+ return 'OK' ;
102
+ } ,
103
+ statusCode : 204 ,
104
+ } satisfies MockResponse ;
105
+ } ;
0 commit comments