PHP Class Neos\Flow\Tests\Unit\Security\ContextTest

Inheritance: extends Neos\Flow\Tests\UnitTestCase
Show file Open project: neos/flow-development-collection

Protected Properties

Property Type Description
$mockActionRequest Neos\Flow\Mvc\ActionRequest
$mockAuthenticationManager Neos\Flow\Security\Authentication\AuthenticationManagerInterface
$securityContext Neos\Flow\Security\Context

Public Methods

Method Description
authenticationStrategies ( ) : array Data provider for authentication strategy settings
authenticationStrategyIsSetCorrectlyFromConfiguration ( $settings, $expectedAuthenticationStrategy )
authorizationChecksAreEnabledByDefault ( )
csrfProtectionStrategies ( ) : array Data provider for CSRF protection strategy settings
csrfProtectionStrategyIsSetCorrectlyFromConfiguration ( $settings, $expectedCsrfProtectionStrategy )
currentRequestIsSetInTheSecurityContext ( )
getAccountByAuthenticationProviderNameReturnsNullIfNoAccountFound ( )
getAccountByAuthenticationProviderNameReturnsTheAuthenticatedAccountWithGivenProviderName ( )
getAccountReturnsTheAccountAttachedToTheFirstAuthenticatedToken ( )
getContextHashInitializesSecurityContext ( )
getContextHashReturnsAHashOverAllAuthenticatedRoles ( )
getContextHashReturnsStaticStringIfAuthorizationChecksAreDisabled ( )
getContextHashReturnsStaticStringIfSecurityContextCantBeInitialized ( )
getCsrfProtectionTokenReturnsANewTokenIfNoneIsPresentInTheContext ( )
getCsrfProtectionTokenReturnsANewTokenIfTheCsrfStrategyIsOnePerUri ( )
getRolesReturnsTheAnonymousRoleIfNoTokenIsAuthenticated ( )
getRolesReturnsTheAuthenticatedUserRoleIfATokenIsAuthenticated ( )
getRolesReturnsTheCorrectRoles ( )
getRolesReturnsTheEverybodyRoleEvenIfNoTokenIsAuthenticated ( )
getRolesTakesInheritanceOfRolesIntoAccount ( )
hasRoleReturnsFalseForAnonymousRoleIfAuthenticated ( )
hasRoleReturnsTrueForAnonymousRoleIfNotAuthenticated ( )
hasRoleReturnsTrueForEverybodyRole ( )
hasRoleWorks ( )
hasRoleWorksWithRecursiveRoles ( )
initializeCallsUpdateCredentialsOnAllActiveTokens ( )
initializeSeparatesActiveAndInactiveTokens ( )
initializeUpdatesAndSeparatesActiveAndInactiveTokensCorrectly ( )
injectAuthenticationManagerSetsAReferenceToTheSecurityContextInTheAuthenticationManager ( )
invalidAuthenticationStrategyFromConfigurationThrowsException ( )
invalidCsrfProtectionStrategyFromConfigurationThrowsException ( )
isCsrfProtectionTokenValidChecksIfTheGivenTokenIsExistingInTheContext ( )
isCsrfProtectionTokenValidChecksIfTheGivenTokenIsExistingInTheContextAndUnsetsItIfTheCsrfStrategyIsOnePerUri ( )
securityContextCallsTheAuthenticationManagerToSetItsTokens ( )
securityContextIsNotInitializedAgainIfItHasBeenInitializedAlready ( ) initialize() might be called multiple times during one request. This might override roles and other data acquired from tokens / accounts, which have been initialized in a previous initialize() call. Therefore - and in order to save some processor cycles - initialization should only by executed once for a Context instance.
securityContextIsSetToInitialized ( )
separateActiveAndInactiveTokensDataProvider ( ) : array
separateActiveAndInactiveTokensTests ( array $patterns, boolean $expectedActive )
setUp ( ) Sets up this test case
tokenFromAnAuthenticationManagerIsReplacedIfThereIsOneOfTheSameTypeInTheSession ( )
withoutAuthorizationChecksDisabledAuthorizationChecks ( )
withoutAuthorizationChecksReactivatesAuthorizationCheckCorrectlyWhenCalledNested ( )
withoutAuthorizationChecksReactivatesAuthorizationChecksAfterClosureInvocation ( )
withoutAuthorizationChecksReactivatesAuthorizationChecksAfterClosureInvocationIfClosureThrowsException ( )

Method Details

authenticationStrategies() public method

Data provider for authentication strategy settings
public authenticationStrategies ( ) : array
return array

authenticationStrategyIsSetCorrectlyFromConfiguration() public method

