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