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