public function testOpenIdConfig()
 {
     $container = ContainerLoader::buildTestContainer(array(__DIR__ . '/../../vendor/symfony/symfony/src/Symfony/Bundle/SecurityBundle/Resources/config/security.xml'));
     $controller = new AuthorizeController();
     $controller->setContainer($container);
     $clientId = 'test-client-' . rand();
     $server = $container->get('oauth2.server');
     $server->getStorage('client_credentials')->setClientDetails($clientId, 'test-client-secret', 'http://brentertainment.com');
     $request = new Request(array('client_id' => $clientId, 'response_type' => 'code', 'scope' => 'openid', 'state' => 'xyz', 'foo' => 'bar', 'nonce' => '123'));
     $container->set('oauth2.request', $request);
     $params = $controller->validateAuthorizeAction();
     $this->assertArrayHasKey('nonce', $params['qs'], 'optional included param');
     $this->assertArrayNotHasKey('foo', $params['qs'], 'invalid included param');
     $this->assertArrayNotHasKey('redirect_uri', $params['qs'], 'optional excluded param');
     $loader = new \Twig_Loader_Filesystem(__DIR__ . '/../../Resources/views');
     $twig = new \Twig_Environment($loader);
     $template = $twig->loadTemplate('Authorize/authorize.html.twig');
     $html = $template->render($params);
     $this->assertContains(htmlentities(http_build_query($params['qs'])), $html);
 }
 /**
  * @Route("/openid/connect/authorize", name="_authorize_validate")
  * @Method({"GET"})
  * @Template("OAuth2ServerBundle:Authorize:authorize.html.twig")
  */
 public function validateAuthorizeAction()
 {
     $request = $this->getRequest();
     $client = $this->getClient($request);
     if ($client instanceof \FOS\OAuthServerBundle\Model\ClientInterface) {
         $event = $this->get('event_dispatcher')->dispatch(OAuthEvent::PRE_AUTHORIZATION_PROCESS, new OAuthEvent($this->getUser(), $client));
         $server = $this->get('oauth2.server');
         if ($event->isAuthorizedClient()) {
             return $this->handleAuthorize($server, $event->isAuthorizedClient());
         }
     }
     return parent::validateAuthorizeAction();
 }
 /**
  * @Route("/openid/connect/authorize", name="_authorize_validate")
  * @Method({"GET"})
  * @Template("OAuth2ServerBundle:Authorize:authorize.html.twig")
  */
 public function validateAuthorizeAction()
 {
     $request = $this->getRequest();
     $id = explode('_', $request->get('client_id'));
     $em = $this->getDoctrine()->getManager();
     $client = $em->getRepository('PROCERGSOAuthBundle:Client')->find($id[0]);
     $event = $this->get('event_dispatcher')->dispatch(OAuthEvent::PRE_AUTHORIZATION_PROCESS, new OAuthEvent($this->getUser(), $client));
     $server = $this->get('oauth2.server');
     if ($event->isAuthorizedClient()) {
         return $this->handleAuthorize($server, $event->isAuthorizedClient());
     }
     return parent::validateAuthorizeAction();
 }