public authenticationStrategyIsSetCorrectlyFromConfiguration ( $settings, $expectedAuthenticationStrategy )

authorizationChecksAreEnabledByDefault() public method

csrfProtectionStrategies() public method

Data provider for CSRF protection strategy settings
public csrfProtectionStrategies ( ) : array
return array

csrfProtectionStrategyIsSetCorrectlyFromConfiguration() public method

public csrfProtectionStrategyIsSetCorrectlyFromConfiguration ( $settings, $expectedCsrfProtectionStrategy )

currentRequestIsSetInTheSecurityContext() public method

getAccountByAuthenticationProviderNameReturnsNullIfNoAccountFound() public method

getAccountByAuthenticationProviderNameReturnsTheAuthenticatedAccountWithGivenProviderName() public method

getAccountReturnsTheAccountAttachedToTheFirstAuthenticatedToken() public method

getContextHashInitializesSecurityContext() public method

getContextHashReturnsAHashOverAllAuthenticatedRoles() public method

getContextHashReturnsStaticStringIfAuthorizationChecksAreDisabled() public method

getContextHashReturnsStaticStringIfSecurityContextCantBeInitialized() public method

getCsrfProtectionTokenReturnsANewTokenIfNoneIsPresentInTheContext() public method

getCsrfProtectionTokenReturnsANewTokenIfTheCsrfStrategyIsOnePerUri() public method

getRolesReturnsTheAnonymousRoleIfNoTokenIsAuthenticated() public method

getRolesReturnsTheAuthenticatedUserRoleIfATokenIsAuthenticated() public method

getRolesReturnsTheCorrectRoles() public method

getRolesReturnsTheEverybodyRoleEvenIfNoTokenIsAuthenticated() public method

getRolesTakesInheritanceOfRolesIntoAccount() public method

hasRoleReturnsFalseForAnonymousRoleIfAuthenticated() public method

hasRoleReturnsTrueForAnonymousRoleIfNotAuthenticated() public method

hasRoleReturnsTrueForEverybodyRole() public method

hasRoleWorks() public method

public hasRoleWorks ( )

hasRoleWorksWithRecursiveRoles() public method

initializeCallsUpdateCredentialsOnAllActiveTokens() public method

initializeSeparatesActiveAndInactiveTokens() public method

initializeUpdatesAndSeparatesActiveAndInactiveTokensCorrectly() public method

injectAuthenticationManagerSetsAReferenceToTheSecurityContextInTheAuthenticationManager() public method

invalidAuthenticationStrategyFromConfigurationThrowsException() public method

invalidCsrfProtectionStrategyFromConfigurationThrowsException() public method

isCsrfProtectionTokenValidChecksIfTheGivenTokenIsExistingInTheContext() public method

isCsrfProtectionTokenValidChecksIfTheGivenTokenIsExistingInTheContextAndUnsetsItIfTheCsrfStrategyIsOnePerUri() public method

securityContextCallsTheAuthenticationManagerToSetItsTokens() public method

securityContextIsNotInitializedAgainIfItHasBeenInitializedAlready() public method

initialize() might be called multiple times during one request. This might override roles and other data acquired from tokens / accounts, which have been initialized in a previous initialize() call. Therefore - and in order to save some processor cycles - initialization should only by executed once for a Context instance.

securityContextIsSetToInitialized() public method

separateActiveAndInactiveTokensDataProvider() public method

separateActiveAndInactiveTokensTests() public method

public separateActiveAndInactiveTokensTests ( array $patterns, boolean $expectedActive )
$patterns array
$expectedActive boolean

setUp() public method

Sets up this test case
public setUp ( )

tokenFromAnAuthenticationManagerIsReplacedIfThereIsOneOfTheSameTypeInTheSession() public method

withoutAuthorizationChecksDisabledAuthorizationChecks() public method

withoutAuthorizationChecksReactivatesAuthorizationCheckCorrectlyWhenCalledNested() public method

withoutAuthorizationChecksReactivatesAuthorizationChecksAfterClosureInvocation() public method

withoutAuthorizationChecksReactivatesAuthorizationChecksAfterClosureInvocationIfClosureThrowsException() public method

Property Details

$mockActionRequest protected property

protected ActionRequest,Neos\Flow\Mvc $mockActionRequest
return Neos\Flow\Mvc\ActionRequest

$mockAuthenticationManager protected property

protected AuthenticationManagerInterface,Neos\Flow\Security\Authentication $mockAuthenticationManager
return Neos\Flow\Security\Authentication\AuthenticationManagerInterface

$securityContext protected property

protected Context,Neos\Flow\Security $securityContext
return Neos\Flow\Security\Context