Commit 3905a253 authored by Łukasz Nowak's avatar Łukasz Nowak

Test role generation up to Computer Partition.

parent 76581c90
......@@ -114,3 +114,120 @@ class TestComputer(TestSlapOSGroupRoleSecurityMixin):
[self.user_id, 'G-COMPANY', reference], False)
self.assertRoles(computer, reference, ['Assignor'])
class TestComputerModel(TestSlapOSGroupRoleSecurityMixin):
def test_GroupCompany(self):
model = self.portal.computer_model_module.newContent(
portal_type='Computer Model')
model.updateLocalRolesOnSecurityGroups()
self.assertSecurityGroup(model,
['G-COMPANY', self.user_id], False)
self.assertRoles(model, 'G-COMPANY', ['Assignor'])
def test_ComputerAgent(self):
reference = 'TESTPERSON-%s' % self.generateNewId()
person = self.portal.person_module.newContent(portal_type='Person',
reference=reference)
model = self.portal.computer_model_module.newContent(
portal_type='Computer Model',
source_administration=person.getRelativeUrl())
model.updateLocalRolesOnSecurityGroups()
self.assertSecurityGroup(model,
['G-COMPANY', self.user_id, reference], False)
self.assertRoles(model, reference, ['Assignee'])
class TestComputerModelModule(TestSlapOSGroupRoleSecurityMixin):
def test(self):
module = self.portal.computer_model_module
self.assertSecurityGroup(module,
['R-MEMBER', 'zope'], False)
self.assertRoles(module, 'R-MEMBER', ['Auditor', 'Author'])
class TestComputerModule(TestSlapOSGroupRoleSecurityMixin):
def test(self):
module = self.portal.computer_module
self.assertSecurityGroup(module,
['R-COMPUTER', 'R-MEMBER', 'R-SHADOW-PERSON', 'zope'], False)
self.assertRoles(module, 'R-MEMBER', ['Auditor', 'Author'])
self.assertRoles(module, 'R-COMPUTER', ['Auditor'])
self.assertRoles(module, 'R-SHADOW-PERSON', ['Auditor'])
class TestComputerNetwork(TestSlapOSGroupRoleSecurityMixin):
def test_GroupCompany(self):
network = self.portal.computer_network_module.newContent(
portal_type='Computer Network')
network.updateLocalRolesOnSecurityGroups()
self.assertSecurityGroup(network,
['G-COMPANY', 'R-SHADOW-PERSON', self.user_id], False)
self.assertRoles(network, 'G-COMPANY', ['Assignor'])
self.assertRoles(network, 'R-SHADOW-PERSON', ['Auditor'])
test_PersonShadow = test_GroupCompany
def test_ComputerAgent(self):
reference = 'TESTPERSON-%s' % self.generateNewId()
person = self.portal.person_module.newContent(portal_type='Person',
reference=reference)
network = self.portal.computer_network_module.newContent(
portal_type='Computer Network',
source_administration=person.getRelativeUrl())
network.updateLocalRolesOnSecurityGroups()
self.assertSecurityGroup(network,
['G-COMPANY', 'R-SHADOW-PERSON', self.user_id, reference], False)
self.assertRoles(network, reference, ['Assignee'])
class TestComputerNetworkModule(TestSlapOSGroupRoleSecurityMixin):
def test(self):
module = self.portal.computer_network_module
self.assertSecurityGroup(module,
['R-MEMBER', 'R-SHADOW-PERSON', 'zope'], False)
self.assertRoles(module, 'R-MEMBER', ['Auditor', 'Author'])
self.assertRoles(module, 'R-SHADOW-PERSON', ['Auditor'])
class TestComputerPartition(TestSlapOSGroupRoleSecurityMixin):
def test_CustomerOfThePartition(self):
partition = self.portal.computer_module.newContent(
portal_type='Computer').newContent(portal_type='Computer Partition')
self.portal.portal_workflow._jumpToStateFor(partition, 'busy')
partition.recursiveImmediateReindexObject()
instance_customer_reference = 'TESTPERSON-%s' % self.generateNewId()
slave_customer_reference = 'TESTPERSON-%s' % self.generateNewId()
instance_customer = self.portal.person_module.newContent(
portal_type='Person', reference=instance_customer_reference)
slave_customer = self.portal.person_module.newContent(
portal_type='Person', reference=slave_customer_reference)
instance_subscription_reference = 'TESTHS-%s' % self.generateNewId()
instance_subscription = self.portal.hosting_subscription_module\
.template_hosting_subscription.Base_createCloneDocument(batch_mode=1)
instance_subscription.edit(
destination_section=instance_customer.getRelativeUrl(),
reference=instance_subscription_reference)
instance = self.portal.software_instance_module.template_software_instance\
.Base_createCloneDocument(batch_mode=1)
instance.edit(specialise=instance_subscription.getRelativeUrl(),
aggregate=partition.getRelativeUrl())
instance.validate()
instance.recursiveImmediateReindexObject()
slave_subscription = self.portal.hosting_subscription_module\
.template_hosting_subscription.Base_createCloneDocument(batch_mode=1)
slave_subscription.edit(
destination_section=slave_customer.getRelativeUrl())
slave = self.portal.software_instance_module.template_slave_instance\
.Base_createCloneDocument(batch_mode=1)
slave.validate()
slave.edit(specialise=slave_subscription.getRelativeUrl(),
aggregate=partition.getRelativeUrl())
slave.recursiveImmediateReindexObject()
partition.updateLocalRolesOnSecurityGroups()
self.assertSecurityGroup(partition,
[self.user_id, instance_customer_reference, slave_customer_reference,
instance_subscription_reference], True)
self.assertRoles(partition, instance_customer_reference, ['Auditor'])
self.assertRoles(partition, slave_customer_reference, ['Auditor'])
self.assertRoles(partition, instance_subscription_reference, ['Auditor'])
test_SoftwareInstanceGroupRelatedToComputerPartition = \
test_CustomerOfThePartition
38
\ No newline at end of file
39
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment