16
16
class AuthenticatorTest extends TestCase {
17
17
public function testConstructWithDefaultSessionNotStarted () {
18
18
self ::expectException (SessionNotStartedException::class);
19
- new Authenticator ("test-key " ,"/ " );
19
+ new Authenticator (
20
+ "example-app-id " ,
21
+ "test-key " ,
22
+ "/ "
23
+ );
20
24
}
21
25
22
26
public function testConstructWithDefaultSession () {
23
27
$ _SESSION = [];
24
- new Authenticator ("test-key " , "/ " );
28
+ new Authenticator (
29
+ "example-app-id " ,
30
+ "test-key " ,
31
+ "/ "
32
+ );
25
33
self ::assertArrayHasKey (
26
34
Authenticator::SESSION_KEY ,
27
35
$ _SESSION
@@ -31,6 +39,7 @@ public function testConstructWithDefaultSession() {
31
39
public function testIsLoggedInFalseByDefault () {
32
40
$ _SESSION = [];
33
41
$ sut = new Authenticator (
42
+ "example-app-id " ,
34
43
"test-key " ,
35
44
"/ "
36
45
);
@@ -49,8 +58,9 @@ public function testIsLoggedInTrueWhenSessionDataSet() {
49
58
];
50
59
51
60
$ sut = new Authenticator (
61
+ "example-app-id " ,
52
62
"test-key " ,
53
- "/ " ,
63
+ "/ "
54
64
);
55
65
self ::assertTrue ($ sut ->isLoggedIn ());
56
66
}
@@ -62,8 +72,9 @@ public function testLogoutClearsSession() {
62
72
];
63
73
64
74
$ sut = new Authenticator (
75
+ "example-app-id " ,
65
76
"test-key " ,
66
- "/ " ,
77
+ "/ "
67
78
);
68
79
$ sut ->logout ();
69
80
self ::assertEmpty ($ _SESSION );
@@ -76,13 +87,14 @@ public function testLoginRedirects() {
76
87
$ redirectHandler ->expects (self ::once ())
77
88
->method ("redirect " )
78
89
->with (self ::callback (fn (UriInterface $ uri ) =>
79
- $ uri ->getHost () === AuthUri::DEFAULT_BASE_URI
90
+ $ uri ->getHost () === AuthUri::DEFAULT_BASE_REMOTE_URI
80
91
));
81
92
82
93
$ sut = new Authenticator (
94
+ "example-app-id " ,
83
95
"test-key " ,
84
96
"/ " ,
85
- AuthUri::DEFAULT_BASE_URI ,
97
+ AuthUri::DEFAULT_BASE_REMOTE_URI ,
86
98
null ,
87
99
$ redirectHandler
88
100
);
@@ -102,6 +114,7 @@ public function testLoginRedirectsLocalhost() {
102
114
));
103
115
104
116
$ sut = new Authenticator (
117
+ "example-app-id " ,
105
118
"test-key " ,
106
119
"/ " ,
107
120
"http://localhost:8081 " ,
@@ -117,6 +130,7 @@ public function testLoginRedirectsWithCorrectQueryString() {
117
130
$ key = uniqid ("key- " );
118
131
$ currentPath = uniqid ("/path/ " );
119
132
133
+ $ id = "example-app-id " ;
120
134
$ cipher = "example-cipher " ;
121
135
$ ivString = "example-iv " ;
122
136
@@ -131,6 +145,7 @@ public function testLoginRedirectsWithCorrectQueryString() {
131
145
->willReturn ($ iv );
132
146
133
147
$ expectedQueryParts = [
148
+ AuthUri::QUERY_STRING_ID => $ id ,
134
149
AuthUri::QUERY_STRING_CIPHER => $ cipher ,
135
150
AuthUri::QUERY_STRING_INIT_VECTOR => $ ivString ,
136
151
AuthUri::QUERY_STRING_CURRENT_PATH => $ currentPath ,
@@ -145,9 +160,10 @@ public function testLoginRedirectsWithCorrectQueryString() {
145
160
));
146
161
147
162
$ sut = new Authenticator (
163
+ $ id ,
148
164
$ key ,
149
165
$ currentPath ,
150
- AuthUri::DEFAULT_BASE_URI ,
166
+ AuthUri::DEFAULT_BASE_REMOTE_URI ,
151
167
null ,
152
168
$ redirectHandler
153
169
);
@@ -165,9 +181,10 @@ public function testLoginDoesNothingWhenAlreadyLoggedIn() {
165
181
->method ("redirect " );
166
182
167
183
$ sut = new Authenticator (
184
+ "example-app-id " ,
168
185
"test-key " ,
169
186
"/ " ,
170
- AuthUri::DEFAULT_BASE_URI ,
187
+ AuthUri::DEFAULT_BASE_REMOTE_URI ,
171
188
null ,
172
189
$ redirectHandler
173
190
);
@@ -178,6 +195,7 @@ public function testLoginDoesNothingWhenAlreadyLoggedIn() {
178
195
public function testGetUuidThrowsExceptionWhenNotLoggedIn () {
179
196
$ _SESSION = [];
180
197
$ sut = new Authenticator (
198
+ "example-app-id " ,
181
199
"test-key " ,
182
200
"/ "
183
201
);
@@ -199,6 +217,7 @@ public function testGetUuid() {
199
217
Authenticator::SESSION_KEY => $ sessionData ,
200
218
];
201
219
$ sut = new Authenticator (
220
+ "example-app-id " ,
202
221
"test-key " ,
203
222
"/ "
204
223
);
@@ -208,6 +227,7 @@ public function testGetUuid() {
208
227
public function testGetEmailThrowsExceptionWhenNotLoggedIn () {
209
228
$ _SESSION = [];
210
229
$ sut = new Authenticator (
230
+ "example-app-id " ,
211
231
"test-key " ,
212
232
"/ "
213
233
);
@@ -229,6 +249,7 @@ public function testGetEmail() {
229
249
Authenticator::SESSION_KEY => $ sessionData ,
230
250
];
231
251
$ sut = new Authenticator (
252
+ "example-app-id " ,
232
253
"test-key " ,
233
254
"/ "
234
255
);
@@ -243,6 +264,7 @@ public function testCompleteAuthNotLoggedIn() {
243
264
$ _SESSION = [];
244
265
self ::expectException (NotLoggedInException::class);
245
266
new Authenticator (
267
+ "example-app-id " ,
246
268
"test-key " ,
247
269
$ currentUri
248
270
);
@@ -275,9 +297,10 @@ public function testCompleteAuth() {
275
297
Authenticator::SESSION_KEY => $ sessionData ,
276
298
];
277
299
new Authenticator (
300
+ "example-app-id " ,
278
301
"test-key " ,
279
302
$ currentUri ,
280
- AuthUri::DEFAULT_BASE_URI ,
303
+ AuthUri::DEFAULT_BASE_REMOTE_URI ,
281
304
null ,
282
305
$ redirectHandler
283
306
);
@@ -302,9 +325,10 @@ public function testCompleteAuthNotAffectedByQueryString() {
302
325
$ _SESSION = [];
303
326
304
327
new Authenticator (
328
+ "example-app-id " ,
305
329
"test-key " ,
306
330
"/example-path?filter=something " ,
307
- AuthUri::DEFAULT_BASE_URI ,
331
+ AuthUri::DEFAULT_BASE_REMOTE_URI ,
308
332
null ,
309
333
$ redirectHandler
310
334
);
0 commit comments