예제 #1
0
 protected function setUp()
 {
     $this->strategy = $this->getMockForAbstractClass('Symfony\\Component\\Security\\Acl\\Model\\PermissionGrantingStrategyInterface');
     $this->baseProvider = $this->getMockBuilder('Oro\\Bundle\\SecurityBundle\\Acl\\Dbal\\MutableAclProvider')->disableOriginalConstructor()->getMock();
     $this->provider = new RootBasedAclProvider(new ObjectIdentityFactory(TestHelper::get($this)->createAclExtensionSelector()));
     $this->provider->setBaseAclProvider($this->baseProvider);
 }
 protected function setUp()
 {
     if (!class_exists('Doctrine\\DBAL\\DriverManager')) {
         $this->markTestSkipped('The Doctrine2 DBAL is required for this test');
     }
     $this->ownerTree = new OwnerTree();
     $this->metadataProvider = new OwnershipMetadataProviderStub($this);
     $objectIdAccessor = new ObjectIdAccessor();
     $treeProviderMock = $this->getMockBuilder('Oro\\Bundle\\SecurityBundle\\Owner\\OwnerTreeProvider')->disableOriginalConstructor()->getMock();
     $treeProviderMock->expects($this->any())->method('getTree')->will($this->returnValue($this->ownerTree));
     $decisionMaker = new EntityOwnershipDecisionMaker($treeProviderMock, $objectIdAccessor, new EntityOwnerAccessor($this->metadataProvider), $this->metadataProvider);
     $this->strategy = new PermissionGrantingStrategy($decisionMaker, $this->metadataProvider);
     $this->selector = TestHelper::get($this)->createAclExtensionSelector($this->metadataProvider);
     $this->context = new PermissionGrantingStrategyContext($this->selector);
     $contextLink = $this->getMockBuilder('Oro\\Bundle\\EntityConfigBundle\\DependencyInjection\\Utils\\ServiceLink')->disableOriginalConstructor()->getMock();
     $contextLink->expects($this->any())->method('getService')->will($this->returnValue($this->context));
     $this->strategy->setContext($contextLink);
     $user = new User(1);
     $this->sid = new UserSecurityIdentity('TestUser', get_class($user));
     $token = $this->getMock('Symfony\\Component\\Security\\Core\\Authentication\\Token\\TokenInterface');
     $token->expects($this->any())->method('getUser')->will($this->returnValue($user));
     $this->context->setSecurityToken($token);
     $this->context->setObject(new TestEntity('testId'));
     $this->map = new PermissionMap($this->selector);
 }
 protected function setUp()
 {
     if (!class_exists('Doctrine\\DBAL\\DriverManager')) {
         $this->markTestSkipped('The Doctrine2 DBAL is required for this test');
     }
     $this->ownerTree = new OwnerTree();
     $this->metadataProvider = new OwnershipMetadataProviderStub($this);
     $objectIdAccessor = new ObjectIdAccessor();
     /** @var \PHPUnit_Framework_MockObject_MockObject|OwnerTreeProvider $treeProviderMock */
     $treeProviderMock = $this->getMockBuilder('Oro\\Bundle\\SecurityBundle\\Owner\\OwnerTreeProvider')->disableOriginalConstructor()->getMock();
     $treeProviderMock->expects($this->any())->method('getTree')->will($this->returnValue($this->ownerTree));
     $configProvider = $this->getMockBuilder('Oro\\Bundle\\EntityConfigBundle\\Provider\\ConfigProvider')->disableOriginalConstructor()->getMock();
     $configProvider->expects($this->any())->method('hasConfig')->willReturn(false);
     $this->container = $this->getMock('Symfony\\Component\\DependencyInjection\\ContainerInterface');
     $this->container->expects($this->any())->method('get')->will($this->returnValueMap([['oro_security.ownership_tree_provider.chain', ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, $treeProviderMock], ['oro_security.owner.metadata_provider.chain', ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, $this->metadataProvider], ['oro_security.acl.object_id_accessor', ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, $objectIdAccessor], ['oro_security.owner.entity_owner_accessor', ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, new EntityOwnerAccessor($this->metadataProvider)], ['oro_entity_config.provider.security', ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, $configProvider]]));
     $decisionMaker = new EntityOwnershipDecisionMaker($treeProviderMock, $objectIdAccessor, new EntityOwnerAccessor($this->metadataProvider), $this->metadataProvider);
     $decisionMaker->setContainer($this->container);
     $this->strategy = new PermissionGrantingStrategy($decisionMaker, $this->metadataProvider);
     $this->selector = TestHelper::get($this)->createAclExtensionSelector($this->metadataProvider, $this->ownerTree, $decisionMaker);
     $this->context = new PermissionGrantingStrategyContext($this->selector);
     $contextLink = $this->getMockBuilder('Oro\\Bundle\\EntityConfigBundle\\DependencyInjection\\Utils\\ServiceLink')->disableOriginalConstructor()->getMock();
     $contextLink->expects($this->any())->method('getService')->will($this->returnValue($this->context));
     $this->strategy->setContext($contextLink);
     $user = new User(1);
     $user->setUsername('TestUser');
     $this->sid = new UserSecurityIdentity('TestUser', get_class($user));
     $this->rsid = new RoleSecurityIdentity('TestRole');
     $token = $this->getMock('Symfony\\Component\\Security\\Core\\Authentication\\Token\\TokenInterface');
     $token->expects($this->any())->method('getUser')->will($this->returnValue($user));
     $this->context->setSecurityToken($token);
     $this->context->setObject(new TestEntity('testId'));
     $this->map = new PermissionMap($this->selector);
 }
