@@ -222,6 +222,7 @@ public function testLoginQuery(): void
222
222
mutation login {
223
223
login(userName: "foo", password: "bar") {
224
224
userName
225
+ roles
225
226
}
226
227
} ' ]);
227
228
@@ -232,7 +233,10 @@ public function testLoginQuery(): void
232
233
$ this ->assertSame ([
233
234
'data ' => [
234
235
'login ' => [
235
- 'userName ' => 'foo '
236
+ 'userName ' => 'foo ' ,
237
+ 'roles ' => [
238
+ 'ROLE_USER '
239
+ ]
236
240
]
237
241
]
238
242
], $ result );
@@ -298,6 +302,14 @@ public function testForceLoginNoSession(): void
298
302
$ kernel ->boot ();
299
303
}
300
304
305
+ public function testForceMeNoSecurity (): void
306
+ {
307
+ $ kernel = new GraphqliteTestingKernel (false , 'off ' , false , 'on ' );
308
+ $ this ->expectException (GraphQLException::class);
309
+ $ this ->expectExceptionMessage ('In order to enable the "me" query (via the graphqlite.security.enable_me parameter), you need to install the security bundle. ' );
310
+ $ kernel ->boot ();
311
+ }
312
+
301
313
public function testForceLoginNoSecurity (): void
302
314
{
303
315
$ kernel = new GraphqliteTestingKernel (true , 'on ' , false );
@@ -306,6 +318,63 @@ public function testForceLoginNoSecurity(): void
306
318
$ kernel ->boot ();
307
319
}
308
320
321
+ /*public function testAutoMeNoSecurity(): void
322
+ {
323
+ $kernel = new GraphqliteTestingKernel(true, null, false);
324
+ $kernel->boot();
325
+
326
+ $session = new Session(new MockArraySessionStorage());
327
+ $container = $kernel->getContainer();
328
+ $container->set('session', $session);
329
+
330
+ $request = Request::create('/graphql', 'POST', ['query' => '
331
+ {
332
+ me {
333
+ userName
334
+ roles
335
+ }
336
+ }
337
+ ']);
338
+
339
+ $response = $kernel->handle($request);
340
+
341
+ $result = json_decode($response->getContent(), true);
342
+
343
+ $this->assertSame([
344
+ 'data' => [
345
+ 'me' => [
346
+ 'userName' => 'anon.',
347
+ 'roles' => [],
348
+ ]
349
+ ]
350
+ ], $result);
351
+ }*/
352
+
353
+ public function testAllOff (): void
354
+ {
355
+ $ kernel = new GraphqliteTestingKernel (true , 'off ' , true , 'off ' );
356
+ $ kernel ->boot ();
357
+
358
+ $ session = new Session (new MockArraySessionStorage ());
359
+ $ container = $ kernel ->getContainer ();
360
+ $ container ->set ('session ' , $ session );
361
+
362
+ $ request = Request::create ('/graphql ' , 'POST ' , ['query ' => '
363
+ {
364
+ me {
365
+ userName
366
+ roles
367
+ }
368
+ }
369
+ ' ]);
370
+
371
+ $ response = $ kernel ->handle ($ request );
372
+
373
+ $ result = json_decode ($ response ->getContent (), true );
374
+
375
+ $ this ->assertSame ('Cannot query field "me" on type "Query". ' , $ result ['errors ' ][0 ]['message ' ]);
376
+ }
377
+
309
378
private function logIn (ContainerInterface $ container )
310
379
{
311
380
// put a token into the storage so the final calls can function
0 commit comments