Commit ab9f21e6 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_erp5: Update default scenario test for chances on security

- Use getUserId instead getReference for person login on self.login method
- Get the person created by searching the ERP5 Login, because person has not reference defined.
parent e59cd81b
...@@ -270,10 +270,10 @@ class TestSlapOSDefaultScenario(TestSlapOSSecurityMixin): ...@@ -270,10 +270,10 @@ class TestSlapOSDefaultScenario(TestSlapOSSecurityMixin):
self.tic() self.tic()
return software_instance return software_instance
def checkSlaveInstanceAllocation(self, person_reference, instance_title, def checkSlaveInstanceAllocation(self, person_user_id, person_reference,
software_release, software_type, server): instance_title, software_release, software_type, server):
self.login(person_reference) self.login(person_user_id)
self.personRequestInstanceNotReady( self.personRequestInstanceNotReady(
software_release=software_release, software_release=software_release,
software_type=software_type, software_type=software_type,
...@@ -353,9 +353,8 @@ class TestSlapOSDefaultScenario(TestSlapOSSecurityMixin): ...@@ -353,9 +353,8 @@ class TestSlapOSDefaultScenario(TestSlapOSSecurityMixin):
if q.getTitle() == instance_title] if q.getTitle() == instance_title]
self.assertEqual(0, len(hosting_subscription_list)) self.assertEqual(0, len(hosting_subscription_list))
def checkCloudContract(self, person_user_id, person_reference,
def checkCloudContract(self, person_reference, instance_title, instance_title, software_release, software_type, server):
software_release, software_type, server):
self.stepCallSlaposContractRequestValidationPaymentAlarm() self.stepCallSlaposContractRequestValidationPaymentAlarm()
self.tic() self.tic()
...@@ -410,7 +409,6 @@ class TestSlapOSDefaultScenario(TestSlapOSSecurityMixin): ...@@ -410,7 +409,6 @@ class TestSlapOSDefaultScenario(TestSlapOSSecurityMixin):
simulation_state="started") simulation_state="started")
self.logout() self.logout()
self.login() self.login()
data_kw = { data_kw = {
...@@ -421,16 +419,16 @@ class TestSlapOSDefaultScenario(TestSlapOSSecurityMixin): ...@@ -421,16 +419,16 @@ class TestSlapOSDefaultScenario(TestSlapOSSecurityMixin):
} }
payment.PaymentTransaction_createPayzenEvent().PayzenEvent_processUpdate(data_kw, True) payment.PaymentTransaction_createPayzenEvent().PayzenEvent_processUpdate(data_kw, True)
self.login(person_reference) self.login(person_user_id)
self.stepCallSlaposContractRequestValidationPaymentAlarm() self.stepCallSlaposContractRequestValidationPaymentAlarm()
self.tic() self.tic()
def checkInstanceAllocation(self, person_reference, instance_title, def checkInstanceAllocation(self, person_user_id, person_reference,
software_release, software_type, server): instance_title, software_release, software_type, server):
self.login(person_reference) self.login(person_user_id)
self.personRequestInstanceNotReady( self.personRequestInstanceNotReady(
software_release=software_release, software_release=software_release,
...@@ -438,8 +436,8 @@ class TestSlapOSDefaultScenario(TestSlapOSSecurityMixin): ...@@ -438,8 +436,8 @@ class TestSlapOSDefaultScenario(TestSlapOSSecurityMixin):
partition_reference=instance_title, partition_reference=instance_title,
) )
self.checkCloudContract(person_reference, instance_title, self.checkCloudContract(person_user_id, person_reference,
software_release, software_type, server) instance_title, software_release, software_type, server)
self.stepCallSlaposAllocateInstanceAlarm() self.stepCallSlaposAllocateInstanceAlarm()
self.tic() self.tic()
...@@ -617,8 +615,13 @@ class TestSlapOSDefaultScenario(TestSlapOSSecurityMixin): ...@@ -617,8 +615,13 @@ class TestSlapOSDefaultScenario(TestSlapOSSecurityMixin):
owner_reference = 'owner-%s' % self.generateNewId() owner_reference = 'owner-%s' % self.generateNewId()
self.joinSlapOS(self.web_site, owner_reference) self.joinSlapOS(self.web_site, owner_reference)
self.login()
owner_person = self.portal.portal_catalog.getResultValue(
portal_type="ERP5 Login",
reference=owner_reference).getParentValue()
# hooray, now it is time to create computers # hooray, now it is time to create computers
self.login(owner_reference) self.login(owner_person.getUserId())
public_server_title = 'Public Server for %s' % owner_reference public_server_title = 'Public Server for %s' % owner_reference
public_server_id = self.requestComputer(public_server_title) public_server_id = self.requestComputer(public_server_title)
...@@ -662,10 +665,17 @@ class TestSlapOSDefaultScenario(TestSlapOSSecurityMixin): ...@@ -662,10 +665,17 @@ class TestSlapOSDefaultScenario(TestSlapOSSecurityMixin):
public_reference = 'public-%s' % self.generateNewId() public_reference = 'public-%s' % self.generateNewId()
self.joinSlapOS(self.web_site, public_reference) self.joinSlapOS(self.web_site, public_reference)
self.login()
public_person = self.portal.portal_catalog.getResultValue(
portal_type="ERP5 Login",
reference=public_reference).getParentValue()
public_instance_title = 'Public title %s' % self.generateNewId() public_instance_title = 'Public title %s' % self.generateNewId()
public_instance_type = 'public type' public_instance_type = 'public type'
self.checkInstanceAllocation(public_reference, public_instance_title, self.checkInstanceAllocation(public_person.getUserId(),
public_server_software, public_instance_type, public_server) public_reference, public_instance_title,
public_server_software, public_instance_type,
public_server)
# join as owner friend and request a software instance on computer # join as owner friend and request a software instance on computer
# configured by owner # configured by owner
...@@ -674,24 +684,26 @@ class TestSlapOSDefaultScenario(TestSlapOSSecurityMixin): ...@@ -674,24 +684,26 @@ class TestSlapOSDefaultScenario(TestSlapOSSecurityMixin):
friend_reference = 'friend-%s' % self.generateNewId() friend_reference = 'friend-%s' % self.generateNewId()
self.joinSlapOS(self.web_site, friend_reference) self.joinSlapOS(self.web_site, friend_reference)
self.login() self.login()
friend_email = self.portal.portal_catalog.getResultValue( friend_person = self.portal.portal_catalog.getResultValue(
portal_type='Person', reference=friend_reference).getDefaultEmailText() portal_type='ERP5 Login', reference=friend_reference).getParentValue()
friend_email = friend_person.getDefaultEmailText()
# allow friend to alloce on friendly computer # allow friend to alloce on friendly computer
self.login(owner_reference) self.login(owner_person.getUserId())
self.setServerOpenFriend(friend_server, [friend_email]) self.setServerOpenFriend(friend_server, [friend_email])
friend_instance_title = 'Friend title %s' % self.generateNewId() friend_instance_title = 'Friend title %s' % self.generateNewId()
friend_instance_type = 'friend_type' friend_instance_type = 'friend_type'
self.checkInstanceAllocation(friend_reference, friend_instance_title, self.checkInstanceAllocation(friend_person.getUserId(), friend_reference,
friend_server_software, friend_instance_type, friend_server) friend_instance_title, friend_server_software, friend_instance_type,
friend_server)
# check that friend is able to request slave instance matching the # check that friend is able to request slave instance matching the
# public's computer software instance # public's computer software instance
friend_slave_instance_title = 'Friend slave title %s' % self.\ friend_slave_instance_title = 'Friend slave title %s' % self.\
generateNewId() generateNewId()
self.checkSlaveInstanceAllocation(friend_reference, self.checkSlaveInstanceAllocation(friend_person.getUserId(),
friend_slave_instance_title, public_server_software, friend_reference, friend_slave_instance_title, public_server_software,
public_instance_type, public_server) public_instance_type, public_server)
# turn public guy to a friend and check that he can allocate slave # turn public guy to a friend and check that he can allocate slave
...@@ -699,14 +711,15 @@ class TestSlapOSDefaultScenario(TestSlapOSSecurityMixin): ...@@ -699,14 +711,15 @@ class TestSlapOSDefaultScenario(TestSlapOSSecurityMixin):
self.login() self.login()
public_email = self.portal.portal_catalog.getResultValue( public_email = self.portal.portal_catalog.getResultValue(
portal_type='Person', reference=public_reference).getDefaultEmailText() portal_type='ERP5 Login', reference=public_reference).getParentValue()
self.login(owner_reference) public_person.getDefaultEmailText()
self.login(owner_person.getUserId())
self.setServerOpenFriend(friend_server, [friend_email, public_email]) self.setServerOpenFriend(friend_server, [friend_email, public_email])
public_slave_instance_title = 'Public slave title %s' % self\ public_slave_instance_title = 'Public slave title %s' % self\
.generateNewId() .generateNewId()
self.checkSlaveInstanceAllocation(public_reference, self.checkSlaveInstanceAllocation(public_person.getUserId(),
public_slave_instance_title, friend_server_software, public_reference, public_slave_instance_title, friend_server_software,
friend_instance_type, friend_server) friend_instance_type, friend_server)
# now deallocate the slaves # now deallocate the slaves
...@@ -727,7 +740,7 @@ class TestSlapOSDefaultScenario(TestSlapOSSecurityMixin): ...@@ -727,7 +740,7 @@ class TestSlapOSDefaultScenario(TestSlapOSSecurityMixin):
# and uninstall some software on them # and uninstall some software on them
self.logout() self.logout()
self.login(owner_reference) self.login(owner_person.getUserId())
self.supplySoftware(public_server, public_server_software, self.supplySoftware(public_server, public_server_software,
state='destroyed') state='destroyed')
self.supplySoftware(personal_server, personal_server_software, self.supplySoftware(personal_server, personal_server_software,
...@@ -839,14 +852,14 @@ class TestSlapOSDefaultScenario(TestSlapOSSecurityMixin): ...@@ -839,14 +852,14 @@ class TestSlapOSDefaultScenario(TestSlapOSSecurityMixin):
# check final document state # check final document state
for person_reference in (owner_reference, friend_reference, for person_reference in (owner_reference, friend_reference,
public_reference): public_reference):
person = self.portal.portal_catalog.getResultValue(portal_type='Person', person = self.portal.portal_catalog.getResultValue(
reference=person_reference) portal_type='ERP5 Login', reference=person_reference).getParentValue()
self.assertPersonDocumentCoverage(person) self.assertPersonDocumentCoverage(person)
self.login(public_reference) self.login(public_person.getUserId())
self.usePayzenManually(self.web_site, public_reference) self.usePayzenManually(self.web_site, public_reference)
self.login(friend_reference) self.login(friend_person.getUserId())
self.usePayzenManually(self.web_site, friend_reference) self.usePayzenManually(self.web_site, friend_reference)
class TestSlapOSDefaultCRMEscalation(TestSlapOSSecurityMixin): class TestSlapOSDefaultCRMEscalation(TestSlapOSSecurityMixin):
...@@ -1004,8 +1017,9 @@ class TestSlapOSDefaultCRMEscalation(TestSlapOSSecurityMixin): ...@@ -1004,8 +1017,9 @@ class TestSlapOSDefaultCRMEscalation(TestSlapOSSecurityMixin):
def assertOpenSaleOrderCoverage(self, person_reference): def assertOpenSaleOrderCoverage(self, person_reference):
self.login() self.login()
person = self.portal.portal_catalog.getResultValue(portal_type='Person', person = self.portal.portal_catalog.getResultValue(
reference=person_reference) portal_type='ERP5 Login',
reference=person_reference).getParentValue()
hosting_subscription_list = self.portal.portal_catalog( hosting_subscription_list = self.portal.portal_catalog(
portal_type='Hosting Subscription', portal_type='Hosting Subscription',
default_destination_section_uid=person.getUid() default_destination_section_uid=person.getUid()
...@@ -1072,10 +1086,10 @@ class TestSlapOSDefaultCRMEscalation(TestSlapOSSecurityMixin): ...@@ -1072,10 +1086,10 @@ class TestSlapOSDefaultCRMEscalation(TestSlapOSSecurityMixin):
data) data)
event.edit(data=data) event.edit(data=data)
def requestInstance(self, person_reference, instance_title, def requestInstance(self, person_user_id, instance_title,
software_release, software_type): software_release, software_type):
self.login(person_reference) self.login(person_user_id)
self.personRequestInstanceNotReady( self.personRequestInstanceNotReady(
software_release=software_release, software_release=software_release,
software_type=software_type, software_type=software_type,
...@@ -1093,10 +1107,15 @@ class TestSlapOSDefaultCRMEscalation(TestSlapOSSecurityMixin): ...@@ -1093,10 +1107,15 @@ class TestSlapOSDefaultCRMEscalation(TestSlapOSSecurityMixin):
public_reference = 'public-%s' % self.generateNewId() public_reference = 'public-%s' % self.generateNewId()
self.joinSlapOS(self.web_site, public_reference) self.joinSlapOS(self.web_site, public_reference)
self.login()
self.tic()
person = self.portal.portal_catalog.getResultValue(
portal_type="ERP5 Login", reference=public_reference).getParentValue()
public_instance_title = 'Public title %s' % self.generateNewId() public_instance_title = 'Public title %s' % self.generateNewId()
public_instance_type = 'public type' public_instance_type = 'public type'
public_server_software = self.generateNewSoftwareReleaseUrl() public_server_software = self.generateNewSoftwareReleaseUrl()
self.requestInstance(public_reference, public_instance_title, self.requestInstance(person.getUserId(), public_instance_title,
public_server_software, public_instance_type) public_server_software, public_instance_type)
# check the Open Sale Order coverage # check the Open Sale Order coverage
...@@ -1191,9 +1210,6 @@ class TestSlapOSDefaultCRMEscalation(TestSlapOSSecurityMixin): ...@@ -1191,9 +1210,6 @@ class TestSlapOSDefaultCRMEscalation(TestSlapOSSecurityMixin):
self.stepCallSlaposCrmCreateRegularisationRequestAlarm() self.stepCallSlaposCrmCreateRegularisationRequestAlarm()
self.tic() self.tic()
person = self.portal.portal_catalog.getResultValue(portal_type='Person',
reference=public_reference)
# escalate 1 # escalate 1
self.trickCrmEvent('slapos_crm_acknowledgement', 38, public_reference) self.trickCrmEvent('slapos_crm_acknowledgement', 38, public_reference)
self.stepCallSlaposCrmTriggerAcknowledgmentEscalationAlarm() self.stepCallSlaposCrmTriggerAcknowledgmentEscalationAlarm()
......
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
<value> <value>
<tuple> <tuple>
<string>W: 38, 4: Unused variable \'credential_request_form\' (unused-variable)</string> <string>W: 38, 4: Unused variable \'credential_request_form\' (unused-variable)</string>
<string>W:859, 4: Unused variable \'credential_request_form\' (unused-variable)</string> <string>W:872, 4: Unused variable \'credential_request_form\' (unused-variable)</string>
</tuple> </tuple>
</value> </value>
</item> </item>
......
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