예제 #4
0
 protected function setUp()
 {
     $this->tree = new OwnerTree();
     $this->metadataProvider = new OwnershipMetadataProviderStub($this);
     $this->metadataProvider->setMetadata($this->metadataProvider->getOrganizationClass(), new OwnershipMetadata());
     $this->metadataProvider->setMetadata($this->metadataProvider->getBusinessUnitClass(), new OwnershipMetadata('BUSINESS_UNIT', 'owner', 'owner_id'));
     $this->metadataProvider->setMetadata($this->metadataProvider->getUserClass(), new OwnershipMetadata('BUSINESS_UNIT', 'owner', 'owner_id'));
     $this->extension = TestHelper::get($this)->createEntityAclExtension($this->metadataProvider, $this->tree);
 }
 protected function setUp()
 {
     $this->factory = new ObjectIdentityFactory(TestHelper::get($this)->createAclExtensionSelector());
 }
예제 #6
0
 protected function setUp()
 {
     $this->tree = new OwnerTree();
     $this->metadataProvider = new OwnershipMetadataProviderStub($this);
     $this->metadataProvider->setMetadata($this->metadataProvider->getOrganizationClass(), new OwnershipMetadata());
     $this->metadataProvider->setMetadata($this->metadataProvider->getBusinessUnitClass(), new OwnershipMetadata('BUSINESS_UNIT', 'owner', 'owner_id'));
     $this->metadataProvider->setMetadata($this->metadataProvider->getUserClass(), new OwnershipMetadata('BUSINESS_UNIT', 'owner', 'owner_id'));
     /** @var \PHPUnit_Framework_MockObject_MockObject|OwnerTreeProvider $treeProviderMock */
     $treeProviderMock = $this->getMockBuilder('Oro\\Bundle\\SecurityBundle\\Owner\\OwnerTreeProvider')->disableOriginalConstructor()->getMock();
     $treeProviderMock->expects($this->any())->method('getTree')->will($this->returnValue($this->tree));
     $container = $this->getMock('Symfony\\Component\\DependencyInjection\\ContainerInterface');
     $container->expects($this->any())->method('get')->will($this->returnValueMap([['oro_security.ownership_tree_provider.chain', ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, $treeProviderMock], ['oro_security.owner.metadata_provider.chain', ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, $this->metadataProvider], ['oro_security.acl.object_id_accessor', ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, new ObjectIdAccessor()], ['oro_security.owner.entity_owner_accessor', ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, new EntityOwnerAccessor($this->metadataProvider)]]));
     $entityOwnerAccessor = new EntityOwnerAccessor($this->metadataProvider);
     $this->decisionMaker = new EntityOwnershipDecisionMaker($treeProviderMock, new ObjectIdAccessor(), $entityOwnerAccessor, $this->metadataProvider);
     $this->decisionMaker->setContainer($container);
     $this->extension = TestHelper::get($this)->createEntityAclExtension($this->metadataProvider, $this->tree, new ObjectIdAccessor(), $this->decisionMaker);
     $this->extension->setEntityOwnerAccessor($entityOwnerAccessor);
 }
 protected function setUp()
 {
     $this->baseProvider = $this->getMockBuilder('Oro\\Bundle\\SecurityBundle\\Acl\\Dbal\\MutableAclProvider')->disableOriginalConstructor()->getMock();
     $this->provider = new RootBasedAclProvider(new ObjectIdentityFactory(TestHelper::get($this)->createAclExtensionSelector()));
     $this->provider->setBaseAclProvider($this->baseProvider);
 }
예제 #8
0
 protected function setUp()
 {
     $this->map = new PermissionMap(TestHelper::get($this)->createAclExtensionSelector());
 }