Commit 46669d4b authored by Romain Courteaud's avatar Romain Courteaud

slapos_cloud: Do not allow user to change the release/type/shared status

parent 05d37c93
......@@ -20,7 +20,6 @@
##############################################################################
from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixin
import transaction
from unittest import expectedFailure
from AccessControl.SecurityManagement import getSecurityManager, \
setSecurityManager
......@@ -326,7 +325,6 @@ class TestSlapOSCorePersonRequest(SlapOSTestCaseMixin):
project_reference=self.project.getReference()
)
@expectedFailure
def test_Person_requestSoftwareInstance_updateInstanceTree(self):
person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
......@@ -352,7 +350,7 @@ class TestSlapOSCorePersonRequest(SlapOSTestCaseMixin):
project_reference=self.project.getReference()
)
instance_tree = person.REQUEST.get('request_instance_tree')
instance_tree_reference = instance_tree.getReference()
# instance_tree_reference = instance_tree.getReference()
transaction.commit()
self.tic()
......@@ -370,31 +368,30 @@ class TestSlapOSCorePersonRequest(SlapOSTestCaseMixin):
shared2 = False
state2 = "stopped"
person.requestSoftwareInstance(
software_release=software_release2,
software_title=software_title,
software_type=software_type2,
instance_xml=instance_xml2,
sla_xml=sla_xml2,
shared=shared2,
state=state2,
project_reference=self.project.getReference()
)
instance_tree2 = person.REQUEST.get('request_instance_tree')
self.assertEqual(instance_tree.getRelativeUrl(),
instance_tree2.getRelativeUrl())
self.assertEqual(instance_tree_reference,
instance_tree2.getReference())
try:
person.requestSoftwareInstance(
software_release=software_release2,
software_title=software_title,
software_type=software_type2,
instance_xml=instance_xml2,
sla_xml=sla_xml2,
shared=shared2,
state=state2,
project_reference=self.project.getReference()
)
except NotImplementedError:
pass
else:
raise AssertionError('User is not supposed to change the release/type/shared')
self.assertEqual(software_release2,
self.assertEqual(software_release,
instance_tree.getUrlString())
self.assertEqual(software_title, instance_tree.getTitle())
self.assertEqual(software_type2, instance_tree.getSourceReference())
self.assertEqual(instance_xml2, instance_tree.getTextContent())
self.assertEqual(sla_xml2, instance_tree.getSlaXml())
self.assertEqual(shared2, instance_tree.getRootSlave())
self.assertEqual("stop_requested", instance_tree.getSlapState())
self.assertEqual(software_type, instance_tree.getSourceReference())
self.assertEqual(instance_xml, instance_tree.getTextContent())
self.assertEqual(sla_xml, instance_tree.getSlaXml())
self.assertEqual(shared, instance_tree.getRootSlave())
self.assertEqual("start_requested", instance_tree.getSlapState())
self.assertEqual("validated", instance_tree.getValidationState())
def test_Person_requestSoftwareInstance_duplicatedInstanceTree(self):
......
......@@ -42,7 +42,7 @@ request_instance_tree_list = portal.portal_catalog(
portal_type=instance_tree_portal_type,
title={'query': software_title, 'key': 'ExactMatch'},
validation_state="validated",
default_destination_section_uid=person.getUid(),
destination_section__uid=person.getUid(),
limit=2,
)
if len(request_instance_tree_list) > 1:
......@@ -55,6 +55,13 @@ elif len(request_instance_tree_list) == 1:
(request_instance_tree.getValidationState() != "validated") or \
(request_instance_tree.getDestinationSection() != person.getRelativeUrl()):
raise NotImplementedError, "The system was not able to get the expected instance tree"
# Do not allow user to change the release/type/shared status
# This is not compatible with invoicing the service
# Instance release change will be handled by allocation supply and upgrade decision
if (request_instance_tree.getUrlString() != software_release_url_string) or \
(request_instance_tree.getSourceReference() != software_type) or \
(request_instance_tree.getRootSlave() != is_slave):
raise NotImplementedError, "You can not change the release / type / shared states"
else:
if (root_state == "destroyed"):
# No need to create destroyed subscription.
......
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