@@ -222,6 +222,7 @@ public function testLoginQuery(): void
222222 mutation login {
223223 login(userName: "foo", password: "bar") {
224224 userName
225+ roles
225226 }
226227 } ' ]);
227228
@@ -232,7 +233,10 @@ public function testLoginQuery(): void
232233 $ this ->assertSame ([
233234 'data ' => [
234235 'login ' => [
235- 'userName ' => 'foo '
236+ 'userName ' => 'foo ' ,
237+ 'roles ' => [
238+ 'ROLE_USER '
239+ ]
236240 ]
237241 ]
238242 ], $ result );
@@ -298,6 +302,14 @@ public function testForceLoginNoSession(): void
298302 $ kernel ->boot ();
299303 }
300304
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+
301313 public function testForceLoginNoSecurity (): void
302314 {
303315 $ kernel = new GraphqliteTestingKernel (true , 'on ' , false );
@@ -306,6 +318,63 @@ public function testForceLoginNoSecurity(): void
306318 $ kernel ->boot ();
307319 }
308320
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+
309378 private function logIn (ContainerInterface $ container )
310379 {
311380 // put a token into the storage so the final calls can function
0 commit comments