Commit b0b435ce authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_erp5: Update related Support Request/Upgrade Decision roles

   Include wider coverage on the security tests related to the "Share" feature,
   implemented via Tracking API.
parent 31e3f6be
Pipeline #15484 failed with stage
in 0 seconds
......@@ -36,7 +36,7 @@ if specialise_value is None:
return []
# Object on this case can be Hosting Subscription, Computer, or Computer Network
organisation = specialise_value.Item_getCurrentOwnerValue()
organisation = specialise_value.Item_getCurrentSiteValue()
if organisation is not None and \
organisation.getPortalType() == "Organisation":
category_list.append({'destination': [organisation.getRelativeUrl()]})
......
......@@ -736,6 +736,18 @@ class TestSlapOSLocalPermissionSlapOSInteractionWorkflow(
slave_instance = self.portal.software_instance_module.newContent(
portal_type='Slave Instance')
slave_instance.edit(specialise=hosting_subscription.getRelativeUrl())
support_request = self.portal.support_request_module.newContent(
portal_type="Support Request"
)
support_request.edit(aggregate=hosting_subscription.getRelativeUrl())
upgrade_decision = self.portal.upgrade_decision_module.newContent(
portal_type="Upgrade Decision"
)
upgrade_decision_line = upgrade_decision.newContent(
portal_type="Upgrade Decision Line"
)
upgrade_decision_line.edit(aggregate=hosting_subscription.getRelativeUrl())
self.tic()
self.assertSecurityGroup(internal_packing_list, [self.user_id,],
......@@ -751,6 +763,10 @@ class TestSlapOSLocalPermissionSlapOSInteractionWorkflow(
self.assertSecurityGroup(slave_instance, [self.user_id, 'G-COMPANY',
hosting_subscription.getReference()], False)
self.assertSecurityGroup(support_request, [self.user_id, 'G-COMPANY'], False)
self.assertSecurityGroup(upgrade_decision, [self.user_id, 'G-COMPANY'], False)
internal_packing_list_line.edit(
#quantity_unit="unit",
resource_value=self.portal.product_module.computer,
......@@ -775,6 +791,13 @@ class TestSlapOSLocalPermissionSlapOSInteractionWorkflow(
project.getReference(),
hosting_subscription.getReference()], False)
self.assertSecurityGroup(support_request, [self.user_id, 'G-COMPANY',
project.getReference()], False)
self.assertSecurityGroup(upgrade_decision, [self.user_id, 'G-COMPANY',
project.getReference()], False)
def test_InternalPackingListLine_setAggregate_computer(self):
self._makePerson()
......@@ -810,6 +833,18 @@ class TestSlapOSLocalPermissionSlapOSInteractionWorkflow(
installation = self.portal.software_installation_module.newContent(
portal_type='Software Installation')
installation.edit(aggregate=computer.getRelativeUrl())
support_request = self.portal.support_request_module.newContent(
portal_type="Support Request"
)
support_request.edit(aggregate=computer.getRelativeUrl())
upgrade_decision = self.portal.upgrade_decision_module.newContent(
portal_type="Upgrade Decision"
)
upgrade_decision_line = upgrade_decision.newContent(
portal_type="Upgrade Decision Line"
)
upgrade_decision_line.edit(aggregate=computer.getRelativeUrl())
self.tic()
self.assertSecurityGroup(internal_packing_list, [self.user_id,],
......@@ -822,6 +857,10 @@ class TestSlapOSLocalPermissionSlapOSInteractionWorkflow(
self.assertSecurityGroup(installation, [self.user_id, 'G-COMPANY',
computer.getUserId()], False)
self.assertSecurityGroup(support_request, [self.user_id, 'G-COMPANY'], False)
self.assertSecurityGroup(upgrade_decision, [self.user_id, 'G-COMPANY'], False)
internal_packing_list_line.edit(
#quantity_unit="unit",
resource_value=self.portal.product_module.computer,
......@@ -839,3 +878,9 @@ class TestSlapOSLocalPermissionSlapOSInteractionWorkflow(
self.assertSecurityGroup(installation, [self.user_id, 'G-COMPANY',
project.getReference(), computer.getUserId()], False)
self.assertSecurityGroup(support_request, [self.user_id, 'G-COMPANY',
project.getReference()], False)
self.assertSecurityGroup(upgrade_decision, [self.user_id, 'G-COMPANY',
project.getReference()], False)
\ No newline at end of file
from Products.ZSQLCatalog.SQLCatalog import SimpleQuery, ComplexQuery
portal_type_list = ['Computer', 'Computer Network', 'Hosting Subscription']
portal = context.getPortalObject()
internal_packing_list_line = state_change['object']
after_tag = (internal_packing_list_line.getPath(), ('immediateReindexObject', 'recursiveImmediateReindexObject'))
internal_packing_list_line.getParentValue().reindexObject()
for object_ in internal_packing_list_line.getAggregateValueList(portal_type=portal_type_list):
object_.activate(after_path_and_method_id=after_tag).updateLocalRolesOnSecurityGroups()
if object_.getPortalType() == "Computer":
for software_installation in object_.getAggregateRelatedValueList(portal_type="Software Installation"):
software_installation.activate(after_path_and_method_id=after_tag).updateLocalRolesOnSecurityGroups()
portal.portal_catalog.searchAndActivate(
portal_type=["Software Installation", "Support Request","Upgrade Decision"],
default_or_child_aggregate_uid=object_.getUid(),
method_id="updateLocalRolesOnSecurityGroups",
activate_kw={"after_path_and_method_id": after_tag}
)
elif object_.getPortalType() == "Hosting Subscription":
for instance in object_.getSpecialiseRelatedValueList(portal_type=["Software instance", "Slave Instance"]):
instance.activate(after_path_and_method_id=after_tag).updateLocalRolesOnSecurityGroups()
query = ComplexQuery(
ComplexQuery(
SimpleQuery(portal_type=["Software instance", "Slave Instance"]),
SimpleQuery(default_specialise_uid=object_.getUid()),
logical_operator="AND"),
ComplexQuery(
SimpleQuery(portal_type=["Support Request", "Upgrade Decision"]),
SimpleQuery(default_or_child_aggregate_uid=object_.getUid()),
logical_operator="AND"),
logical_operator="OR"
)
portal.portal_catalog.searchAndActivate(
query=query,
method_id="updateLocalRolesOnSecurityGroups",
activate_kw={"after_path_and_method_id": after_tag}
)
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