Neos\Flow\Tests\Unit\Security\ContextTest::isCsrfProtectionTokenValidChecksIfTheGivenTokenIsExistingInTheContextAndUnsetsItIfTheCsrfStrategyIsOnePerUri PHP Метод

isCsrfProtectionTokenValidChecksIfTheGivenTokenIsExistingInTheContextAndUnsetsItIfTheCsrfStrategyIsOnePerUri() публичный Метод

    public function isCsrfProtectionTokenValidChecksIfTheGivenTokenIsExistingInTheContextAndUnsetsItIfTheCsrfStrategyIsOnePerUri()
    {
        $mockAuthenticationManager = $this->createMock(AuthenticationManagerInterface::class);
        $existingTokens = ['csrfToken12345' => true];
        /** @var Context $securityContext */
        $securityContext = $this->getAccessibleMock(Context::class, ['initialize']);
        $securityContext->setRequest($this->mockActionRequest);
        $securityContext->_set('authenticationManager', $mockAuthenticationManager);
        $securityContext->_set('csrfProtectionTokens', $existingTokens);
        $securityContext->_set('csrfProtectionStrategy', Context::CSRF_ONE_PER_URI);
        $this->assertTrue($securityContext->isCsrfProtectionTokenValid('csrfToken12345'));
        $this->assertFalse($securityContext->isCsrfProtectionTokenValid('csrfToken12345'));
    }
ContextTest