Commit 086e53b6 authored by Romain Courteaud's avatar Romain Courteaud

slapos_jio_hateoas_backward_compatibility: drop as not used

parent 7fa4e308
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ActionInformation" module="Products.CMFCore.ActionInformation"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>action</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>action_type/object_slap</string>
</tuple>
</value>
</item>
<item>
<key> <string>category</string> </key>
<value> <string>object_slap</string> </value>
</item>
<item>
<key> <string>condition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>icon</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>get_hateoas_software_installation_list</string> </value>
</item>
<item>
<key> <string>permissions</string> </key>
<value>
<tuple>
<string>View</string>
</tuple>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Action Information</string> </value>
</item>
<item>
<key> <string>priority</string> </key>
<value> <float>50.0</float> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>getHateoasSoftwareInstallationList</string> </value>
</item>
<item>
<key> <string>visible</string> </key>
<value> <int>1</int> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Expression" module="Products.CMFCore.Expression"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>string:${object_url}/ComputeNode_getHateoasSoftwareInstallationList</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ActionInformation" module="Products.CMFCore.ActionInformation"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>action</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>action_type/object_slap</string>
</tuple>
</value>
</item>
<item>
<key> <string>category</string> </key>
<value> <string>object_slap</string> </value>
</item>
<item>
<key> <string>condition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>icon</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>get_hateoas_instance_list</string> </value>
</item>
<item>
<key> <string>permissions</string> </key>
<value>
<tuple>
<string>View</string>
</tuple>
</value>
</item>
<item>
<key> <string>priority</string> </key>
<value> <float>2.0</float> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>getHateoasInstanceList</string> </value>
</item>
<item>
<key> <string>visible</string> </key>
<value> <int>1</int> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Expression" module="Products.CMFCore.Expression"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>string:${object_url}/InstanceTree_getHateoasInstanceList</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ActionInformation" module="Products.CMFCore.ActionInformation"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>action</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>action_type/object_slap</string>
</tuple>
</value>
</item>
<item>
<key> <string>category</string> </key>
<value> <string>object_slap</string> </value>
</item>
<item>
<key> <string>condition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>icon</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>get_hateoas_root_instance</string> </value>
</item>
<item>
<key> <string>permissions</string> </key>
<value>
<tuple>
<string>View</string>
</tuple>
</value>
</item>
<item>
<key> <string>priority</string> </key>
<value> <float>2.0</float> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>getHateoasRootInstance</string> </value>
</item>
<item>
<key> <string>visible</string> </key>
<value> <int>1</int> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Expression" module="Products.CMFCore.Expression"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>string:${object_url}/InstanceTree_getHateoasRootSoftwareInstance</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ActionInformation" module="Products.CMFCore.ActionInformation"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>action</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>action_type/object_slap</string>
</tuple>
</value>
</item>
<item>
<key> <string>category</string> </key>
<value> <string>object_slap</string> </value>
</item>
<item>
<key> <string>condition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>icon</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>get_hateoas_compute_node_list</string> </value>
</item>
<item>
<key> <string>permissions</string> </key>
<value>
<tuple>
<string>View</string>
</tuple>
</value>
</item>
<item>
<key> <string>priority</string> </key>
<value> <float>15.0</float> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>getHateoasComputeNodeList</string> </value>
</item>
<item>
<key> <string>visible</string> </key>
<value> <int>1</int> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Expression" module="Products.CMFCore.Expression"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>string:${object_url}/Person_getHateoasComputeNodeList</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ActionInformation" module="Products.CMFCore.ActionInformation"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>action</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>action_type/object_slap</string>
</tuple>
</value>
</item>
<item>
<key> <string>category</string> </key>
<value> <string>object_slap</string> </value>
</item>
<item>
<key> <string>condition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>icon</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>get_hateoas_information</string> </value>
</item>
<item>
<key> <string>permissions</string> </key>
<value>
<tuple>
<string>View</string>
</tuple>
</value>
</item>
<item>
<key> <string>priority</string> </key>
<value> <float>15.0</float> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>getHateoasInformation</string> </value>
</item>
<item>
<key> <string>visible</string> </key>
<value> <int>1</int> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Expression" module="Products.CMFCore.Expression"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>string:${object_url}/Person_getHateoasInformation</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ActionInformation" module="Products.CMFCore.ActionInformation"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>action</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>action_type/object_slap</string>
</tuple>
</value>
</item>
<item>
<key> <string>category</string> </key>
<value> <string>object_slap</string> </value>
</item>
<item>
<key> <string>condition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>icon</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>get_hateoas_instance_tree_list</string> </value>
</item>
<item>
<key> <string>permissions</string> </key>
<value>
<tuple>
<string>View</string>
</tuple>
</value>
</item>
<item>
<key> <string>priority</string> </key>
<value> <float>15.0</float> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>getHateoasInstanceTreeList</string> </value>
</item>
<item>
<key> <string>visible</string> </key>
<value> <int>1</int> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Expression" module="Products.CMFCore.Expression"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>string:${object_url}/Person_getHateoasInstanceTreeList</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ActionInformation" module="Products.CMFCore.ActionInformation"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>action</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>action_type/object_slap</string>
</tuple>
</value>
</item>
<item>
<key> <string>category</string> </key>
<value> <string>object_slap</string> </value>
</item>
<item>
<key> <string>condition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>icon</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>get_hateoas_information</string> </value>
</item>
<item>
<key> <string>permissions</string> </key>
<value>
<tuple>
<string>View</string>
</tuple>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Action Information</string> </value>
</item>
<item>
<key> <string>priority</string> </key>
<value> <float>2.0</float> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>getHateoasInformation</string> </value>
</item>
<item>
<key> <string>visible</string> </key>
<value> <int>1</int> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Expression" module="Products.CMFCore.Expression"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>string:${object_url}/Instance_getHateoasInformation</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ActionInformation" module="Products.CMFCore.ActionInformation"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>action</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>action_type/object_slap</string>
</tuple>
</value>
</item>
<item>
<key> <string>category</string> </key>
<value> <string>object_slap</string> </value>
</item>
<item>
<key> <string>condition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>icon</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>get_hateoas_news</string> </value>
</item>
<item>
<key> <string>permissions</string> </key>
<value>
<tuple>
<string>View</string>
</tuple>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Action Information</string> </value>
</item>
<item>
<key> <string>priority</string> </key>
<value> <float>2.0</float> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>getHateoasNews</string> </value>
</item>
<item>
<key> <string>visible</string> </key>
<value> <int>1</int> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Expression" module="Products.CMFCore.Expression"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>string:${object_url}/Instance_getHateoasNews</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ActionInformation" module="Products.CMFCore.ActionInformation"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>action</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>action_type/object_slap</string>
</tuple>
</value>
</item>
<item>
<key> <string>category</string> </key>
<value> <string>object_slap</string> </value>
</item>
<item>
<key> <string>condition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>icon</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>get_hateoas_related_instance_tree</string> </value>
</item>
<item>
<key> <string>permissions</string> </key>
<value>
<tuple>
<string>View</string>
</tuple>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Action Information</string> </value>
</item>
<item>
<key> <string>priority</string> </key>
<value> <float>2.0</float> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>getHateoasRelatedInstanceTree</string> </value>
</item>
<item>
<key> <string>visible</string> </key>
<value> <int>1</int> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Expression" module="Products.CMFCore.Expression"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>string:${object_url}/Instance_getHateoasRelatedInstanceTree</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ActionInformation" module="Products.CMFCore.ActionInformation"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>action</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>action_type/object_slap</string>
</tuple>
</value>
</item>
<item>
<key> <string>category</string> </key>
<value> <string>object_slap</string> </value>
</item>
<item>
<key> <string>condition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>icon</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>get_hateoas_information</string> </value>
</item>
<item>
<key> <string>permissions</string> </key>
<value>
<tuple>
<string>View</string>
</tuple>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Action Information</string> </value>
</item>
<item>
<key> <string>priority</string> </key>
<value> <float>2.0</float> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>getHateoasInformation</string> </value>
</item>
<item>
<key> <string>visible</string> </key>
<value> <int>1</int> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Expression" module="Products.CMFCore.Expression"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>string:${object_url}/SoftwareInstallation_getHateoasInformation</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ActionInformation" module="Products.CMFCore.ActionInformation"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>action</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>action_type/object_slap</string>
</tuple>
</value>
</item>
<item>
<key> <string>category</string> </key>
<value> <string>object_slap</string> </value>
</item>
<item>
<key> <string>condition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>icon</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>get_hateoas_news</string> </value>
</item>
<item>
<key> <string>permissions</string> </key>
<value>
<tuple>
<string>View</string>
</tuple>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Action Information</string> </value>
</item>
<item>
<key> <string>priority</string> </key>
<value> <float>2.0</float> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>getHateoasNews</string> </value>
</item>
<item>
<key> <string>visible</string> </key>
<value> <int>1</int> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Expression" module="Products.CMFCore.Expression"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>string:${object_url}/SoftwareInstallation_getHateoasNews</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ActionInformation" module="Products.CMFCore.ActionInformation"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>action</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>action_type/object_slap</string>
</tuple>
</value>
</item>
<item>
<key> <string>category</string> </key>
<value> <string>object_slap</string> </value>
</item>
<item>
<key> <string>condition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>icon</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>get_hateoas_information</string> </value>
</item>
<item>
<key> <string>permissions</string> </key>
<value>
<tuple>
<string>View</string>
</tuple>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Action Information</string> </value>
</item>
<item>
<key> <string>priority</string> </key>
<value> <float>2.0</float> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>getHateoasInformation</string> </value>
</item>
<item>
<key> <string>visible</string> </key>
<value> <int>1</int> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Expression" module="Products.CMFCore.Expression"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>string:${object_url}/Instance_getHateoasInformation</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ActionInformation" module="Products.CMFCore.ActionInformation"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>action</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>action_type/object_slap</string>
</tuple>
</value>
</item>
<item>
<key> <string>category</string> </key>
<value> <string>object_slap</string> </value>
</item>
<item>
<key> <string>condition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>icon</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>get_hateoas_news</string> </value>
</item>
<item>
<key> <string>permissions</string> </key>
<value>
<tuple>
<string>View</string>
</tuple>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Action Information</string> </value>
</item>
<item>
<key> <string>priority</string> </key>
<value> <float>2.0</float> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>getHateoasNews</string> </value>
</item>
<item>
<key> <string>visible</string> </key>
<value> <int>1</int> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Expression" module="Products.CMFCore.Expression"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>string:${object_url}/Instance_getHateoasNews</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ActionInformation" module="Products.CMFCore.ActionInformation"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>action</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>action_type/object_slap</string>
</tuple>
</value>
</item>
<item>
<key> <string>category</string> </key>
<value> <string>object_slap</string> </value>
</item>
<item>
<key> <string>condition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>icon</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>get_hateoas_related_instance_tree</string> </value>
</item>
<item>
<key> <string>permissions</string> </key>
<value>
<tuple>
<string>View</string>
</tuple>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Action Information</string> </value>
</item>
<item>
<key> <string>priority</string> </key>
<value> <float>2.0</float> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>getHateoasRelatedInstanceTree</string> </value>
</item>
<item>
<key> <string>visible</string> </key>
<value> <int>1</int> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Expression" module="Products.CMFCore.Expression"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>string:${object_url}/Instance_getHateoasRelatedInstanceTree</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Category" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Add_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Add_portal_folders_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Copy_or_Move_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Delete_objects_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Modify_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>action_type/object_slap</string>
<string>action_type/object_slap</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>object_slap</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Category</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>object_slap</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Category" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Add_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Add_portal_folders_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Copy_or_Move_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Delete_objects_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Modify_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>action_type/object_slap</string>
<string>action_type/object_slap</string>
<string>action_type/object_slap_post</string>
<string>action_type/object_slap_post</string>
<string>action_type/object_slap_post</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>object_slap_post</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Category</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>object_slap_post</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Folder" module="OFS.Folder"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_local_properties</string> </key>
<value>
<tuple>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>business_template_skin_layer_priority</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>float</string> </value>
</item>
</dictionary>
</tuple>
</value>
</item>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>business_template_skin_layer_priority</string> </key>
<value> <float>99.01</float> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>slapos_hal_json_style_backward_compatibility</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
from zExceptions import Unauthorized
from AccessControl import getSecurityManager
if REQUEST is None:
raise Unauthorized
response = REQUEST.RESPONSE
mime_type = 'application/hal+json'
if REQUEST.other['method'] != "GET":
response.setStatus(405)
return ""
elif mime_type != context.Base_handleAcceptHeader([mime_type]):
response.setStatus(406)
return ""
elif context.getPortalType() != "Compute Node":
response.setStatus(403)
return ""
import json
result_dict = {
'_links': {
"self": { "href": context.Base_getRequestUrl() },
"index": {
"href": "urn:jio:get:%s" % context.getRelativeUrl(),
"title": "Compute Node"
},
"content": [],
},
}
for sql_obj in context.getPortalObject().portal_catalog(
portal_type='Software Installation',
default_aggregate_uid=context.getUid(),
validation_state='validated',
):
obj = sql_obj.getObject()
result_dict['_links']['content'].append({
'href': '%s/ERP5Document_getHateoas' % obj.absolute_url(),
'title': obj.getUrlString()
})
response.setHeader('Content-Type', mime_type)
return json.dumps(result_dict, indent=2)
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</tuple>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>REQUEST=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ComputeNode_getHateoasSoftwareInstallationList</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
from zExceptions import Unauthorized
from AccessControl import getSecurityManager
if REQUEST is None:
raise Unauthorized
response = REQUEST.RESPONSE
mime_type = 'application/hal+json'
if REQUEST.other['method'] != "GET":
response.setStatus(405)
return ""
elif mime_type != context.Base_handleAcceptHeader([mime_type]):
response.setStatus(406)
return ""
elif context.getPortalType() != "Instance Tree":
response.setStatus(403)
return ""
import json
result_dict = {
'_links': {
"self": { "href": context.Base_getRequestUrl() },
"content": [],
"index": {
"href": "urn:jio:get:%s" % context.getRelativeUrl(),
"title": "Instance Tree"
},
},
}
for sql_obj in context.getPortalObject().portal_catalog(
portal_type=['Software Instance', 'Slave Instance'],
default_specialise_uid=context.getUid(),
):
obj = sql_obj.getObject()
result_dict['_links']['content'].append({
'href': '%s/ERP5Document_getHateoas' % obj.absolute_url(),
'title': obj.getTitle()
})
response.setHeader('Content-Type', mime_type)
return json.dumps(result_dict, indent=2)
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</tuple>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>REQUEST=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>InstanceTree_getHateoasInstanceList</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
from zExceptions import Unauthorized
from AccessControl import getSecurityManager
if REQUEST is None:
raise Unauthorized
response = REQUEST.RESPONSE
mime_type = 'application/hal+json'
if REQUEST.other['method'] != "GET":
response.setStatus(405)
return ""
elif mime_type != context.Base_handleAcceptHeader([mime_type]):
response.setStatus(406)
return ""
elif context.getPortalType() != "Instance Tree":
response.setStatus(403)
return ""
instance_list = context.getSuccessorValueList()
for instance in instance_list:
if instance.getTitle() == context.getTitle():
root_instance = instance
break
else:
raise Exception('Root instance not found.')
import json
result_dict = {
'_links': {
"self": { "href": context.Base_getRequestUrl() },
"content": [
{'href': '%s/ERP5Document_getHateoas' % root_instance.getAbsoluteUrl()},
],
"index": {
"href": "urn:jio:get:%s" % context.getRelativeUrl(),
"title": "Instance Tree"
},
},
}
response.setHeader('Content-Type', mime_type)
return json.dumps(result_dict, indent=2)
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</tuple>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>REQUEST=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>InstanceTree_getHateoasRootSoftwareInstance</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
from zExceptions import Unauthorized
from AccessControl import getSecurityManager
if REQUEST is None:
raise Unauthorized
response = REQUEST.RESPONSE
mime_type = 'application/hal+json'
if REQUEST.other['method'] != "GET":
response.setStatus(405)
return ""
elif mime_type != context.Base_handleAcceptHeader([mime_type]):
response.setStatus(406)
return ""
elif context.getPortalType() not in ["Software Instance", "Slave Instance"]:
response.setStatus(403)
return ""
if context.getSlapState() == "stop_requested":
state = 'stopped'
elif context.getSlapState() == "start_requested":
state = 'started'
else:
state = 'destroyed'
import json
result_dict = {
'title': context.getTitle(),
'slave': context.getPortalType() == 'Slave Instance',
'software_type': context.getSourceReference(),
'parameter_dict': context.getInstanceXmlAsDict(),
'sla_dict': context.getSlaXmlAsDict(),
'connection_dict': context.getConnectionXmlAsDict(),
'requested_state': state,
'instance_guid': context.getId(),
'_links': {
"self": { "href": context.Base_getRequestUrl() },
"index": {
"href": "urn:jio:get:%s" % context.getRelativeUrl(),
"title": "Software Instance",
},
'software_release': {
"href": context.getUrlString(),
}
},
}
response.setHeader('Content-Type', mime_type)
return json.dumps(result_dict, indent=2)
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</tuple>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>REQUEST=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Instance_getHateoasInformation</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
# This should be refactored
from zExceptions import Unauthorized
from AccessControl import getSecurityManager
if REQUEST is None:
raise Unauthorized
response = REQUEST.RESPONSE
mime_type = 'application/hal+json'
if REQUEST.other['method'] != "GET":
response.setStatus(405)
return ""
elif mime_type != context.Base_handleAcceptHeader([mime_type]):
response.setStatus(406)
return ""
elif context.getPortalType() not in ["Software Instance", "Slave Instance"]:
response.setStatus(403)
return ""
import json
memcached_dict = context.getPortalObject().portal_memcached.getMemcachedDict(
key_prefix='slap_tool',
plugin_path='portal_memcached/default_memcached_plugin')
try:
d = memcached_dict[context.getReference()]
except KeyError:
d = {
"user": "SlapOS Master",
"text": "#error no data found for %s" % context.getReference()
}
else:
d = json.loads(d)
result_dict = {
'news': [d],
'_links': {
"self": { "href": context.Base_getRequestUrl() },
# XXX current type
"index": {
"href": "urn:jio:get:%s" % context.getRelativeUrl(),
"title": "Software Instance"
},
},
}
response.setHeader('Content-Type', mime_type)
return json.dumps(result_dict, indent=2)
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</tuple>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>REQUEST=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Instance_getHateoasNews</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
from zExceptions import Unauthorized
from AccessControl import getSecurityManager
if REQUEST is None:
raise Unauthorized
response = REQUEST.RESPONSE
mime_type = 'application/hal+json'
if REQUEST.other['method'] != "GET":
response.setStatus(405)
return ""
elif mime_type != context.Base_handleAcceptHeader([mime_type]):
response.setStatus(406)
return ""
elif context.getPortalType() not in ["Software Instance", "Slave Instance"]:
response.setStatus(403)
return ""
if context.getSlapState() == "stop_requested":
state = 'stopped'
elif context.getSlapState() == "start_requested":
state = 'started'
else:
state = 'destroyed'
import json
result_dict = {
'_links': {
"self": { "href": context.Base_getRequestUrl() },
"index": {
"href": "urn:jio:get:%s" % context.getRelativeUrl(),
"title": "Software Instance",
},
'action_object_jump': {
"href": "%s/ERP5Document_getHateoas" % context.getSpecialiseValue().getAbsoluteUrl(),
"title": "Instance Tree",
}
},
}
response.setHeader('Content-Type', mime_type)
return json.dumps(result_dict, indent=2)
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</tuple>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>REQUEST=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Instance_getHateoasRelatedInstanceTree</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
from zExceptions import Unauthorized
if REQUEST is None:
raise Unauthorized
response = REQUEST.RESPONSE
mime_type = 'application/hal+json'
if REQUEST.other['method'] != "GET":
response.setStatus(405)
return ""
elif mime_type != context.Base_handleAcceptHeader([mime_type]):
response.setStatus(406)
return ""
elif context.getPortalType() != "Person":
response.setStatus(403)
return ""
import json
result_dict = {
'_links': {
"self": { "href": context.Base_getRequestUrl() },
# XXX current type
"index": {
"href": "urn:jio:get:%s" % context.getRelativeUrl(),
"title": "Person"
},
"content": [],
},
}
for sql_obj in context.getPortalObject().portal_catalog(
portal_type="Compute Node",
default_source_administration_uid=context.getUid(),
):
obj = sql_obj.getObject()
result_dict['_links']['content'].append({
'href': '%s/ERP5Document_getHateoas' % obj.absolute_url(),
'title': obj.getTitle(),
})
response.setHeader('Content-Type', mime_type)
return json.dumps(result_dict, indent=2)
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</tuple>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>REQUEST=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Person_getHateoasComputeNodeList</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
from zExceptions import Unauthorized
from AccessControl import getSecurityManager
if REQUEST is None:
raise Unauthorized
response = REQUEST.RESPONSE
mime_type = 'application/hal+json'
if REQUEST.other['method'] != "GET":
response.setStatus(405)
return ""
elif mime_type != context.Base_handleAcceptHeader([mime_type]):
response.setStatus(406)
return ""
elif context.getPortalType() != "Person":
response.setStatus(403)
return ""
import json
result_dict = {
'_links': {
"self": { "href": context.Base_getRequestUrl() },
# XXX current type
"index": {
"href": "urn:jio:get:%s" % context.getRelativeUrl(),
"title": "Person"
},
"content": [],
},
}
for sql_obj in context.getPortalObject().portal_catalog(
portal_type="Instance Tree",
default_destination_section_uid=context.getUid(),
validation_state="validated"
):
obj = sql_obj.getObject()
result_dict['_links']['content'].append({
'href': '%s/ERP5Document_getHateoas' % obj.absolute_url(),
'title': obj.getTitle()
})
response.setHeader('Content-Type', mime_type)
return json.dumps(result_dict, indent=2)
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</tuple>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>REQUEST=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Person_getHateoasInstanceTreeList</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
from zExceptions import Unauthorized
from AccessControl import getSecurityManager
if REQUEST is None:
raise Unauthorized
response = REQUEST.RESPONSE
mime_type = 'application/hal+json'
if REQUEST.other['method'] != "GET":
response.setStatus(405)
return ""
elif mime_type != context.Base_handleAcceptHeader([mime_type]):
response.setStatus(406)
return ""
elif context.getPortalType() not in ["Software Installation"]:
response.setStatus(403)
return ""
else:
if context.getSlapState() == "stop_requested":
state = 'stopped'
elif context.getSlapState() == "start_requested":
state = 'started'
else:
state = 'destroyed'
import json
result_dict = {
'title': context.getTitle(),
'status': state,
'_links': {
"self": { "href": context.Base_getRequestUrl() },
"index": {
"href": "urn:jio:get:%s" % context.getRelativeUrl(),
"title": "Software Installation"
},
},
}
url_string = context.getUrlString(None)
if url_string is not None:
result_dict["_links"]["software_release"] = { "href": url_string }
response.setHeader('Content-Type', mime_type)
return json.dumps(result_dict)
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</tuple>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>REQUEST=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>SoftwareInstallation_getHateoasInformation</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
from zExceptions import Unauthorized
from AccessControl import getSecurityManager
if REQUEST is None:
raise Unauthorized
response = REQUEST.RESPONSE
mime_type = 'application/hal+json'
if REQUEST.other['method'] != "GET":
response.setStatus(405)
return ""
elif mime_type != context.Base_handleAcceptHeader([mime_type]):
response.setStatus(406)
return ""
elif context.getPortalType() not in ["Software Installation"]:
raise
response.setStatus(403)
return ""
import json
memcached_dict = context.getPortalObject().portal_memcached.getMemcachedDict(
key_prefix='slap_tool',
plugin_path='portal_memcached/default_memcached_plugin')
try:
d = memcached_dict[context.getReference()]
except KeyError:
d = {
"user": "SlapOS Master",
"text": "#error no data found for %s" % context.getReference()
}
else:
d = json.loads(d)
result_dict = {
'news': [d],
'_links': {
"self": { "href": context.Base_getRequestUrl() },
# XXX current type
"index": {
"href": "urn:jio:get:%s" % context.getRelativeUrl(),
"title": "Software Instance"
},
},
}
response.setHeader('Content-Type', mime_type)
return json.dumps(result_dict, indent=2)
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</tuple>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>REQUEST=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>SoftwareInstallation_getHateoasNews</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
# -*- coding: utf-8 -*-
# Copyright (c) 2002-2013 Nexedi SA and Contributors. All Rights Reserved.
from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixin
import json
import httplib
import urlparse
import base64
from unittest import skip
def hateoasGetLinkFromLinks(links, title):
if type(links) == dict:
if links.get('title') == title:
return links
return
for action in links:
if action.get('title') == title:
return action
def getRelativeUrlFromUrn(urn):
urn_schema = 'urn:jio:get:'
try:
_, url = urn.split(urn_schema)
except ValueError:
return
return url
class TestSlapOSHypermediaPersonScenario(SlapOSTestCaseMixin):
def _makeUser(self):
person_user = self.makePerson()
login = person_user.objectValues("ERP5 Login")[0]
login.edit(
reference=person_user.getReference(),
password=person_user.getReference())
self.tic()
return person_user
@skip("Hypermedia is not supported anymore.")
def test(self):
erp5_person = self._makeUser()
self.tic()
self.portal.changeSkin('Hal')
self.tic()
authorization = 'Basic %s' % base64.b64encode(
"%s:%s" % (erp5_person.getReference(), erp5_person.getReference()))
content_type = "application/hal+json"
api_scheme, api_netloc, api_path, api_query, \
api_fragment = urlparse.urlsplit(self.portal.absolute_url())
def getNewHttpConnection(api_netloc):
if api_scheme == 'https':
raise Exception('Please connect directly to the Zope server')
connection = httplib.HTTPConnection(api_netloc)
return connection
#####################################################
# Access the master home page hal
#####################################################
connection = getNewHttpConnection(api_netloc)
connection.request(
method='GET',
url='%s/web_site_module/hateoas/' % \
self.portal.absolute_url(),
headers={
'Authorization': authorization,
'Accept': content_type,
},
body="",
)
response = connection.getresponse()
self.assertEqual(response.status, 200)
self.assertEqual(response.getheader('Content-Type'), content_type)
home_page_hal = json.loads(response.read())
#####################################################
# Fetch the user hal
#####################################################
user_link_dict = home_page_hal['_links']['me']
self.assertNotEqual(user_link_dict, None)
traverse_url_template = home_page_hal['_links']['traverse']['href']
me_relative_url = getRelativeUrlFromUrn(user_link_dict['href'])
me_url = traverse_url_template.replace(
'{&relative_url,view}',
'&relative_url=%s&view=view' % me_relative_url
)
connection = getNewHttpConnection(api_netloc)
connection.request(
method=user_link_dict.get('method', 'GET'),
url=me_url,
headers={
'Authorization': authorization,
'Accept': content_type,
},
body="",
)
response = connection.getresponse()
self.assertEqual(response.status, 200)
self.assertEqual(response.getheader('Content-Type'), content_type)
user_hal = json.loads(response.read())
#####################################################
# Run method to request an instance tree
#####################################################
request_link_dict = hateoasGetLinkFromLinks(
user_hal['_links']['action_object_slap_post'],
'requestHateoasInstanceTree'
)
self.assertNotEqual(request_link_dict, None)
connection = getNewHttpConnection(api_netloc)
connection.request(
method=request_link_dict.get('method', 'POST'),
url=request_link_dict['href'],
headers={
'Authorization': authorization,
'Content-Type': 'application/json',
},
body=json.dumps({
'software_release': 'http://example.orgé',
'title': 'a great titleé',
'software_type': 'fooé',
'parameter': {'param1é': 'value1é', 'param2é': 'value2é'},
'sla': {'param3é': 'value3é', 'param4é': 'value4é'},
'slave': False,
'status': 'started',
}),
)
response = connection.getresponse()
self.assertEqual(response.status, 201)
self.tic()
#####################################################
# Get user's instance tree list
#####################################################
user_link_dict = hateoasGetLinkFromLinks(
user_hal['_links']['action_object_slap'],
'getHateoasInstanceTreeList'
)
self.assertNotEqual(user_link_dict, None)
connection = getNewHttpConnection(api_netloc)
connection.request(
method=user_link_dict.get('method', 'GET'),
url=user_link_dict['href'],
headers={
'Authorization': authorization,
'Accept': content_type,
},
body="",
)
response = connection.getresponse()
self.assertEqual(response.status, 200)
self.assertEqual(response.getheader('Content-Type'), content_type)
subscription_collection_hal = json.loads(response.read())
#####################################################
# Get user's instance tree
#####################################################
subscription_link_dict = subscription_collection_hal['_links']\
['content'][0]
self.assertNotEqual(subscription_link_dict, None)
connection = getNewHttpConnection(api_netloc)
connection.request(
method=subscription_link_dict.get('method', 'GET'),
url=subscription_link_dict['href'],
headers={
'Authorization': authorization,
'Accept': content_type,
},
body="",
)
response = connection.getresponse()
self.assertEqual(response.status, 200)
self.assertEqual(response.getheader('Content-Type'), content_type)
subscription_hal = json.loads(response.read())
#####################################################
# Get instance tree's instance list
#####################################################
user_link_dict = hateoasGetLinkFromLinks(
subscription_hal['_links']['action_object_slap'],
'getHateoasInstanceList'
)
self.assertNotEqual(user_link_dict, None)
connection = getNewHttpConnection(api_netloc)
connection.request(
method=user_link_dict.get('method', 'GET'),
url=user_link_dict['href'],
headers={
'Authorization': authorization,
'Accept': content_type,
},
body="",
)
response = connection.getresponse()
self.assertEqual(response.status, 200)
self.assertEqual(response.getheader('Content-Type'), content_type)
instance_collection_hal = json.loads(response.read())
#####################################################
# Get instance
#####################################################
subscription_link_dict = instance_collection_hal['_links']\
['content'][0]
self.assertNotEqual(subscription_link_dict, None)
connection = getNewHttpConnection(api_netloc)
connection.request(
method=subscription_link_dict.get('method', 'GET'),
url=subscription_link_dict['href'],
headers={
'Authorization': authorization,
'Accept': content_type,
},
body="",
)
response = connection.getresponse()
self.assertEqual(response.status, 200)
self.assertEqual(response.getheader('Content-Type'), content_type)
instance_hal = json.loads(response.read())
#####################################################
# Fetch instance informations
#####################################################
request_link_dict = hateoasGetLinkFromLinks(
instance_hal['_links']['action_object_slap'],
'getHateoasInformation'
)
self.assertNotEqual(request_link_dict, None)
connection = getNewHttpConnection(api_netloc)
connection.request(
method=request_link_dict.get('method', 'GET'),
url=request_link_dict['href'],
headers={
'Authorization': authorization,
'Accept': content_type,
},
body="",
)
response = connection.getresponse()
self.assertEqual(response.status, 200)
self.assertEqual(response.getheader('Content-Type'), content_type)
self.tic()
#####################################################
# Get instance news
#####################################################
news_link_dict = hateoasGetLinkFromLinks(
instance_hal['_links']['action_object_slap'],
'getHateoasNews'
)
self.assertNotEqual(news_link_dict, None)
connection = getNewHttpConnection(api_netloc)
connection.request(
method=news_link_dict.get('method', 'GET'),
url=news_link_dict['href'],
headers={
'Authorization': authorization,
'Accept': content_type,
},
body="",
)
response = connection.getresponse()
self.assertEqual(response.status, 200)
self.assertEqual(response.getheader('Content-Type'), content_type)
news_hal = json.loads(response.read())
# We are going to check compute_node and software
# First create a compute_node and a software. We could alternatively later
# create them through hypermedia links
self.login(erp5_person.getUserId())
self.portal.portal_slap.requestComputer(
"compute node %s" % erp5_person.getReference())
self.tic()
compute_node = self.portal.portal_catalog(portal_type="Compute Node",
sort_on=[('creation_date','descending')])[0].getObject()
self.tic()
self.portal.portal_slap.supplySupply("http://foo.com/software.cfg",
compute_node.getReference(), "available")
self.tic()
self.logout()
#####################################################
# Get user's compute_node list
#####################################################
user_link_dict = hateoasGetLinkFromLinks(
user_hal['_links']['action_object_slap'],
'getHateoasComputeNodeList'
)
self.assertNotEqual(user_link_dict, None)
connection = getNewHttpConnection(api_netloc)
connection.request(
method=user_link_dict.get('method', 'GET'),
url=user_link_dict['href'],
headers={
'Authorization': authorization,
'Accept': content_type,
},
body="",
)
response = connection.getresponse()
self.assertEqual(response.status, 200)
self.assertEqual(response.getheader('Content-Type'), content_type)
compute_node_collection_hal = json.loads(response.read())
#####################################################
# Get user's compute_node
#####################################################
compute_node_link_dict = compute_node_collection_hal['_links']\
['content'][0]
self.assertNotEqual(compute_node_link_dict, None)
connection = getNewHttpConnection(api_netloc)
connection.request(
method=compute_node_link_dict.get('method', 'GET'),
url=compute_node_link_dict['href'],
headers={
'Authorization': authorization,
'Accept': content_type,
},
body="",
)
response = connection.getresponse()
self.assertEqual(response.status, 200)
self.assertEqual(response.getheader('Content-Type'), content_type)
compute_node_hal = json.loads(response.read())
#####################################################
# Get compute_node's software list
#####################################################
compute_node_link_dict = hateoasGetLinkFromLinks(
compute_node_hal['_links']['action_object_slap'],
'getHateoasSoftwareInstallationList'
)
self.assertNotEqual(compute_node_link_dict, None)
connection = getNewHttpConnection(api_netloc)
connection.request(
method=compute_node_link_dict.get('method', 'GET'),
url=compute_node_link_dict['href'],
headers={
'Authorization': authorization,
'Accept': content_type,
},
body="",
)
response = connection.getresponse()
self.assertEqual(response.status, 200)
self.assertEqual(response.getheader('Content-Type'), content_type)
software_collection_hal = json.loads(response.read())
#####################################################
# Get user's software
#####################################################
software_link_dict = software_collection_hal['_links']\
['content'][0]
self.assertNotEqual(software_link_dict, None)
connection = getNewHttpConnection(api_netloc)
connection.request(
method=software_link_dict.get('method', 'GET'),
url=software_link_dict['href'],
headers={
'Authorization': authorization,
'Accept': content_type,
},
body="",
)
response = connection.getresponse()
self.assertEqual(response.getheader('Content-Type'), content_type)
software_hal = json.loads(response.read())
class TestSlapOSHypermediaInstanceScenario(SlapOSTestCaseMixin):
def generateNewId(self):
return "%shype" % self.portal.portal_ids.generateNewId(
id_group=('slapos_core_test'))
def generateNewSoftwareReleaseUrl(self):
return 'http://example.org/test%s.cfg' % self.generateNewId()
def generateNewSoftwareType(self):
return 'Type %s' % self.generateNewId()
def generateNewSoftwareTitle(self):
return 'Title %s' % self.generateNewId()
@skip("Hypermedia is not supported anymore.")
def test(self):
self._makeTree()
instance = self.software_instance
self._addERP5Login(self.software_instance)
self.portal.changeSkin('Hal')
self.tic()
remote_user = instance.getUserId()
content_type = "application/hal+json"
api_scheme, api_netloc, api_path, api_query, \
api_fragment = urlparse.urlsplit(self.portal.absolute_url())
def getNewHttpConnection(api_netloc):
if api_scheme == 'https':
raise Exception('Please connect directly to the Zope server')
connection = httplib.HTTPConnection(api_netloc)
return connection
#####################################################
# Access the master home page hal
#####################################################
connection = getNewHttpConnection(api_netloc)
connection.request(
method='GET',
url='%s/web_site_module/hateoas/' % \
self.portal.absolute_url(),
headers={
'REMOTE_USER': remote_user,
'Accept': content_type,
},
body="",
)
response = connection.getresponse()
self.assertEqual(response.status, 200, response)
self.assertEqual(response.getheader('Content-Type'), content_type)
home_page_hal = json.loads(response.read())
#####################################################
# Fetch the instance hal
#####################################################
user_link_dict = home_page_hal['_links']['me']
self.assertNotEqual(user_link_dict, None)
traverse_url_template = home_page_hal['_links']['traverse']['href']
me_relative_url = getRelativeUrlFromUrn(user_link_dict['href'])
me_url = traverse_url_template.replace(
'{&relative_url,view}',
'&relative_url=%s&view=view' % me_relative_url
)
connection = getNewHttpConnection(api_netloc)
connection.request(
method=user_link_dict.get('method', 'GET'),
url=me_url,
headers={
'REMOTE_USER': remote_user,
'Accept': content_type,
},
body="",
)
response = connection.getresponse()
self.assertEqual(response.status, 200)
self.assertEqual(response.getheader('Content-Type'), content_type)
instance_hal = json.loads(response.read())
#####################################################
# Fetch instance informations
#####################################################
user_link_dict = hateoasGetLinkFromLinks(
instance_hal['_links']['action_object_slap'],
'getHateoasInformation'
)
self.assertNotEqual(user_link_dict, None)
connection = getNewHttpConnection(api_netloc)
connection.request(
method=user_link_dict.get('method', 'GET'),
url=user_link_dict['href'],
headers={
'REMOTE_USER': remote_user,
'Accept': content_type,
},
body="",
)
response = connection.getresponse()
self.assertEqual(response.status, 200)
self.assertEqual(response.getheader('Content-Type'), content_type)
self.tic()
#####################################################
# Get instance news
#####################################################
user_link_dict = hateoasGetLinkFromLinks(
instance_hal['_links']['action_object_slap'],
'getHateoasNews'
)
self.assertNotEqual(user_link_dict, None)
connection = getNewHttpConnection(api_netloc)
connection.request(
method=user_link_dict.get('method', 'GET'),
url=user_link_dict['href'],
headers={
'REMOTE_USER': remote_user,
'Accept': content_type,
},
body="",
)
response = connection.getresponse()
self.assertEqual(response.status, 200)
self.assertEqual(response.getheader('Content-Type'), content_type)
self.tic()
#####################################################
# Get instance tree of instance
#####################################################
# XXX can be simpler and doesn't need getHateoasRelatedInstanceTree script
hosting_link_dict = hateoasGetLinkFromLinks(
instance_hal['_links']['action_object_slap'],
'getHateoasRelatedInstanceTree'
)
self.assertNotEqual(hosting_link_dict, None)
connection = getNewHttpConnection(api_netloc)
connection.request(
method=hosting_link_dict.get('method', 'GET'),
url=hosting_link_dict['href'],
headers={
'REMOTE_USER': remote_user,
'Accept': content_type,
},
body="",
)
response = connection.getresponse()
self.assertEqual(response.status, 200)
self.assertEqual(response.getheader('Content-Type'), content_type)
subscription_hal = json.loads(response.read())
self.tic()
hosting_link_dict = hateoasGetLinkFromLinks(
subscription_hal['_links']['action_object_jump'],
'Instance Tree'
)
self.assertNotEqual(hosting_link_dict, None)
connection = getNewHttpConnection(api_netloc)
connection.request(
method=hosting_link_dict.get('method', 'GET'),
url=hosting_link_dict['href'],
headers={
'REMOTE_USER': remote_user,
'Accept': content_type,
},
body="",
)
response = connection.getresponse()
self.assertEqual(response.status, 200)
self.assertEqual(response.getheader('Content-Type'), content_type)
subscription_hal = json.loads(response.read())
self.tic()
#####################################################
# Get instance tree's instance list
#####################################################
user_link_dict = hateoasGetLinkFromLinks(
subscription_hal['_links']['action_object_slap'],
'getHateoasInstanceList'
)
self.assertNotEqual(user_link_dict, None)
connection = getNewHttpConnection(api_netloc)
connection.request(
method=user_link_dict.get('method', 'GET'),
url=user_link_dict['href'],
headers={
'REMOTE_USER': remote_user,
'Accept': content_type,
},
body="",
)
response = connection.getresponse()
self.assertEqual(response.status, 200)
self.assertEqual(response.getheader('Content-Type'), content_type)
instance_collection_hal = json.loads(response.read())
#####################################################
# Get instance
#####################################################
subscription_link_dict = instance_collection_hal['_links']\
['content'][0]
self.assertNotEqual(subscription_link_dict, None)
connection = getNewHttpConnection(api_netloc)
connection.request(
method=subscription_link_dict.get('method', 'GET'),
url=subscription_link_dict['href'],
headers={
'REMOTE_USER': remote_user,
'Accept': content_type,
},
body="",
)
response = connection.getresponse()
self.assertEqual(response.status, 200)
self.assertEqual(response.getheader('Content-Type'), content_type)
instance_hal = json.loads(response.read())
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Test Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>testSlapOSHypermediaScenario</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test.erp5.testSlapOSHypermediaScenario</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Test Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple>
<string>W: 12, 5: Using type() instead of isinstance() for a typecheck. (unidiomatic-typecheck)</string>
<string>W: 50, 28: Unused variable \'api_path\' (unused-variable)</string>
<string>W:281, 4: Unused variable \'news_hal\' (unused-variable)</string>
<string>W: 51, 8: Unused variable \'api_fragment\' (unused-variable)</string>
<string>W: 50, 38: Unused variable \'api_query\' (unused-variable)</string>
<string>W:386, 4: Unused variable \'software_hal\' (unused-variable)</string>
<string>W:417, 28: Unused variable \'api_path\' (unused-variable)</string>
<string>W:417, 38: Unused variable \'api_query\' (unused-variable)</string>
<string>W:418, 8: Unused variable \'api_fragment\' (unused-variable)</string>
</tuple>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<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>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
</ZopeData>
# -*- coding: utf-8 -*-
# Copyright (c) 2002-2013 Nexedi SA and Contributors. All Rights Reserved.
from erp5.component.test.SlapOSTestCaseMixin import \
SlapOSTestCaseMixinWithAbort, changeSkin, simulate
from erp5.component.test.testHalJsonStyle import \
do_fake_request
import json
from zExceptions import Unauthorized
class TestSlapOSHypermediaMixin(SlapOSTestCaseMixinWithAbort):
def afterSetUp(self):
SlapOSTestCaseMixinWithAbort.afterSetUp(self)
self.changeSkin('Hal')
def _makePerson(self):
person_user = self.makePerson()
self.tic()
self.changeSkin('Hal')
return person_user
def _makeInstanceTree(self):
instance_tree = self.portal.instance_tree_module\
.template_instance_tree.Base_createCloneDocument(batch_mode=1)
instance_tree.validate()
self.tic()
self.changeSkin('Hal')
return instance_tree
def _makeInstance(self):
instance = self.portal.software_instance_module\
.template_software_instance.Base_createCloneDocument(batch_mode=1)
instance.validate()
self.tic()
return instance
def _makeComputeNode(self):
compute_node = self.portal.compute_node_module\
.template_compute_node.Base_createCloneDocument(batch_mode=1)
compute_node.validate()
self.tic()
return compute_node
def _makeSoftwareInstallation(self):
software_installation = self.portal.software_installation_module\
.template_software_installation.Base_createCloneDocument(batch_mode=1)
software_installation.validate()
self.tic()
return software_installation
class TestSlapOSPersonERP5Document_getHateoas(TestSlapOSHypermediaMixin):
@simulate('Base_getRequestHeader', '*args, **kwargs',
'return "application/vnd+bar"')
@changeSkin('Hal')
def test_getHateoasPerson_wrong_ACCEPT(self):
person_user = self._makePerson()
fake_request = do_fake_request("GET")
result = person_user.ERP5Document_getHateoas(REQUEST=fake_request)
self.assertEqual(fake_request.RESPONSE.status, 406)
self.assertEqual(result, "")
@simulate('Base_getRequestHeader', '*args, **kwargs',
'return "application/hal+json"')
@changeSkin('Hal')
def test_getHateoasPerson_bad_method(self):
person_user = self._makePerson()
fake_request = do_fake_request("POST")
result = person_user.ERP5Document_getHateoas(REQUEST=fake_request)
self.assertEqual(fake_request.RESPONSE.status, 405)
self.assertEqual(result, "")
@simulate('Base_getRequestUrl', '*args, **kwargs',
'return "http://example.org/bar"')
@simulate('Base_getRequestHeader', '*args, **kwargs',
'return "application/hal+json"')
@changeSkin('Hal')
def test_getHateoasPerson_result(self):
person_user = self._makePerson()
fake_request = do_fake_request("GET")
result = person_user.ERP5Document_getHateoas(REQUEST=fake_request)
self.assertEqual(fake_request.RESPONSE.status, 200)
self.assertEqual(fake_request.RESPONSE.getHeader('Content-Type'),
"application/hal+json"
)
results = json.loads(result)
action_object_slap = results['_links']['action_object_slap']
self.assertEqual(len(action_object_slap), 3)
for action in [
{
u'href': u'%s/Person_getHateoasComputeNodeList' % \
person_user.absolute_url(),
u'name': u'get_hateoas_compute_node_list',
u'icon': u'',
u'title': u'getHateoasComputeNodeList'
},
{
u'href': u'%s/Person_getHateoasInstanceTreeList' % \
person_user.absolute_url(),
u'name': u'get_hateoas_instance_tree_list',
u'icon': u'',
u'title': u'getHateoasInstanceTreeList'
},
{
u'href': u'%s/Person_getHateoasInformation' % \
person_user.absolute_url(),
u'name': u'get_hateoas_information',
u'icon': u'',
u'title': u'getHateoasInformation'
},
]:
self.assertTrue(action in action_object_slap, \
"%s not in %s" % (action, action_object_slap))
self.assertEqual(results['_links']['action_object_slap_post'], {
u"href": u'%s/Person_requestHateoasInstanceTree' % \
person_user.absolute_url(),
u"name": u"request_hateoas_instance_tree",
u'icon': u'',
u"title": u"requestHateoasInstanceTree"
})
class TestSlapOSERP5Document_getHateoas_me(TestSlapOSHypermediaMixin):
"""
Complementary tests to ensure "me" is present on the request.
"""
@simulate('Base_getRequestUrl', '*args, **kwargs',
'return "http://example.org/bar"')
@simulate('Base_getRequestHeader', '*args, **kwargs',
'return "application/hal+json"')
@changeSkin('Hal')
def _test_me(self, me=None):
self.changeSkin('Hal')
fake_request = do_fake_request("GET")
result = self.portal.ERP5Document_getHateoas(REQUEST=fake_request)
self.assertEqual(fake_request.RESPONSE.status, 200)
self.assertEqual(fake_request.RESPONSE.getHeader('Content-Type'),
"application/hal+json"
)
result = json.loads(result)
self.assertEqual(result['_links']['self'],
{"href": "http://example.org/bar"}
)
self.assertEqual(result['_links'].get('me'), me)
def test_me_annonymous(self):
self.logout()
self._test_me()
def test_me_person(self):
person_user = self._makePerson()
self.login(person_user.getUserId())
self._test_me(
{"href": "urn:jio:get:%s" % person_user.getRelativeUrl()})
def test_me_instance(self):
self._makeTree()
self.login(self.software_instance.getUserId())
self._test_me(
{"href": "urn:jio:get:%s" % self.software_instance.getRelativeUrl()}
)
def test_me_compute_node(self):
compute_node = self._makeComputeNode()
self.tic()
self.login(compute_node.getUserId())
self._test_me(
{"href": "urn:jio:get:%s" % compute_node.getRelativeUrl()}
)
class TestSlapOSPerson_requestHateoasInstanceTree(TestSlapOSHypermediaMixin):
@changeSkin('Hal')
def test_requestHateoasInstanceTree_REQUEST_mandatory(self):
self.assertRaises(
Unauthorized,
self.portal.Person_requestHateoasInstanceTree
)
@simulate('Base_getRequestHeader', '*args, **kwargs',
'return "application/vnd+bar"')
@changeSkin('Hal')
def test_requestHateoasInstanceTree_wrong_CONTENT(self):
person_user = self._makePerson()
fake_request = do_fake_request("POST")
result = person_user.Person_requestHateoasInstanceTree(
REQUEST=fake_request)
self.assertEqual(fake_request.RESPONSE.status, 406)
self.assertEqual(result, "")
@simulate('Base_getRequestHeader', '*args, **kwargs',
'return "application/json"')
@changeSkin('Hal')
def test_requestHateoasInstanceTree_bad_method(self):
person_user = self._makePerson()
fake_request = do_fake_request("GET")
result = person_user.Person_requestHateoasInstanceTree(
REQUEST=fake_request)
self.assertEqual(fake_request.RESPONSE.status, 405)
self.assertEqual(result, "")
@simulate('Base_getRequestHeader', '*args, **kwargs',
'return "application/json"')
@changeSkin('Hal')
def test_requestHateoasInstanceTree_not_person_context(self):
fake_request = do_fake_request("POST")
result = self.portal.Person_requestHateoasInstanceTree(
REQUEST=fake_request)
self.assertEqual(fake_request.RESPONSE.status, 403)
self.assertEqual(result, "")
@simulate('Base_getRequestBody', '*args, **kwargs',
'return "[}"')
@simulate('Base_getRequestHeader', '*args, **kwargs',
'return "application/json"')
@changeSkin('Hal')
def test_requestHateoasInstanceTree_no_json(self):
person_user = self._makePerson()
fake_request = do_fake_request("POST")
result = person_user.Person_requestHateoasInstanceTree(
REQUEST=fake_request)
self.assertEqual(fake_request.RESPONSE.status, 400)
self.assertEqual(result, "")
@simulate('Base_getRequestBody', '*args, **kwargs',
'return "%s"' % json.dumps({
}))
@simulate('Base_getRequestHeader', '*args, **kwargs',
'return "application/json"')
@changeSkin('Hal')
def test_requestHateoasInstanceTree_missing_parameter(self):
person_user = self._makePerson()
fake_request = do_fake_request("POST")
result = person_user.Person_requestHateoasInstanceTree(
REQUEST=fake_request)
self.assertEqual(fake_request.RESPONSE.status, 400)
self.assertEqual(result, "")
@simulate('Base_getRequestBody', '*args, **kwargs',
'return """%s"""' % json.dumps({
'software_release': 'http://example.orgé',
'title': 'a great titleé',
'software_type': 'fooé',
'parameter': {'param1é': 'value1é', 'param2é': 'value2é'},
'sla': {'param3': 'value3é', 'param4é': 'value4é'},
'slave': False,
'status': 'started',
}))
@simulate('Base_getRequestHeader', '*args, **kwargs',
'return "application/json"')
@changeSkin('Hal')
def test_requestHateoasInstanceTree_result(self):
person_user = self._makePerson()
fake_request = do_fake_request("POST")
result = person_user.Person_requestHateoasInstanceTree(
REQUEST=fake_request)
self.assertEqual(fake_request.RESPONSE.status, 201)
self.assertEqual(result, "")
# XXX Test that person.request is called.
class TestSlapOSPerson_getHateoasInstanceTreeList(TestSlapOSHypermediaMixin):
@changeSkin('Hal')
def test_getHateoasInstanceTreeList_REQUEST_mandatory(self):
self.assertRaises(
Unauthorized,
self.portal.Person_getHateoasInstanceTreeList
)
@simulate('Base_getRequestHeader', '*args, **kwargs',
'return "application/vnd+bar"')
@changeSkin('Hal')
def test_getHateoasInstanceTreeList_wrong_ACCEPT(self):
person_user = self._makePerson()
fake_request = do_fake_request("GET")
result = person_user.Person_getHateoasInstanceTreeList(
REQUEST=fake_request)
self.assertEqual(fake_request.RESPONSE.status, 406)
self.assertEqual(result, "")
@simulate('Base_getRequestHeader', '*args, **kwargs',
'return "application/hal+json')
@changeSkin('Hal')
def test_getHateoasInstanceTreeList_bad_method(self):
fake_request = do_fake_request("POST")
result = self.portal.Person_getHateoasInstanceTreeList(
REQUEST=fake_request)
self.assertEqual(fake_request.RESPONSE.status, 405)
self.assertEqual(result, "")
@simulate('Base_getRequestHeader', '*args, **kwargs',
'return "application/hal+json"')
@changeSkin('Hal')
def test_getHateoasInstanceTreeList_not_person_context(self):
fake_request = do_fake_request("GET")
result = self.portal.Person_getHateoasInstanceTreeList(
REQUEST=fake_request)
self.assertEqual(fake_request.RESPONSE.status, 403)
self.assertEqual(result, "")
@simulate('Base_getRequestUrl', '*args, **kwargs',
'return "http://example.org/foo"')
@simulate('Base_getRequestHeader', '*args, **kwargs',
'return "application/hal+json"')
def test_getHateoasInstanceTreeList_person_result(self):
person_user = self._makePerson()
instance_tree = self._makeInstanceTree()
instance_tree.edit(destination_section_value=person_user)
self.tic()
self.login(person_user.getUserId())
self.changeSkin('Hal')
fake_request = do_fake_request("GET")
result = person_user.Person_getHateoasInstanceTreeList(
REQUEST=fake_request)
self.assertEqual(fake_request.RESPONSE.status, 200)
self.assertEqual(fake_request.RESPONSE.getHeader('Content-Type'),
"application/hal+json"
)
self.assertEqual(result, json.dumps({
'_links': {
"self": {
"href": "http://example.org/foo",
},
"index": {
"href": "urn:jio:get:%s" % person_user.getRelativeUrl(),
"title": "Person"
},
"content": [{
"href": "%s/ERP5Document_getHateoas" % \
instance_tree.absolute_url(),
"title": "Template Instance Tree"
}],
},
}, indent=2))
class TestSlapOSInstanceTree_getHateoasInstanceList(TestSlapOSHypermediaMixin):
@changeSkin('Hal')
def test_getHateoasInstanceList_REQUEST_mandatory(self):
self.assertRaises(
Unauthorized,
self.portal.InstanceTree_getHateoasInstanceList
)
@simulate('Base_getRequestHeader', '*args, **kwargs',
'return "application/vnd+bar"')
@changeSkin('Hal')
def test_getHateoasInstanceList_wrong_ACCEPT(self):
subscription = self._makeInstanceTree()
fake_request = do_fake_request("GET")
result = subscription.InstanceTree_getHateoasInstanceList(
REQUEST=fake_request)
self.assertEqual(fake_request.RESPONSE.status, 406)
self.assertEqual(result, "")
@simulate('Base_getRequestHeader', '*args, **kwargs',
'return "application/hal+json"')
@changeSkin('Hal')
def test_getHateoasInstanceList_bad_method(self):
fake_request = do_fake_request("POST")
result = self.portal.InstanceTree_getHateoasInstanceList(
REQUEST=fake_request)
self.assertEqual(fake_request.RESPONSE.status, 405)
self.assertEqual(result, "")
@simulate('Base_getRequestHeader', '*args, **kwargs',
'return "application/hal+json"')
@changeSkin('Hal')
def test_getHateoasInstanceList_not_instance_tree_context(self):
fake_request = do_fake_request("GET")
result = self.portal.InstanceTree_getHateoasInstanceList(
REQUEST=fake_request)
self.assertEqual(fake_request.RESPONSE.status, 403)
self.assertEqual(result, "")
@simulate('Base_getRequestUrl', '*args, **kwargs',
'return "http://example.org/bar"')
@simulate('Base_getRequestHeader', '*args, **kwargs',
'return "application/hal+json"')
@changeSkin('Hal')
def test_getHateoasInstanceList_person_result(self):
subscription = self._makeInstanceTree()
instance= self._makeInstance()
instance.edit(specialise_value=subscription)
self.tic()
fake_request = do_fake_request("GET")
result = subscription.InstanceTree_getHateoasInstanceList(
REQUEST=fake_request)
self.assertEqual(fake_request.RESPONSE.status, 200)
self.assertEqual(fake_request.RESPONSE.getHeader('Content-Type'),
"application/hal+json"
)
self.assertEqual(result, json.dumps({
'_links': {
"self": {
"href": "http://example.org/bar"
},
"content": [{
"href": "%s/ERP5Document_getHateoas" % \
instance.absolute_url(),
"title": "Template Software Instance"
}],
"index": {
"href": "urn:jio:get:%s" % subscription.getRelativeUrl(),
"title": "Instance Tree"
},
},
}, indent=2))
class TestSlapOSInstanceTree_getHateoasRootSoftwareInstance(TestSlapOSHypermediaMixin):
@changeSkin('Hal')
def test_getHateoasRootSoftwareInstance_REQUEST_mandatory(self):
self.assertRaises(
Unauthorized,
self.portal.InstanceTree_getHateoasRootSoftwareInstance
)
@simulate('Base_getRequestHeader', '*args, **kwargs',
'return "application/vnd+bar"')
@changeSkin('Hal')
def test_getHateoasRootSoftwareInstance_wrong_ACCEPT(self):
subscription = self._makeInstanceTree()
fake_request = do_fake_request("GET")
result = subscription.InstanceTree_getHateoasRootSoftwareInstance(
REQUEST=fake_request)
self.assertEqual(fake_request.RESPONSE.status, 406)
self.assertEqual(result, "")
@simulate('Base_getRequestHeader', '*args, **kwargs',
'return "application/hal+json"')
@changeSkin('Hal')
def test_getHateoasRootSoftwareInstance_bad_method(self):
fake_request = do_fake_request("POST")
result = self.portal.InstanceTree_getHateoasRootSoftwareInstance(
REQUEST=fake_request)
self.assertEqual(fake_request.RESPONSE.status, 405)
self.assertEqual(result, "")
@simulate('Base_getRequestHeader', '*args, **kwargs',
'return "application/hal+json"')
@changeSkin('Hal')
def test_getHateoasRootSoftwareInstance_not_instance_tree_context(self):
fake_request = do_fake_request("GET")
result = self.portal.InstanceTree_getHateoasRootSoftwareInstance(
REQUEST=fake_request)
self.assertEqual(fake_request.RESPONSE.status, 403)
self.assertEqual(result, "")
@simulate('Base_getRequestUrl', '*args, **kwargs',
'return "http://example.org/bar"')
@simulate('Base_getRequestHeader', '*args, **kwargs',
'return "application/hal+json"')
@changeSkin('Hal')
def test_getHateoasRootSoftwareInstance_person_result(self):
subscription = self._makeInstanceTree()
instance = self._makeInstance()
instance.edit(specialise_value=subscription, title=subscription.getTitle())
subscription.edit(successor_value=instance)
self.tic()
fake_request = do_fake_request("GET")
result = subscription.InstanceTree_getHateoasRootSoftwareInstance(
REQUEST=fake_request)
self.assertEqual(fake_request.RESPONSE.status, 200)
self.assertEqual(fake_request.RESPONSE.getHeader('Content-Type'),
"application/hal+json"
)
self.assertEqual(result, json.dumps({
'_links': {
"self": {
"href": "http://example.org/bar"
},
"content": [{
"href": "%s/ERP5Document_getHateoas" % \
instance.absolute_url(),
}],
"index": {
"href": "urn:jio:get:%s" % subscription.getRelativeUrl(),
"title": "Instance Tree"
},
},
}, indent=2))
class TestSlapOSInstance_getHateoasNews(TestSlapOSHypermediaMixin):
def _makeInstance(self):
instance = self.portal.software_instance_module\
.template_software_instance.Base_createCloneDocument(batch_mode=1)
instance.edit(
title=self.generateNewSoftwareTitle(),
reference="TESTHS-%s" % self.generateNewId(),
software_type=self.generateNewSoftwareType(),
url_string=self.generateNewSoftwareReleaseUrl(),
instance_xml=self.generateSafeXml(),
sla_xml=self.generateSafeXml(),
connection_xml=self.generateSafeXml(),
)
self._addERP5Login(instance)
self.tic()
return instance
@changeSkin('Hal')
def test_getHateoasNewsInstance_REQUEST_mandatory(self):
self.assertRaises(
Unauthorized,
self.portal.Instance_getHateoasNews
)
@simulate('Base_getRequestHeader', '*args, **kwargs',
'return "application/vnd+bar"')
@changeSkin('Hal')
def test_getHateoasNewsInstance_wrong_ACCEPT(self):
instance = self._makeInstance()
fake_request = do_fake_request("GET")
result = instance.Instance_getHateoasNews(
REQUEST=fake_request)
self.assertEqual(fake_request.RESPONSE.status, 406)
self.assertEqual(result, "")
@simulate('Base_getRequestHeader', '*args, **kwargs',
'return "application/hal+json"')
@changeSkin('Hal')
def test_getHateoasNewsInstance_bad_method(self):
instance = self._makeInstance()
fake_request = do_fake_request("POST")
result = instance.Instance_getHateoasNews(
REQUEST=fake_request)
self.assertEqual(fake_request.RESPONSE.status, 405)
self.assertEqual(result, "")
@simulate('Base_getRequestHeader', '*args, **kwargs',
'return "application/hal+json"')
@changeSkin('Hal')
def test_getHateoasNewsInstance_not_instance_context(self):
fake_request = do_fake_request("GET")
result = self.portal.Instance_getHateoasNews(REQUEST=fake_request)
self.assertEqual(fake_request.RESPONSE.status, 403)
self.assertEqual(result, "")
@simulate('Base_getRequestUrl', '*args, **kwargs',
'return "http://example.org/bar"')
@simulate('Base_getRequestHeader', '*args, **kwargs',
'return "application/hal+json"')
@changeSkin('Hal')
def test_getHateoasNewsInstance_result(self):
instance = self._makeInstance()
fake_request = do_fake_request("GET")
result = instance.Instance_getHateoasNews(
REQUEST=fake_request)
self.assertEqual(fake_request.RESPONSE.status, 200)
self.assertEqual(fake_request.RESPONSE.getHeader('Content-Type'),
"application/hal+json"
)
self.assertEqual(json.loads(result), json.loads(json.dumps({
'news': [{
"user": "SlapOS Master",
"text": "#error no data found for %s" % instance.getReference()
}],
'_links': {
"self": {
"href": "http://example.org/bar"
},
"index": {
"href": "urn:jio:get:%s" % \
instance.getRelativeUrl(),
"title": "Software Instance"
},
},
}, indent=2)))
class TestSlapOSInstance_getHateoasRelatedInstanceTree(TestSlapOSHypermediaMixin):
def _makeInstance(self):
instance = self.portal.software_instance_module\
.template_software_instance.Base_createCloneDocument(batch_mode=1)
instance.edit(
title=self.generateNewSoftwareTitle(),
reference="TESTHS-%s" % self.generateNewId(),
software_type=self.generateNewSoftwareType(),
url_string=self.generateNewSoftwareReleaseUrl(),
instance_xml=self.generateSafeXml(),
sla_xml=self.generateSafeXml(),
connection_xml=self.generateSafeXml(),
)
self._addERP5Login(instance)
self.tic()
return instance
@changeSkin('Hal')
def test_getHateoasRelatedInstanceTree_REQUEST_mandatory(self):
self.assertRaises(
Unauthorized,
self.portal.Instance_getHateoasRelatedInstanceTree
)
@simulate('Base_getRequestHeader', '*args, **kwargs',
'return "application/vnd+bar"')
@changeSkin('Hal')
def test_getHateoasRelatedInstanceTree_wrong_ACCEPT(self):
instance = self._makeInstance()
fake_request = do_fake_request("GET")
result = instance.Instance_getHateoasRelatedInstanceTree(
REQUEST=fake_request)
self.assertEqual(fake_request.RESPONSE.status, 406)
self.assertEqual(result, "")
@simulate('Base_getRequestHeader', '*args, **kwargs',
'return "application/hal+json"')
@changeSkin('Hal')
def test_getHateoasRelatedInstanceTree_bad_method(self):
instance = self._makeInstance()
fake_request = do_fake_request("POST")
result = instance.Instance_getHateoasRelatedInstanceTree(
REQUEST=fake_request)
self.assertEqual(fake_request.RESPONSE.status, 405)
self.assertEqual(result, "")
@simulate('Base_getRequestHeader', '*args, **kwargs',
'return "application/hal+json"')
@changeSkin('Hal')
def test_getHateoasRelatedInstanceTree_not_instance_context(self):
fake_request = do_fake_request("GET")
result = self.portal.Instance_getHateoasRelatedInstanceTree(REQUEST=fake_request)
self.assertEqual(fake_request.RESPONSE.status, 403)
self.assertEqual(result, "")
@simulate('Base_getRequestUrl', '*args, **kwargs',
'return "http://example.org/bar"')
@simulate('Base_getRequestHeader', '*args, **kwargs',
'return "application/hal+json"')
@changeSkin('Hal')
def test_getHateoasRelatedInstanceTree_result(self):
subscription = self._makeInstanceTree()
instance= self._makeInstance()
instance.edit(specialise_value=subscription)
self.tic()
fake_request = do_fake_request("GET")
result = instance.Instance_getHateoasRelatedInstanceTree(
REQUEST=fake_request)
self.assertEqual(fake_request.RESPONSE.status, 200)
self.assertEqual(fake_request.RESPONSE.getHeader('Content-Type'),
"application/hal+json"
)
self.assertEqual(json.loads(result), json.loads(json.dumps({
'_links': {
"self": {
"href": "http://example.org/bar"
},
"index": {
"href": "urn:jio:get:%s" % \
instance.getRelativeUrl(),
"title": "Software Instance"
},
"action_object_jump": {
'href': "%s/ERP5Document_getHateoas" % subscription.getAbsoluteUrl(),
'title': "Instance Tree"
}
},
}, indent=2)))
class TestSlapOSInstance_getHateoasInformation(TestSlapOSHypermediaMixin):
def _makeInstance(self):
instance = self.portal.software_instance_module\
.template_software_instance.Base_createCloneDocument(batch_mode=1)
instance.edit(
title=self.generateNewSoftwareTitle(),
reference="TESTHS-%s" % self.generateNewId(),
software_type=self.generateNewSoftwareType(),
url_string=self.generateNewSoftwareReleaseUrl(),
instance_xml=self.generateSafeXml(),
sla_xml=self.generateSafeXml(),
connection_xml=self.generateSafeXml(),
)
self._addERP5Login(instance)
self.tic()
return instance
@simulate('Base_getRequestHeader', '*args, **kwargs',
'return "application/vnd+bar"')
@changeSkin('Hal')
def test_getHateoas_wrong_ACCEPT(self):
fake_request = do_fake_request("GET")
result = self.portal.Instance_getHateoasInformation(REQUEST=fake_request)
self.assertEqual(fake_request.RESPONSE.status, 406)
self.assertEqual(result, "")
@simulate('Base_getRequestHeader', '*args, **kwargs',
'return "application/hal+json"')
@changeSkin('Hal')
def test_getHateoas_bad_method(self):
fake_request = do_fake_request("POST")
result = self.portal.Instance_getHateoasInformation(
REQUEST=fake_request)
self.assertEqual(fake_request.RESPONSE.status, 405)
self.assertEqual(result, "")
@simulate('Base_getRequestHeader', '*args, **kwargs',
'return "application/hal+json"')
@changeSkin('Hal')
def test_getHateoas_request_not_correct_context(self):
fake_request = do_fake_request("GET")
result = self.portal.Instance_getHateoasInformation(REQUEST=fake_request)
self.assertEqual(fake_request.RESPONSE.status, 403)
self.assertEqual(result, "")
@simulate('Base_getRequestUrl', '*args, **kwargs',
'return "http://example.org/foo"')
@simulate('Base_getRequestHeader', '*args, **kwargs',
'return "application/hal+json"')
@changeSkin('Hal')
def test_getHateoas_result(self):
instance = self._makeInstance()
instance.edit(url_string="http://foo.com/software.cfg")
self.portal.portal_workflow._jumpToStateFor(instance,
'start_requested')
fake_request = do_fake_request("GET")
result = instance.Instance_getHateoasInformation(
REQUEST=fake_request)
self.assertEqual(fake_request.RESPONSE.status, 200)
self.assertEqual(fake_request.RESPONSE.getHeader('Content-Type'),
"application/hal+json"
)
self.assertEqual(json.loads(result), json.loads(json.dumps({
'title': instance.getTitle(),
'requested_state': 'started',
'slave': False,
'instance_guid': instance.getId(),
'connection_dict': instance.getConnectionXmlAsDict(),
'parameter_dict': instance.getInstanceXmlAsDict(),
'software_type': instance.getSourceReference(),
'sla_dict': instance.getSlaXmlAsDict(),
'_links': {
"self": {
"href": "http://example.org/foo"
},
"software_release": {
"href": "http://foo.com/software.cfg",
},
"index": {
"href": "urn:jio:get:%s" % instance.getRelativeUrl(),
"title": "Software Instance"
},
},
}, indent=2)))
class TestSlapOSPerson_getHateoasComputeNodeList(TestSlapOSHypermediaMixin):
@changeSkin('Hal')
def test_getHateoasComputeNodeList_REQUEST_mandatory(self):
self.assertRaises(
Unauthorized,
self.portal.Person_getHateoasComputeNodeList
)
@simulate('Base_getRequestHeader', '*args, **kwargs',
'return "application/vnd+bar"')
@changeSkin('Hal')
def test_getHateoasComputeNodeList_wrong_ACCEPT(self):
fake_request = do_fake_request("GET")
result = self.portal.Person_getHateoasComputeNodeList(REQUEST=fake_request)
self.assertEqual(fake_request.RESPONSE.status, 406)
self.assertEqual(result, "")
@simulate('Base_getRequestHeader', '*args, **kwargs',
'return "application/hal+json"')
@changeSkin('Hal')
def test_getHateoasComputeNodeList_bad_method(self):
fake_request = do_fake_request("POST")
result = self.portal.Person_getHateoasComputeNodeList(
REQUEST=fake_request)
self.assertEqual(fake_request.RESPONSE.status, 405)
self.assertEqual(result, "")
@simulate('Base_getRequestHeader', '*args, **kwargs',
'return "application/hal+json"')
@changeSkin('Hal')
def test_getHateoasComputeNodeList_request_not_correct_context(self):
fake_request = do_fake_request("GET")
result = self.portal.Person_getHateoasComputeNodeList(REQUEST=fake_request)
self.assertEqual(fake_request.RESPONSE.status, 403)
self.assertEqual(result, "")
@simulate('Base_getRequestUrl', '*args, **kwargs',
'return "http://example.org/foo"')
@simulate('Base_getRequestHeader', '*args, **kwargs',
'return "application/hal+json"')
@changeSkin('Hal')
def test_getHateoasComputeNodeList_result(self):
person_user = self._makePerson()
compute_node = self._makeComputeNode()
compute_node.edit(source_administration_value=person_user)
self.tic()
fake_request = do_fake_request("GET")
self.changeSkin('Hal')
result = person_user.Person_getHateoasComputeNodeList(REQUEST=fake_request)
self.assertEqual(fake_request.RESPONSE.status, 200)
self.assertEqual(fake_request.RESPONSE.getHeader('Content-Type'),
"application/hal+json"
)
self.assertEqual(json.loads(result), json.loads(json.dumps({
'_links': {
"self": {
"href": "http://example.org/foo"
},
"index": {
"href": "urn:jio:get:%s" % \
person_user.getRelativeUrl(),
"title": "Person"
},
"content": [{
"href": "%s/ERP5Document_getHateoas" % \
compute_node.absolute_url(),
"title": compute_node.getTitle()
}],
},
}, indent=2)))
class TestSlapOSComputeNode_getHateoasSoftwareInstallationList(TestSlapOSHypermediaMixin):
@changeSkin('Hal')
def test_getSoftwareInstallationList_REQUEST_mandatory(self):
self.assertRaises(
Unauthorized,
self.portal.ComputeNode_getHateoasSoftwareInstallationList
)
@simulate('Base_getRequestHeader', '*args, **kwargs',
'return "application/vnd+bar"')
@changeSkin('Hal')
def test_getSoftwareInstallationList_wrong_ACCEPT(self):
fake_request = do_fake_request("GET")
result = self.portal.ComputeNode_getHateoasSoftwareInstallationList(
REQUEST=fake_request)
self.assertEqual(fake_request.RESPONSE.status, 406)
self.assertEqual(result, "")
@simulate('Base_getRequestHeader', '*args, **kwargs',
'return "application/hal+json"')
@changeSkin('Hal')
def test_getSoftwareInstallationList_bad_method(self):
fake_request = do_fake_request("POST")
result = self.portal.ComputeNode_getHateoasSoftwareInstallationList(
REQUEST=fake_request)
self.assertEqual(fake_request.RESPONSE.status, 405)
self.assertEqual(result, "")
@simulate('Base_getRequestHeader', '*args, **kwargs',
'return "application/hal+json"')
@changeSkin('Hal')
def test_getSoftwareInstallationList_request_not_correct_context(self):
fake_request = do_fake_request("GET")
result = self.portal.ComputeNode_getHateoasSoftwareInstallationList(
REQUEST=fake_request)
self.assertEqual(fake_request.RESPONSE.status, 403)
self.assertEqual(result, "")
@simulate('Base_getRequestUrl', '*args, **kwargs',
'return "http://example.org/foo"')
@simulate('Base_getRequestHeader', '*args, **kwargs',
'return "application/hal+json"')
@changeSkin('Hal')
def test_getSoftwareInstallationList_result(self):
compute_node = self._makeComputeNode()
software_installation = self._makeSoftwareInstallation()
software_installation.edit(aggregate_value=compute_node, url_string='foo')
self.tic()
fake_request = do_fake_request("GET")
result = compute_node.ComputeNode_getHateoasSoftwareInstallationList(
REQUEST=fake_request)
self.assertEqual(fake_request.RESPONSE.status, 200)
self.assertEqual(fake_request.RESPONSE.getHeader('Content-Type'),
"application/hal+json"
)
self.assertEqual(json.loads(result), json.loads(json.dumps({
'_links': {
"self": {
"href": "http://example.org/foo"
},
"content": [{
"href": "%s/ERP5Document_getHateoas" % \
software_installation.absolute_url(),
"title": "foo"
}],
"index": {
"href": "urn:jio:get:%s" % compute_node.getRelativeUrl(),
"title": "Compute Node"
},
},
}, indent=2)))
class TestSlapOSSoftwareInstallation_getHateoasInformation(TestSlapOSHypermediaMixin):
@simulate('Base_getRequestHeader', '*args, **kwargs',
'return "application/vnd+bar"')
@changeSkin('Hal')
def test_getHateoas_wrong_ACCEPT(self):
fake_request = do_fake_request("GET")
result = self.portal.SoftwareInstallation_getHateoasInformation(REQUEST=fake_request)
self.assertEqual(fake_request.RESPONSE.status, 406)
self.assertEqual(result, "")
@simulate('Base_getRequestHeader', '*args, **kwargs',
'return "application/hal+json"')
@changeSkin('Hal')
def test_getHateoas_bad_method(self):
fake_request = do_fake_request("POST")
result = self.portal.SoftwareInstallation_getHateoasInformation(
REQUEST=fake_request)
self.assertEqual(fake_request.RESPONSE.status, 405)
self.assertEqual(result, "")
@simulate('Base_getRequestHeader', '*args, **kwargs',
'return "application/hal+json"')
@changeSkin('Hal')
def test_getHateoas_request_not_correct_context(self):
fake_request = do_fake_request("GET")
result = self.portal.SoftwareInstallation_getHateoasInformation(REQUEST=fake_request)
self.assertEqual(fake_request.RESPONSE.status, 403)
self.assertEqual(result, "")
@simulate('Base_getRequestUrl', '*args, **kwargs',
'return "http://example.org/foo"')
@simulate('Base_getRequestHeader', '*args, **kwargs',
'return "application/hal+json"')
@changeSkin('Hal')
def test_getHateoas_result(self):
software_installation = self._makeSoftwareInstallation()
software_installation.edit(url_string="http://foo.com/software.cfg")
self.portal.portal_workflow._jumpToStateFor(software_installation,
'start_requested')
fake_request = do_fake_request("GET")
result = software_installation.SoftwareInstallation_getHateoasInformation(
REQUEST=fake_request)
self.assertEqual(fake_request.RESPONSE.status, 200)
self.assertEqual(fake_request.RESPONSE.getHeader('Content-Type'),
"application/hal+json"
)
self.assertEqual(json.loads(result), json.loads(json.dumps({
'title': software_installation.getTitle(),
'status': 'started',
'_links': {
"self": {
"href": "http://example.org/foo"
},
"software_release": {
"href": "http://foo.com/software.cfg",
},
"index": {
"href": "urn:jio:get:%s" % software_installation.getRelativeUrl(),
"title": "Software Installation"
},
},
}, indent=2)))
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Test Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>testSlapOSHypermediaSkins</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test.erp5.testSlapOSHypermediaSkins</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Test Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<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>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
</ZopeData>
Compute Node | get_hateoas_software_installation_list
Instance Tree | get_hateoas_instance_list
Instance Tree | get_hateoas_root_instance
Person | get_hateoas_compute_node_list
Person | get_hateoas_instance_tree_list
Person | get_hateoas_information
Slave Instance | get_hateoas_information
Slave Instance | get_hateoas_news
Slave Instance | get_hateoas_related_instance_tree
Software Installation | get_hateoas_information
Software Installation | get_hateoas_news
Software Instance | get_hateoas_information
Software Instance | get_hateoas_news
Software Instance | get_hateoas_related_instance_tree
\ No newline at end of file
action_type/object_slap
action_type/object_slap_post
\ No newline at end of file
slapos_hal_json_style_backward_compatibility
\ No newline at end of file
test.erp5.testSlapOSHypermediaScenario
test.erp5.testSlapOSHypermediaSkins
\ No newline at end of file
slapos_jio_hateoas_backward_compatibility
\ No newline at end of file
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