/**
  * @test
  */
 public function buildBackendUriCreatesAbsoluteUrisIfSpecified()
 {
     t3lib_div::_GETset(array('M' => 'moduleKey'));
     $this->mockRequest->expects($this->any())->method('getBaseURI')->will($this->returnValue('http://baseuri/' . TYPO3_mainDir));
     $this->uriBuilder->setCreateAbsoluteUri(TRUE);
     $expectedResult = 'http://baseuri/' . TYPO3_mainDir . 'mod.php?M=moduleKey';
     $actualResult = $this->uriBuilder->buildBackendUri();
     $this->assertSame($expectedResult, $actualResult);
 }
 /**
  * @test
  * @author Bastian Waidelich <*****@*****.**>
  */
 public function getPartialSourceReturnsContentOfDefaultPartialFileIfNoPartialExistsForTheSpecifiedFormat()
 {
     $partialRootPath = dirname(__FILE__) . '/Fixtures';
     $this->view->setPartialRootPath($partialRootPath);
     $this->mockRequest->expects($this->once())->method('getFormat')->will($this->returnValue('foo'));
     $expectedResult = file_get_contents($partialRootPath . '/LayoutFixture');
     $actualResult = $this->view->_call('getPartialSource', 'LayoutFixture');
     $this->assertEquals($expectedResult, $actualResult);
 }
 /**
  * @test
  */
 public function buildSetsFormatFromGetAndPostVariables()
 {
     $this->configuration['extensionName'] = 'SomeExtensionName';
     $this->configuration['pluginName'] = 'SomePluginName';
     $this->injectDependencies();
     $_GET = array('tx_someextensionname_somepluginname' => array('format' => 'GET'));
     $_POST = array('tx_someextensionname_somepluginname' => array('format' => 'POST'));
     $this->mockRequest->expects($this->at(7))->method('setFormat')->with('POST');
     $this->requestBuilder->build();
 }
Example #4
0
 /**
  * Builds the URI, backend flavour
  * The resulting URI is relative and starts with "mod.php".
  * The settings pageUid, pageType, noCache, useCacheHash & linkAccessRestrictedPages
  * will be ignored in the backend.
  *
  * @return string The URI
  */
 public function buildBackendUri()
 {
     if ($this->addQueryString === TRUE) {
         $arguments = t3lib_div::_GET();
         foreach ($this->argumentsToBeExcludedFromQueryString as $argumentToBeExcluded) {
             unset($arguments[$argumentToBeExcluded]);
         }
     } else {
         $arguments = array('M' => t3lib_div::_GET('M'), 'id' => t3lib_div::_GET('id'));
     }
     $arguments = t3lib_div::array_merge_recursive_overrule($arguments, $this->arguments);
     $arguments = $this->convertDomainObjectsToIdentityArrays($arguments);
     $this->lastArguments = $arguments;
     $uri = 'mod.php?' . http_build_query($arguments, NULL, '&');
     if ($this->section !== '') {
         $uri .= '#' . $this->section;
     }
     if ($this->createAbsoluteUri === TRUE) {
         $uri = $this->request->getBaseURI() . $uri;
     }
     return $uri;
 }
 /**
  * @test
  * @author Sebastian Kurfürst <*****@*****.**>
  */
 public function initiateSubRequestBuildsRequestProperly()
 {
     $controller = $this->getMock('Tx_Fluid_Core_Widget_AbstractWidgetController', array(), array(), '', FALSE);
     $this->viewHelper->_set('controller', $controller);
     // Initial Setup
     $widgetRequest = $this->getMock('Tx_Fluid_Core_Widget_WidgetRequest');
     $response = $this->getMock('Tx_Extbase_MVC_Web_Response');
     $this->objectManager->expects($this->at(0))->method('create')->with('Tx_Fluid_Core_Widget_WidgetRequest')->will($this->returnValue($widgetRequest));
     $this->objectManager->expects($this->at(1))->method('create')->with('Tx_Extbase_MVC_Web_Response')->will($this->returnValue($response));
     // Widget Context is set
     $widgetRequest->expects($this->once())->method('setWidgetContext')->with($this->widgetContext);
     // The namespaced arguments are passed to the sub-request
     // and the action name is exctracted from the namespace.
     $this->controllerContext->expects($this->once())->method('getRequest')->will($this->returnValue($this->request));
     $this->widgetContext->expects($this->once())->method('getWidgetIdentifier')->will($this->returnValue('widget-1'));
     $this->request->expects($this->once())->method('getArguments')->will($this->returnValue(array('k1' => 'k2', 'widget-1' => array('arg1' => 'val1', 'arg2' => 'val2', 'action' => 'myAction'))));
     $widgetRequest->expects($this->once())->method('setArguments')->with(array('arg1' => 'val1', 'arg2' => 'val2'));
     $widgetRequest->expects($this->once())->method('setControllerActionName')->with('myAction');
     // Controller is called
     $controller->expects($this->once())->method('processRequest')->with($widgetRequest, $response);
     $output = $this->viewHelper->_call('initiateSubRequest');
     // SubResponse is returned
     $this->assertSame($response, $output);
 }
