diff --git a/TYPO3.Flow/Classes/TYPO3/Flow/Security/Context.php b/TYPO3.Flow/Classes/TYPO3/Flow/Security/Context.php index 2e0ecf018d..48054a484d 100644 --- a/TYPO3.Flow/Classes/TYPO3/Flow/Security/Context.php +++ b/TYPO3.Flow/Classes/TYPO3/Flow/Security/Context.php @@ -647,6 +647,7 @@ public function clearContext() { $this->request = NULL; $this->csrfProtectionTokens = array(); $this->interceptedRequest = NULL; + $this->authorizationChecksDisabled = FALSE; $this->initialized = FALSE; } diff --git a/TYPO3.Flow/Tests/FunctionalTestCase.php b/TYPO3.Flow/Tests/FunctionalTestCase.php index d44f36afed..8dc5bb1851 100644 --- a/TYPO3.Flow/Tests/FunctionalTestCase.php +++ b/TYPO3.Flow/Tests/FunctionalTestCase.php @@ -162,9 +162,7 @@ public function setUp() { $session->destroy(sprintf('assure that session is fresh, in setUp() method of functional test %s.', get_class($this) . '::' . $this->getName())); } - if ($this->testableSecurityEnabled === TRUE) { - $this->setupSecurity(); - } + $this->setupSecurity(); } /** @@ -175,30 +173,34 @@ public function setUp() { * @return void */ protected function setupSecurity() { - $this->privilegeManager = $this->objectManager->get('TYPO3\Flow\Security\Authorization\TestingPrivilegeManager'); - $this->privilegeManager->setOverrideDecision(NULL); + $this->securityContext = $this->objectManager->get('TYPO3\Flow\Security\Context'); + if ($this->testableSecurityEnabled) { + $this->privilegeManager = $this->objectManager->get('TYPO3\Flow\Security\Authorization\TestingPrivilegeManager'); + $this->privilegeManager->setOverrideDecision(NULL); - $this->policyService = $this->objectManager->get('TYPO3\Flow\Security\Policy\PolicyService'); + $this->policyService = $this->objectManager->get('TYPO3\Flow\Security\Policy\PolicyService'); - $this->authenticationManager = $this->objectManager->get('TYPO3\Flow\Security\Authentication\AuthenticationProviderManager'); + $this->authenticationManager = $this->objectManager->get('TYPO3\Flow\Security\Authentication\AuthenticationProviderManager'); - $this->testingProvider = $this->objectManager->get('TYPO3\Flow\Security\Authentication\Provider\TestingProvider'); - $this->testingProvider->setName('TestingProvider'); + $this->testingProvider = $this->objectManager->get('TYPO3\Flow\Security\Authentication\Provider\TestingProvider'); + $this->testingProvider->setName('TestingProvider'); - $this->registerRoute('functionaltestroute', 'typo3/flow/test', array( - '@package' => 'TYPO3.Flow', - '@subpackage' => 'Tests\Functional\Mvc\Fixtures', - '@controller' => 'Standard', - '@action' => 'index', - '@format' => 'html' - )); + $this->registerRoute('functionaltestroute', 'typo3/flow/test', array( + '@package' => 'TYPO3.Flow', + '@subpackage' => 'Tests\Functional\Mvc\Fixtures', + '@controller' => 'Standard', + '@action' => 'index', + '@format' => 'html' + )); - $requestHandler = self::$bootstrap->getActiveRequestHandler(); - $actionRequest = $this->route($requestHandler->getHttpRequest()); + $requestHandler = self::$bootstrap->getActiveRequestHandler(); + $actionRequest = $this->route($requestHandler->getHttpRequest()); - $this->securityContext = $this->objectManager->get('TYPO3\Flow\Security\Context'); - $this->securityContext->clearContext(); - $this->securityContext->setRequest($actionRequest); + $this->securityContext->clearContext(); + $this->securityContext->setRequest($actionRequest); + } else { + \TYPO3\Flow\Reflection\ObjectAccess::setProperty($this->securityContext, 'authorizationChecksDisabled', TRUE, TRUE); + } } /** @@ -227,9 +229,7 @@ protected function route(Request $httpRequest) { * @return void */ public function tearDown() { - if ($this->testableSecurityEnabled === TRUE) { - $this->tearDownSecurity(); - } + $this->tearDownSecurity(); $persistenceManager = self::$bootstrap->getObjectManager()->get('TYPO3\Flow\Persistence\PersistenceManagerInterface'); @@ -273,7 +273,10 @@ protected function tearDownSecurity() { if ($this->securityContext !== NULL) { $this->securityContext->clearContext(); } - \TYPO3\Flow\Reflection\ObjectAccess::setProperty($this->authenticationManager, 'isAuthenticated', NULL, TRUE); + if ($this->authenticationManager !== NULL) { + \TYPO3\Flow\Reflection\ObjectAccess::setProperty($this->authenticationManager, 'isAuthenticated', NULL, TRUE); + } + } /**