/** * Sends the given HTTP request * * @param \TYPO3\FLOW3\Http\Request $request * @return \TYPO3\FLOW3\Http\Response * @throws \TYPO3\FLOW3\Http\Exception * @api */ public function sendRequest(Request $request) { $requestHandler = $this->bootstrap->getActiveRequestHandler(); if (!$requestHandler instanceof \TYPO3\FLOW3\Tests\FunctionalTestRequestHandler) { throw new \TYPO3\FLOW3\Http\Exception('The browser\'s internal request engine has only been designed for use within functional tests.', 1335523749); } $response = new Response(); $requestHandler->setHttpRequest($request); $requestHandler->setHttpResponse($response); try { $actionRequest = $this->router->route($request); $this->securityContext->clearContext(); $this->securityContext->injectRequest($actionRequest); $this->dispatcher->dispatch($actionRequest, $response); } catch (\Exception $exception) { $pathPosition = strpos($exception->getFile(), 'Packages/'); $filePathAndName = $pathPosition !== FALSE ? substr($exception->getFile(), $pathPosition) : $exception->getFile(); $exceptionCodeNumber = $exception->getCode() > 0 ? '#' . $exception->getCode() . ': ' : ''; $content = PHP_EOL . 'Uncaught Exception in FLOW3 ' . $exceptionCodeNumber . $exception->getMessage() . PHP_EOL; $content .= 'thrown in file ' . $filePathAndName . PHP_EOL; $content .= 'in line ' . $exception->getLine() . PHP_EOL . PHP_EOL; $content .= \TYPO3\FLOW3\Error\Debugger::getBacktraceCode($exception->getTrace(), FALSE, TRUE) . PHP_EOL; $response->setStatus(500); $response->setContent($content); $response->setHeader('X-FLOW3-ExceptionCode', $exceptionCodeNumber); $response->setHeader('X-FLOW3-ExceptionMessage', $exception->getMessage()); } return $response; }
/** * Prepares the environment for and conducts an account authentication * * @param \TYPO3\FLOW3\Security\Account $account * @return void * @api */ protected function authenticateAccount(\TYPO3\FLOW3\Security\Account $account) { $this->testingProvider->setAuthenticationStatus(\TYPO3\FLOW3\Security\Authentication\TokenInterface::AUTHENTICATION_SUCCESSFUL); $this->testingProvider->setAccount($account); $this->securityContext->clearContext(); $requestHandler = self::$bootstrap->getActiveRequestHandler(); $request = $requestHandler->getHttpRequest(); $actionRequest = $request->createActionRequest(); $this->securityContext->injectRequest($actionRequest); $this->authenticationManager->authenticate(); }