Example #6
0
 /**
  * @test
  */
 public function isCachedReturnsTheValueWhichWasPreviouslySet()
 {
     $request = new Tx_Extbase_MVC_Web_Request();
     $request->setIsCached(TRUE);
     $this->assertTrue($request->isCached());
 }
 /**
  * Verify the request. Checks if there is an __hmac argument, and if yes, tries to validate and verify it.
  *
  * In the end, $request->setHmacVerified is set depending on the value.
  * @param \F3\FLOW3\MVC\Web\Request $request The request to verify
  * @return void
  * @author Sebastian Kurfürst <*****@*****.**>
  */
 public function verifyRequest(Tx_Extbase_MVC_Web_Request $request)
 {
     if (!$request->hasArgument('__hmac')) {
         $request->setHmacVerified(FALSE);
         return;
     }
     $hmac = $request->getArgument('__hmac');
     if (strlen($hmac) < 40) {
         throw new Tx_Extbase_Security_Exception_SyntacticallyWrongRequestHash('Request hash too short. This is a probably manipulation attempt!', 1255089361);
     }
     $serializedFieldNames = substr($hmac, 0, -40);
     // TODO: Constant for hash length needs to be introduced
     $hash = substr($hmac, -40);
     if ($this->hashService->validateHash($serializedFieldNames, $hash)) {
         $requestArguments = $request->getArguments();
         // Unset framework arguments
         unset($requestArguments['__referrer']);
         unset($requestArguments['__hmac']);
         if ($this->checkFieldNameInclusion($requestArguments, unserialize($serializedFieldNames))) {
             $request->setHmacVerified(TRUE);
         } else {
             $request->setHmacVerified(FALSE);
         }
     } else {
         $request->setHmacVerified(FALSE);
     }
 }
 /**
  * Builds and returns a controller
  *
  * @param Tx_Extbase_MVC_Web_Request $request
  * @return Tx_Extbase_MVC_Controller_ControllerInterface The prepared controller
  */
 protected function getPreparedController(Tx_Extbase_MVC_Web_Request $request)
 {
     $controllerObjectName = $request->getControllerObjectName();
     $controller = t3lib_div::makeInstance($controllerObjectName);
     if (!$controller instanceof Tx_Extbase_MVC_Controller_ControllerInterface) {
         throw new Tx_Extbase_MVC_Exception_InvalidController('Invalid controller "' . $request->getControllerObjectName() . '". The controller must implement the Tx_Extbase_MVC_Controller_ControllerInterface.', 1202921619);
     }
     $propertyMapper = t3lib_div::makeInstance('Tx_Extbase_Property_Mapper');
     $propertyMapper->injectReflectionService(self::$reflectionService);
     $controller->injectPropertyMapper($propertyMapper);
     $controller->injectSettings(is_array(self::$extbaseFrameworkConfiguration['settings']) ? self::$extbaseFrameworkConfiguration['settings'] : array());
     $flashMessageContainer = t3lib_div::makeInstance('Tx_Extbase_MVC_Controller_FlashMessages');
     // singleton
     $flashMessageContainer->reset();
     $controller->injectFlashMessageContainer($flashMessageContainer);
     $objectManager = t3lib_div::makeInstance('Tx_Extbase_Object_Manager');
     $validatorResolver = t3lib_div::makeInstance('Tx_Extbase_Validation_ValidatorResolver');
     $validatorResolver->injectObjectManager($objectManager);
     $validatorResolver->injectReflectionService(self::$reflectionService);
     $controller->injectValidatorResolver($validatorResolver);
     $controller->injectReflectionService(self::$reflectionService);
     $controller->injectObjectManager($objectManager);
     return $controller;
 }