@@ -23,73 +23,86 @@ import { Operation } from './action_code_info';
23
23
describe ( 'ActionCodeURL' , ( ) => {
24
24
describe ( '_fromLink' , ( ) => {
25
25
it ( 'should parse correctly formatted links' , ( ) => {
26
- const continueUrl = 'https://www.example.com/path/to/file?a=1&b=2#c=3' ;
27
- const actionLink = 'https://www.example.com/finishSignIn?' +
28
- 'oobCode=CODE&mode=signIn&apiKey=API_KEY&' +
29
- 'continueUrl=' + encodeURIComponent ( continueUrl ) +
30
- '&languageCode=en&tenantId=TENANT_ID&state=bla' ;
31
- const actionCodeUrl = ActionCodeURL . _fromLink ( mockAuth , actionLink ) ;
32
- expect ( actionCodeUrl ! . operation ) . to . eq ( Operation . EMAIL_SIGNIN ) ;
33
- expect ( actionCodeUrl ! . code ) . to . eq ( 'CODE' ) ;
34
- expect ( actionCodeUrl ! . apiKey ) . to . eq ( 'API_KEY' ) ;
35
- // ContinueUrl should be decoded.
36
- expect ( actionCodeUrl ! . continueUrl ) . to . eq ( continueUrl ) ;
37
- expect ( actionCodeUrl ! . tenantId ) . to . eq ( 'TENANT_ID' ) ;
38
- expect ( actionCodeUrl ! . languageCode ) . to . eq ( 'en' ) ;
26
+ const continueUrl = 'https://www.example.com/path/to/file?a=1&b=2#c=3' ;
27
+ const actionLink =
28
+ 'https://www.example.com/finishSignIn?' +
29
+ 'oobCode=CODE&mode=signIn&apiKey=API_KEY&' +
30
+ 'continueUrl=' +
31
+ encodeURIComponent ( continueUrl ) +
32
+ '&languageCode=en&tenantId=TENANT_ID&state=bla' ;
33
+ const actionCodeUrl = ActionCodeURL . _fromLink ( mockAuth , actionLink ) ;
34
+ expect ( actionCodeUrl ! . operation ) . to . eq ( Operation . EMAIL_SIGNIN ) ;
35
+ expect ( actionCodeUrl ! . code ) . to . eq ( 'CODE' ) ;
36
+ expect ( actionCodeUrl ! . apiKey ) . to . eq ( 'API_KEY' ) ;
37
+ // ContinueUrl should be decoded.
38
+ expect ( actionCodeUrl ! . continueUrl ) . to . eq ( continueUrl ) ;
39
+ expect ( actionCodeUrl ! . tenantId ) . to . eq ( 'TENANT_ID' ) ;
40
+ expect ( actionCodeUrl ! . languageCode ) . to . eq ( 'en' ) ;
39
41
} ) ;
40
42
41
43
context ( 'operation' , ( ) => {
42
44
it ( 'should identitfy EMAIL_SIGNIN' , ( ) => {
43
- const actionLink = 'https://www.example.com/finishSignIn?' +
45
+ const actionLink =
46
+ 'https://www.example.com/finishSignIn?' +
44
47
'oobCode=CODE&mode=signIn&apiKey=API_KEY&' +
45
48
'languageCode=en' ;
46
49
const actionCodeUrl = ActionCodeURL . _fromLink ( mockAuth , actionLink ) ;
47
50
expect ( actionCodeUrl ! . operation ) . to . eq ( Operation . EMAIL_SIGNIN ) ;
48
51
} ) ;
49
52
50
53
it ( 'should identitfy VERIFY_AND_CHANGE_EMAIL' , ( ) => {
51
- const actionLink = 'https://www.example.com/finishSignIn?' +
54
+ const actionLink =
55
+ 'https://www.example.com/finishSignIn?' +
52
56
'oobCode=CODE&mode=verifyAndChangeEmail&apiKey=API_KEY&' +
53
57
'languageCode=en' ;
54
58
const actionCodeUrl = ActionCodeURL . _fromLink ( mockAuth , actionLink ) ;
55
- expect ( actionCodeUrl ! . operation ) . to . eq ( Operation . VERIFY_AND_CHANGE_EMAIL ) ;
59
+ expect ( actionCodeUrl ! . operation ) . to . eq (
60
+ Operation . VERIFY_AND_CHANGE_EMAIL
61
+ ) ;
56
62
} ) ;
57
63
58
64
it ( 'should identitfy VERIFY_EMAIL' , ( ) => {
59
- const actionLink = 'https://www.example.com/finishSignIn?' +
65
+ const actionLink =
66
+ 'https://www.example.com/finishSignIn?' +
60
67
'oobCode=CODE&mode=verifyEmail&apiKey=API_KEY&' +
61
68
'languageCode=en' ;
62
69
const actionCodeUrl = ActionCodeURL . _fromLink ( mockAuth , actionLink ) ;
63
70
expect ( actionCodeUrl ! . operation ) . to . eq ( Operation . VERIFY_EMAIL ) ;
64
71
} ) ;
65
72
66
73
it ( 'should identitfy RECOVER_EMAIL' , ( ) => {
67
- const actionLink = 'https://www.example.com/finishSignIn?' +
74
+ const actionLink =
75
+ 'https://www.example.com/finishSignIn?' +
68
76
'oobCode=CODE&mode=recoverEmail&apiKey=API_KEY&' +
69
77
'languageCode=en' ;
70
78
const actionCodeUrl = ActionCodeURL . _fromLink ( mockAuth , actionLink ) ;
71
79
expect ( actionCodeUrl ! . operation ) . to . eq ( Operation . RECOVER_EMAIL ) ;
72
80
} ) ;
73
81
74
82
it ( 'should identitfy PASSWORD_RESET' , ( ) => {
75
- const actionLink = 'https://www.example.com/finishSignIn?' +
83
+ const actionLink =
84
+ 'https://www.example.com/finishSignIn?' +
76
85
'oobCode=CODE&mode=resetPassword&apiKey=API_KEY&' +
77
86
'languageCode=en' ;
78
87
const actionCodeUrl = ActionCodeURL . _fromLink ( mockAuth , actionLink ) ;
79
88
expect ( actionCodeUrl ! . operation ) . to . eq ( Operation . PASSWORD_RESET ) ;
80
89
} ) ;
81
90
82
91
it ( 'should identitfy REVERT_SECOND_FACTOR_ADDITION' , ( ) => {
83
- const actionLink = 'https://www.example.com/finishSignIn?' +
92
+ const actionLink =
93
+ 'https://www.example.com/finishSignIn?' +
84
94
'oobCode=CODE&mode=revertSecondFactorAddition&apiKey=API_KEY&' +
85
95
'languageCode=en' ;
86
96
const actionCodeUrl = ActionCodeURL . _fromLink ( mockAuth , actionLink ) ;
87
- expect ( actionCodeUrl ! . operation ) . to . eq ( Operation . REVERT_SECOND_FACTOR_ADDITION ) ;
97
+ expect ( actionCodeUrl ! . operation ) . to . eq (
98
+ Operation . REVERT_SECOND_FACTOR_ADDITION
99
+ ) ;
88
100
} ) ;
89
101
} ) ;
90
102
91
103
it ( 'should work if there is a port number in the URL' , ( ) => {
92
- const actionLink = 'https://www.example.com:8080/finishSignIn?' +
104
+ const actionLink =
105
+ 'https://www.example.com:8080/finishSignIn?' +
93
106
'oobCode=CODE&mode=signIn&apiKey=API_KEY&state=bla' ;
94
107
const actionCodeUrl = ActionCodeURL . _fromLink ( mockAuth , actionLink ) ;
95
108
expect ( actionCodeUrl ! . operation ) . to . eq ( Operation . EMAIL_SIGNIN ) ;
@@ -101,7 +114,8 @@ describe('ActionCodeURL', () => {
101
114
} ) ;
102
115
103
116
it ( 'should ignore parameters after anchor' , ( ) => {
104
- const actionLink = 'https://www.example.com/finishSignIn?' +
117
+ const actionLink =
118
+ 'https://www.example.com/finishSignIn?' +
105
119
'oobCode=CODE1&mode=signIn&apiKey=API_KEY1&state=bla' +
106
120
'#oobCode=CODE2&mode=signIn&apiKey=API_KEY2&state=bla' ;
107
121
const actionCodeUrl = ActionCodeURL . _fromLink ( mockAuth , actionLink ) ;
@@ -120,24 +134,28 @@ describe('ActionCodeURL', () => {
120
134
} ) ;
121
135
122
136
it ( 'should handle invalid mode' , ( ) => {
123
- const actionLink = 'https://www.example.com/finishSignIn?oobCode=CODE&mode=INVALID_MODE&apiKey=API_KEY' ;
137
+ const actionLink =
138
+ 'https://www.example.com/finishSignIn?oobCode=CODE&mode=INVALID_MODE&apiKey=API_KEY' ;
124
139
expect ( ActionCodeURL . _fromLink ( mockAuth , actionLink ) ) . to . be . null ;
125
140
} ) ;
126
141
127
142
it ( 'should handle missing code' , ( ) => {
128
- const actionLink = 'https://www.example.com/finishSignIn?mode=signIn&apiKey=API_KEY' ;
143
+ const actionLink =
144
+ 'https://www.example.com/finishSignIn?mode=signIn&apiKey=API_KEY' ;
129
145
expect ( ActionCodeURL . _fromLink ( mockAuth , actionLink ) ) . to . be . null ;
130
146
} ) ;
131
147
132
148
it ( 'should handle missing API key' , ( ) => {
133
- const actionLink = 'https://www.example.com/finishSignIn?oobCode=CODE&mode=signIn' ;
149
+ const actionLink =
150
+ 'https://www.example.com/finishSignIn?oobCode=CODE&mode=signIn' ;
134
151
expect ( ActionCodeURL . _fromLink ( mockAuth , actionLink ) ) . to . be . null ;
135
152
} ) ;
136
153
137
154
it ( 'should handle missing mode' , ( ) => {
138
- const actionLink = 'https://www.example.com/finishSignIn?oobCode=CODE&apiKey=API_KEY' ;
155
+ const actionLink =
156
+ 'https://www.example.com/finishSignIn?oobCode=CODE&apiKey=API_KEY' ;
139
157
expect ( ActionCodeURL . _fromLink ( mockAuth , actionLink ) ) . to . be . null ;
140
158
} ) ;
141
159
} ) ;
142
- } ) ;
160
+ } ) ;
143
161
} ) ;
0 commit comments