/** * Sends the given HTTP request * * @param Http\Request $httpRequest * @return Http\Response * @throws Http\Exception * @api */ public function sendRequest(Http\Request $httpRequest) { $requestHandler = $this->bootstrap->getActiveRequestHandler(); if (!$requestHandler instanceof FunctionalTestRequestHandler) { throw new Http\Exception('The browser\'s internal request engine has only been designed for use within functional tests.', 1335523749); } $this->securityContext->clearContext(); $this->validatorResolver->reset(); $response = new Http\Response(); $componentContext = new ComponentContext($httpRequest, $response); $requestHandler->setComponentContext($componentContext); $objectManager = $this->bootstrap->getObjectManager(); $baseComponentChain = $objectManager->get(\Neos\Flow\Http\Component\ComponentChain::class); $componentContext = new ComponentContext($httpRequest, $response); try { $baseComponentChain->handle($componentContext); } catch (\Throwable $throwable) { $this->prepareErrorResponse($throwable, $componentContext->getHttpResponse()); } catch (\Exception $exception) { $this->prepareErrorResponse($exception, $componentContext->getHttpResponse()); } $session = $this->bootstrap->getObjectManager()->get(SessionInterface::class); if ($session->isStarted()) { $session->close(); } $this->persistenceManager->clearState(); return $componentContext->getHttpResponse(); }
/** * Prepares the environment for and conducts an account authentication * * @param \Neos\Flow\Security\Account $account * @return void * @api */ protected function authenticateAccount(\Neos\Flow\Security\Account $account) { $this->testingProvider->setAuthenticationStatus(\Neos\Flow\Security\Authentication\TokenInterface::AUTHENTICATION_SUCCESSFUL); $this->testingProvider->setAccount($account); $this->securityContext->clearContext(); $requestHandler = self::$bootstrap->getActiveRequestHandler(); $actionRequest = $this->route($requestHandler->getHttpRequest()); $this->securityContext->setRequest($actionRequest); $this->authenticationManager->authenticate(); }