Commit 534272e2 authored by Romain Courteaud's avatar Romain Courteaud

slapos_json_rpc_api: tests

parent 515bb9c3
import json software_instance = context.jIOWebSection_getObjectFromData(data_dict)
software_instance = context.getParentValue()
return json.dumps({ # software_instance = context.getParentValue()
"$schema": json_form.absolute_url().strip() + "/getOutputJSONSchema", return {
#"$schema": json_form.absolute_url().strip() + "/getOutputJSONSchema",
"reference": software_instance.getReference(), "reference": software_instance.getReference(),
"key": software_instance.getSslKey(), "key": software_instance.getSslKey(),
"certificate": software_instance.getSslCertificate(), "certificate": software_instance.getSslCertificate(),
"portal_type": "Software Instance Certificate Record", "portal_type": "Software Instance Certificate Record",
}, indent=2) }
...@@ -171,11 +171,10 @@ class TestSlapOSSlapToolComputeNodeAccess(TestSlapOSJsonRpcMixin): ...@@ -171,11 +171,10 @@ class TestSlapOSSlapToolComputeNodeAccess(TestSlapOSJsonRpcMixin):
instance_2 = self.compute_node.partition2.getAggregateRelatedValue(portal_type='Software Instance') instance_2 = self.compute_node.partition2.getAggregateRelatedValue(portal_type='Software Instance')
instance_3 = self.compute_node.partition3.getAggregateRelatedValue(portal_type='Software Instance') instance_3 = self.compute_node.partition3.getAggregateRelatedValue(portal_type='Software Instance')
self.login(self.compute_node_user_id)
response = self.callJsonRpcWebService('slapos.allDocs.slapos_jio_api_search_instance', { response = self.callJsonRpcWebService('slapos.allDocs.slapos_jio_api_search_instance', {
"compute_node_id": self.compute_node_id, "compute_node_id": self.compute_node_id,
"portal_type": "Software Instance", "portal_type": "Software Instance",
}) }, self.compute_node_user_id)
instance_list_response = json.loads(response.getBody()) instance_list_response = json.loads(response.getBody())
if 200 != response.getStatus(): if 200 != response.getStatus():
...@@ -221,7 +220,6 @@ class TestSlapOSSlapToolComputeNodeAccess(TestSlapOSJsonRpcMixin): ...@@ -221,7 +220,6 @@ class TestSlapOSSlapToolComputeNodeAccess(TestSlapOSJsonRpcMixin):
self.assertEqual('application/json', self.assertEqual('application/json',
response.headers.get('content-type')) response.headers.get('content-type'))
# Check Data is correct # Check Data is correct
self.login()
partition = instance.getAggregateValue(portal_type="Compute Partition") partition = instance.getAggregateValue(portal_type="Compute Partition")
self.assertEqual({ self.assertEqual({
"$schema": instance.getJSONSchemaUrl(), "$schema": instance.getJSONSchemaUrl(),
...@@ -571,25 +569,19 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSJsonRpcMixin): ...@@ -571,25 +569,19 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSJsonRpcMixin):
def test_InstanceAccess_10_getComputerPartitionCertificate(self): def test_InstanceAccess_10_getComputerPartitionCertificate(self):
self._makeComplexComputeNode(self.project) self._makeComplexComputeNode(self.project)
self.login(self.start_requested_software_instance.getUserId())
response = self.callJsonRpcWebService("slapos.get.slapos_jio_api_get_software_instance_certificate", { response = self.callJsonRpcWebService("slapos.get.slapos_jio_api_get_software_instance_certificate", {
"portal_type": "Software Instance Certificate Record", "portal_type": "Software Instance Certificate Record",
"reference": self.start_requested_software_instance.getReference(), "reference": self.start_requested_software_instance.getReference(),
}) }, self.start_requested_software_instance.getUserId())
certificate_dict = json.loads(response.getBody())
if 200 != response.getStatus(): self.assertEqual('application/json', response.headers.get('content-type'))
raise ValueError("Unexpected Result %s" % certificate_dict) self.assertEqual({
self.assertEqual('application/json',
response.headers.get('content-type'))
self.assertTrue(
certificate_dict.pop("$schema").endswith("SoftwareInstanceCertificateRecord_getFromJSON/getOutputJSONSchema")
)
self.assertEqual(certificate_dict, {
"key" :self.start_requested_software_instance.getSslKey(), "key" :self.start_requested_software_instance.getSslKey(),
"certificate": self.start_requested_software_instance.getSslCertificate(), "certificate": self.start_requested_software_instance.getSslCertificate(),
"portal_type": "Software Instance Certificate Record", "portal_type": "Software Instance Certificate Record",
"reference": self.start_requested_software_instance.getReference(), "reference": self.start_requested_software_instance.getReference(),
}) }, byteify(json.loads(response.getBody())))
self.assertEqual(response.getStatus(), 200)
def test_InstanceAccess_11_getFullComputerInformationWithSharedInstance(self, with_slave=True): def test_InstanceAccess_11_getFullComputerInformationWithSharedInstance(self, with_slave=True):
self._makeComplexComputeNode(self.project, with_slave=with_slave) self._makeComplexComputeNode(self.project, with_slave=with_slave)
......
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