Commit ae610908 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_slap_tool: testSlapOSSlapTool use person.getUserId instead person.getReference

parent 11bdc499
...@@ -6,10 +6,22 @@ ...@@ -6,10 +6,22 @@
</pickle> </pickle>
<pickle> <pickle>
<dictionary> <dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item> <item>
<key> <string>default_reference</string> </key> <key> <string>default_reference</string> </key>
<value> <string>SlapOSSlapTool</string> </value> <value> <string>SlapOSSlapTool</string> </value>
</item> </item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>extension.erp5.SlapOSSlapTool</string> </value> <value> <string>extension.erp5.SlapOSSlapTool</string> </value>
...@@ -43,13 +55,28 @@ ...@@ -43,13 +55,28 @@
<item> <item>
<key> <string>workflow_history</string> </key> <key> <string>workflow_history</string> </key>
<value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="2" aka="AAAAAAAAAAI="> <record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle> <pickle>
<global name="PersistentMapping" module="Persistence.mapping"/> <global name="PersistentMapping" module="Persistence.mapping"/>
</pickle> </pickle>
...@@ -62,7 +89,7 @@ ...@@ -62,7 +89,7 @@
<item> <item>
<key> <string>component_validation_workflow</string> </key> <key> <string>component_validation_workflow</string> </key>
<value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value> </value>
</item> </item>
</dictionary> </dictionary>
...@@ -71,7 +98,7 @@ ...@@ -71,7 +98,7 @@
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="3" aka="AAAAAAAAAAM="> <record id="4" aka="AAAAAAAAAAQ=">
<pickle> <pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/> <global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle> </pickle>
......
...@@ -2141,10 +2141,11 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin): ...@@ -2141,10 +2141,11 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
person.recursiveImmediateReindexObject() person.recursiveImmediateReindexObject()
self.person = person self.person = person
self.person_reference = person.getReference() self.person_reference = person.getReference()
self.person_user_id = person.getUserId()
TestSlapOSSlapToolMixin.afterSetUp(self, person=person) TestSlapOSSlapToolMixin.afterSetUp(self, person=person)
def test_not_accessed_getComputerStatus(self): def test_not_accessed_getComputerStatus(self):
self.login(self.person_reference) self.login(self.person_user_id)
created_at = rfc1123_date(DateTime()) created_at = rfc1123_date(DateTime())
response = self.portal_slap.getComputerStatus(self.computer_id) response = self.portal_slap.getComputerStatus(self.computer_id)
self.assertEqual(200, response.status) self.assertEqual(200, response.status)
...@@ -2185,7 +2186,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin): ...@@ -2185,7 +2186,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
def test_accessed_getComputerStatus(self): def test_accessed_getComputerStatus(self):
self.login(self.computer_id) self.login(self.computer_id)
self.portal_slap.getFullComputerInformation(self.computer_id) self.portal_slap.getFullComputerInformation(self.computer_id)
self.login(self.person_reference) self.login(self.person_user_id)
created_at = rfc1123_date(DateTime()) created_at = rfc1123_date(DateTime())
response = self.portal_slap.getComputerStatus(self.computer_id) response = self.portal_slap.getComputerStatus(self.computer_id)
self.assertEqual(200, response.status) self.assertEqual(200, response.status)
...@@ -2233,7 +2234,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin): ...@@ -2233,7 +2234,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
'recmethod': 'reportComputerBang'}]) 'recmethod': 'reportComputerBang'}])
def test_computerBang(self): def test_computerBang(self):
self.login(self.person_reference) self.login(self.person_user_id)
self.computer_bang_simulator = tempfile.mkstemp()[1] self.computer_bang_simulator = tempfile.mkstemp()[1]
try: try:
self.computer.reportComputerBang = Simulator( self.computer.reportComputerBang = Simulator(
...@@ -2276,7 +2277,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin): ...@@ -2276,7 +2277,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
def test_getComputerPartitionStatus(self): def test_getComputerPartitionStatus(self):
self._makeComplexComputer() self._makeComplexComputer()
self.login(self.person_reference) self.login(self.person_user_id)
partition_id = self.start_requested_software_instance.getAggregateValue( partition_id = self.start_requested_software_instance.getAggregateValue(
portal_type='Computer Partition').getReference() portal_type='Computer Partition').getReference()
created_at = rfc1123_date(DateTime()) created_at = rfc1123_date(DateTime())
...@@ -2319,13 +2320,13 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin): ...@@ -2319,13 +2320,13 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
def test_getComputerPartitionStatus_visited(self): def test_getComputerPartitionStatus_visited(self):
self._makeComplexComputer(person=self.person) self._makeComplexComputer(person=self.person)
self.login(self.person_reference) self.login(self.person_user_id)
partition_id = self.start_requested_software_instance.getAggregateValue( partition_id = self.start_requested_software_instance.getAggregateValue(
portal_type='Computer Partition').getReference() portal_type='Computer Partition').getReference()
created_at = rfc1123_date(DateTime()) created_at = rfc1123_date(DateTime())
self.login(self.start_requested_software_instance.getReference()) self.login(self.start_requested_software_instance.getReference())
self.portal_slap.registerComputerPartition(self.computer_id, partition_id) self.portal_slap.registerComputerPartition(self.computer_id, partition_id)
self.login(self.person_reference) self.login(self.person_user_id)
response = self.portal_slap.getComputerPartitionStatus(self.computer_id, response = self.portal_slap.getComputerPartitionStatus(self.computer_id,
partition_id) partition_id)
self.assertEqual(200, response.status) self.assertEqual(200, response.status)
...@@ -2368,7 +2369,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin): ...@@ -2368,7 +2369,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
self._makeComplexComputer(person=self.person, with_slave=True) self._makeComplexComputer(person=self.person, with_slave=True)
partition_id = self.start_requested_software_instance.getAggregateValue( partition_id = self.start_requested_software_instance.getAggregateValue(
portal_type='Computer Partition').getReference() portal_type='Computer Partition').getReference()
self.login(self.person_reference) self.login(self.person_user_id)
response = self.portal_slap.registerComputerPartition(self.computer_id, partition_id) response = self.portal_slap.registerComputerPartition(self.computer_id, partition_id)
self.assertEqual(200, response.status) self.assertEqual(200, response.status)
self.assertEqual( 'public, max-age=1, stale-if-error=604800', self.assertEqual( 'public, max-age=1, stale-if-error=604800',
...@@ -2500,7 +2501,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin): ...@@ -2500,7 +2501,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
self._makeComplexComputer(person=self.person) self._makeComplexComputer(person=self.person)
partition_id = self.start_requested_software_instance.getAggregateValue( partition_id = self.start_requested_software_instance.getAggregateValue(
portal_type='Computer Partition').getReference() portal_type='Computer Partition').getReference()
self.login(self.person_reference) self.login(self.person_user_id)
response = self.portal_slap.registerComputerPartition(self.computer_id, partition_id) response = self.portal_slap.registerComputerPartition(self.computer_id, partition_id)
self.assertEqual(200, response.status) self.assertEqual(200, response.status)
self.assertEqual( 'public, max-age=1, stale-if-error=604800', self.assertEqual( 'public, max-age=1, stale-if-error=604800',
...@@ -2623,7 +2624,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin): ...@@ -2623,7 +2624,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
try: try:
partition_id = self.start_requested_software_instance.getAggregateValue( partition_id = self.start_requested_software_instance.getAggregateValue(
portal_type='Computer Partition').getReference() portal_type='Computer Partition').getReference()
self.login(self.person_reference) self.login(self.person_user_id)
self.start_requested_software_instance.bang = Simulator( self.start_requested_software_instance.bang = Simulator(
self.instance_bang_simulator, 'bang') self.instance_bang_simulator, 'bang')
error_log = 'Please bang me' error_log = 'Please bang me'
...@@ -2662,7 +2663,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin): ...@@ -2662,7 +2663,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
finally: finally:
if os.path.exists(self.instance_bang_simulator): if os.path.exists(self.instance_bang_simulator):
os.unlink(self.instance_bang_simulator) os.unlink(self.instance_bang_simulator)
def assertInstanceRenameSimulator(self, args, kwargs): def assertInstanceRenameSimulator(self, args, kwargs):
stored = eval(open(self.instance_rename_simulator).read()) stored = eval(open(self.instance_rename_simulator).read())
# do the same translation magic as in workflow # do the same translation magic as in workflow
...@@ -2676,7 +2677,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin): ...@@ -2676,7 +2677,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
try: try:
partition_id = self.start_requested_software_instance.getAggregateValue( partition_id = self.start_requested_software_instance.getAggregateValue(
portal_type='Computer Partition').getReference() portal_type='Computer Partition').getReference()
self.login(self.person_reference) self.login(self.person_user_id)
self.start_requested_software_instance.rename = Simulator( self.start_requested_software_instance.rename = Simulator(
self.instance_rename_simulator, 'rename') self.instance_rename_simulator, 'rename')
new_name = 'new me' new_name = 'new me'
...@@ -2700,7 +2701,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin): ...@@ -2700,7 +2701,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
def test_request_withSlave(self): def test_request_withSlave(self):
self.instance_request_simulator = tempfile.mkstemp()[1] self.instance_request_simulator = tempfile.mkstemp()[1]
try: try:
self.login(self.person_reference) self.login(self.person_user_id)
self.person.requestSoftwareInstance = Simulator( self.person.requestSoftwareInstance = Simulator(
self.instance_request_simulator, 'requestSoftwareInstance') self.instance_request_simulator, 'requestSoftwareInstance')
response = self.portal_slap.requestComputerPartition( response = self.portal_slap.requestComputerPartition(
...@@ -2730,7 +2731,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin): ...@@ -2730,7 +2731,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
def test_request(self): def test_request(self):
self.instance_request_simulator = tempfile.mkstemp()[1] self.instance_request_simulator = tempfile.mkstemp()[1]
try: try:
self.login(self.person_reference) self.login(self.person_user_id)
self.person.requestSoftwareInstance = Simulator( self.person.requestSoftwareInstance = Simulator(
self.instance_request_simulator, 'requestSoftwareInstance') self.instance_request_simulator, 'requestSoftwareInstance')
response = self.portal_slap.requestComputerPartition( response = self.portal_slap.requestComputerPartition(
...@@ -2766,7 +2767,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin): ...@@ -2766,7 +2767,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
self._makeComplexComputer(person=self.person) self._makeComplexComputer(person=self.person)
self.start_requested_software_instance.updateLocalRolesOnSecurityGroups() self.start_requested_software_instance.updateLocalRolesOnSecurityGroups()
self.tic() self.tic()
self.login(self.person_reference) self.login(self.person_user_id)
response = self.portal_slap.requestComputerPartition( response = self.portal_slap.requestComputerPartition(
software_release=self.start_requested_software_instance.getUrlString(), software_release=self.start_requested_software_instance.getUrlString(),
software_type=self.start_requested_software_instance.getSourceReference(), software_type=self.start_requested_software_instance.getSourceReference(),
...@@ -2857,7 +2858,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin): ...@@ -2857,7 +2858,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
def test_computerSupply(self): def test_computerSupply(self):
self.computer_supply_simulator = tempfile.mkstemp()[1] self.computer_supply_simulator = tempfile.mkstemp()[1]
try: try:
self.login(self.person_reference) self.login(self.person_user_id)
self.computer.requestSoftwareRelease = Simulator( self.computer.requestSoftwareRelease = Simulator(
self.computer_supply_simulator, 'requestSoftwareRelease') self.computer_supply_simulator, 'requestSoftwareRelease')
software_url = 'live_test_url_%s' % self.generateNewId() software_url = 'live_test_url_%s' % self.generateNewId()
...@@ -2884,7 +2885,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin): ...@@ -2884,7 +2885,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
def test_requestComputer(self): def test_requestComputer(self):
self.computer_request_computer_simulator = tempfile.mkstemp()[1] self.computer_request_computer_simulator = tempfile.mkstemp()[1]
try: try:
self.login(self.person_reference) self.login(self.person_user_id)
self.person.requestComputer = Simulator( self.person.requestComputer = Simulator(
self.computer_request_computer_simulator, 'requestComputer') self.computer_request_computer_simulator, 'requestComputer')
...@@ -2932,7 +2933,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin): ...@@ -2932,7 +2933,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
def test_generateComputerCertificate(self): def test_generateComputerCertificate(self):
self.generate_computer_certificate_simulator = tempfile.mkstemp()[1] self.generate_computer_certificate_simulator = tempfile.mkstemp()[1]
try: try:
self.login(self.person_reference) self.login(self.person_user_id)
self.computer.generateCertificate = Simulator( self.computer.generateCertificate = Simulator(
self.generate_computer_certificate_simulator, self.generate_computer_certificate_simulator,
'generateComputerCertificate') 'generateComputerCertificate')
...@@ -2979,9 +2980,9 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin): ...@@ -2979,9 +2980,9 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
def test_revokeComputerCertificate(self): def test_revokeComputerCertificate(self):
self.revoke_computer_certificate_simulator = tempfile.mkstemp()[1] self.revoke_computer_certificate_simulator = tempfile.mkstemp()[1]
try: try:
self.login(self.person_reference) self.login(self.person_user_id)
self.computer.revokeCertificate = Simulator( self.computer.revokeCertificate = Simulator(
self.revoke_computer_certificate_simulator, self.revoke_computer_certificate_simulator,
'revokeComputerCertificate') 'revokeComputerCertificate')
response = self.portal_slap.revokeComputerCertificate(self.computer_id) response = self.portal_slap.revokeComputerCertificate(self.computer_id)
...@@ -2998,7 +2999,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin): ...@@ -2998,7 +2999,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
if preference.getPreferenceState() == 'global': if preference.getPreferenceState() == 'global':
preference.setPreferredHateoasUrl('') preference.setPreferredHateoasUrl('')
self.tic() self.tic()
self.login(self.person_reference) self.login(self.person_user_id)
self.assertRaises(NotFound, self.portal_slap.getHateoasUrl) self.assertRaises(NotFound, self.portal_slap.getHateoasUrl)
def test_getHateoasUrl(self): def test_getHateoasUrl(self):
...@@ -3008,7 +3009,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin): ...@@ -3008,7 +3009,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
if preference.getPreferenceState() == 'global': if preference.getPreferenceState() == 'global':
preference.setPreferredHateoasUrl('foo') preference.setPreferredHateoasUrl('foo')
self.tic() self.tic()
self.login(self.person_reference) self.login(self.person_user_id)
response = self.portal_slap.getHateoasUrl() response = self.portal_slap.getHateoasUrl()
self.assertEqual(200, response.status) self.assertEqual(200, response.status)
self.assertEqual('foo', response.body) self.assertEqual('foo', response.body)
...@@ -55,15 +55,15 @@ ...@@ -55,15 +55,15 @@
<string>W:1514, 13: Use of eval (eval-used)</string> <string>W:1514, 13: Use of eval (eval-used)</string>
<string>W:1568, 13: Use of eval (eval-used)</string> <string>W:1568, 13: Use of eval (eval-used)</string>
<string>W:1608, 13: Use of eval (eval-used)</string> <string>W:1608, 13: Use of eval (eval-used)</string>
<string>W:2015, 2: Arguments number differs from overridden \'afterSetUp\' method (arguments-differ)</string> <string>W:2132, 2: Arguments number differs from overridden \'afterSetUp\' method (arguments-differ)</string>
<string>W:2111, 13: Use of eval (eval-used)</string> <string>W:2229, 13: Use of eval (eval-used)</string>
<string>W:2496, 13: Use of eval (eval-used)</string> <string>W:2614, 13: Use of eval (eval-used)</string>
<string>W:2550, 13: Use of eval (eval-used)</string> <string>W:2668, 13: Use of eval (eval-used)</string>
<string>W:2577, 13: Use of eval (eval-used)</string> <string>W:2695, 13: Use of eval (eval-used)</string>
<string>W:2732, 13: Use of eval (eval-used)</string> <string>W:2850, 13: Use of eval (eval-used)</string>
<string>W:2760, 13: Use of eval (eval-used)</string> <string>W:2878, 13: Use of eval (eval-used)</string>
<string>W:2809, 13: Use of eval (eval-used)</string> <string>W:2927, 13: Use of eval (eval-used)</string>
<string>W:2856, 13: Use of eval (eval-used)</string> <string>W:2974, 13: Use of eval (eval-used)</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