Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
18
Merge Requests
18
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
slapos.core
Commits
65b98642
Commit
65b98642
authored
Nov 05, 2014
by
Cédric de Saint Martin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[slapos_hypermedia] Change Base_getHateoasMaster about 'me' link.
So that it fits ERP5Document_getHateoas style.
parent
68284380
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
43 additions
and
33 deletions
+43
-33
master/bt5/slapos_hypermedia/SkinTemplateItem/portal_skins/slapos_hypermedia/Base_getHateoasMaster.xml
.../portal_skins/slapos_hypermedia/Base_getHateoasMaster.xml
+3
-4
master/bt5/slapos_hypermedia/TestTemplateItem/testSlapOSHypermediaScenario.py
...permedia/TestTemplateItem/testSlapOSHypermediaScenario.py
+35
-22
master/bt5/slapos_hypermedia/TestTemplateItem/testSlapOSHypermediaSkins.py
..._hypermedia/TestTemplateItem/testSlapOSHypermediaSkins.py
+4
-6
master/bt5/slapos_hypermedia/bt/revision
master/bt5/slapos_hypermedia/bt/revision
+1
-1
No files found.
master/bt5/slapos_hypermedia/SkinTemplateItem/portal_skins/slapos_hypermedia/Base_getHateoasMaster.xml
View file @
65b98642
...
...
@@ -90,16 +90,15 @@ portal = context.getPortalObject()\n
person = portal.ERP5Site_getAuthenticatedMemberPersonValue()\n
if person is not None:\n
result_dict[\'_links\'][\'me\'] = {\n
"href": "urn:jio:get:%s" % person.getRelativeUrl(),\n
"href": "urn:jio:get:%s
/ERP5Document_getHateoas
" % person.getRelativeUrl(),\n
}\n
\n
else:\n
user = str(portal.portal_membership.getAuthenticatedMember())\n
if user != "Anonymous User":\n
user_document = context.ERP5Site_getUserDocument(user)\n
result_dict[\'_links\'][\'action_object_jump\'] = {\n
\'href\': \'%s/ERP5Document_getHateoas\' % user_document.absolute_url(),\n
\'title\': user_document.getPortalType()\n
result_dict[\'_links\'][\'me\'] = {\n
\'href\': \'urn:jio:get:%s/ERP5Document_getHateoas\' % user_document.getRelativeUrl(),\n
}\n
\n
response.setHeader(\'Content-Type\', mime_type)\n
...
...
master/bt5/slapos_hypermedia/TestTemplateItem/testSlapOSHypermediaScenario.py
View file @
65b98642
...
...
@@ -17,6 +17,14 @@ def hateoasGetLinkFromLinks(links, title):
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
(
testSlapOSMixin
):
def
_makeUser
(
self
):
...
...
@@ -42,10 +50,8 @@ class TestSlapOSHypermediaPersonScenario(testSlapOSMixin):
"%s:%s"
%
(
erp5_person
.
getReference
(),
erp5_person
.
getReference
()))
content_type
=
"application/hal+json"
# XXX Default home url. 'Hardcoded' in client.
api_scheme
,
api_netloc
,
api_path
,
api_query
,
\
api_fragment
=
urlparse
.
urlsplit
(
'%s/Base_getHateoasMaster'
%
\
self
.
portal
.
absolute_url
())
api_fragment
=
urlparse
.
urlsplit
(
self
.
portal
.
absolute_url
())
def
getNewHttpConnection
(
api_netloc
):
if
api_scheme
==
'https'
:
...
...
@@ -76,13 +82,17 @@ class TestSlapOSHypermediaPersonScenario(testSlapOSMixin):
#####################################################
# Fetch the user hal
#####################################################
user_link_dict
=
home_page_hal
[
'_links'
][
'action_object_jump'
]
user_link_dict
=
home_page_hal
[
'_links'
][
'me'
]
self
.
assertNotEqual
(
user_link_dict
,
None
)
me_url
=
'http://%s%s/web_site_module/hateoas/%s'
%
(
api_netloc
,
api_path
,
getRelativeUrlFromUrn
(
user_link_dict
[
'href'
]))
connection
=
getNewHttpConnection
(
api_netloc
)
connection
.
request
(
method
=
user_link_dict
.
get
(
'method'
,
'GET'
),
url
=
user_link_dict
[
'href'
]
,
url
=
me_url
,
headers
=
{
'Authorization'
:
authorization
,
'Accept'
:
content_type
,
...
...
@@ -396,10 +406,8 @@ class TestSlapOSHypermediaInstanceScenario(testSlapOSMixin):
remote_user
=
instance
.
getReference
()
content_type
=
"application/hal+json"
# XXX Default home url. 'Hardcoded' in client.
api_scheme
,
api_netloc
,
api_path
,
api_query
,
\
api_fragment
=
urlparse
.
urlsplit
(
'%s/Base_getHateoasMaster'
%
\
self
.
portal
.
absolute_url
())
api_fragment
=
urlparse
.
urlsplit
(
self
.
portal
.
absolute_url
())
def
getNewHttpConnection
(
api_netloc
):
if
api_scheme
==
'https'
:
...
...
@@ -410,6 +418,7 @@ class TestSlapOSHypermediaInstanceScenario(testSlapOSMixin):
#####################################################
# Access the master home page hal
#####################################################
connection
=
getNewHttpConnection
(
api_netloc
)
connection
.
request
(
method
=
'GET'
,
...
...
@@ -429,13 +438,17 @@ class TestSlapOSHypermediaInstanceScenario(testSlapOSMixin):
#####################################################
# Fetch the instance hal
#####################################################
user_link_dict
=
home_page_hal
[
'_links'
][
'action_object_jump'
]
user_link_dict
=
home_page_hal
[
'_links'
][
'me'
]
self
.
assertNotEqual
(
user_link_dict
,
None
)
me_url
=
str
(
'http://%s%s/web_site_module/hateoas/%s'
%
(
api_netloc
,
api_path
,
getRelativeUrlFromUrn
(
user_link_dict
[
'href'
])))
connection
=
getNewHttpConnection
(
api_netloc
)
connection
.
request
(
method
=
user_link_dict
.
get
(
'method'
,
'GET'
),
url
=
user_link_dict
[
'href'
]
,
url
=
me_url
,
headers
=
{
'REMOTE_USER'
:
remote_user
,
'Accept'
:
content_type
,
...
...
@@ -451,11 +464,11 @@ class TestSlapOSHypermediaInstanceScenario(testSlapOSMixin):
# Fetch instance informations
#####################################################
request
_link_dict
=
hateoasGetLinkFromLinks
(
user
_link_dict
=
hateoasGetLinkFromLinks
(
instance_hal
[
'_links'
][
'action_object_slap'
],
'getHateoasInformation'
)
self
.
assertNotEqual
(
request
_link_dict
,
None
)
self
.
assertNotEqual
(
user
_link_dict
,
None
)
connection
=
getNewHttpConnection
(
api_netloc
)
connection
.
request
(
method
=
user_link_dict
.
get
(
'method'
,
'GET'
),
...
...
@@ -476,11 +489,11 @@ class TestSlapOSHypermediaInstanceScenario(testSlapOSMixin):
#####################################################
# Get instance news
#####################################################
request
_link_dict
=
hateoasGetLinkFromLinks
(
user
_link_dict
=
hateoasGetLinkFromLinks
(
instance_hal
[
'_links'
][
'action_object_slap'
],
'getHateoasNews'
)
self
.
assertNotEqual
(
request
_link_dict
,
None
)
self
.
assertNotEqual
(
user
_link_dict
,
None
)
connection
=
getNewHttpConnection
(
api_netloc
)
connection
.
request
(
method
=
user_link_dict
.
get
(
'method'
,
'GET'
),
...
...
@@ -502,15 +515,15 @@ class TestSlapOSHypermediaInstanceScenario(testSlapOSMixin):
# Get hosting subscription of instance
#####################################################
# XXX can be simpler and doesn't need getHateoasRelatedHostingSubscription script
request
_link_dict
=
hateoasGetLinkFromLinks
(
hosting
_link_dict
=
hateoasGetLinkFromLinks
(
instance_hal
[
'_links'
][
'action_object_slap'
],
'getHateoasRelatedHostingSubscription'
)
self
.
assertNotEqual
(
request
_link_dict
,
None
)
self
.
assertNotEqual
(
hosting
_link_dict
,
None
)
connection
=
getNewHttpConnection
(
api_netloc
)
connection
.
request
(
method
=
request
_link_dict
.
get
(
'method'
,
'GET'
),
url
=
request
_link_dict
[
'href'
],
method
=
hosting
_link_dict
.
get
(
'method'
,
'GET'
),
url
=
hosting
_link_dict
[
'href'
],
headers
=
{
'REMOTE_USER'
:
remote_user
,
'Accept'
:
content_type
,
...
...
@@ -526,15 +539,15 @@ class TestSlapOSHypermediaInstanceScenario(testSlapOSMixin):
self
.
tic
()
request
_link_dict
=
hateoasGetLinkFromLinks
(
hosting
_link_dict
=
hateoasGetLinkFromLinks
(
subscription_hal
[
'_links'
][
'action_object_jump'
],
'Hosting Subscription'
)
self
.
assertNotEqual
(
request
_link_dict
,
None
)
self
.
assertNotEqual
(
hosting
_link_dict
,
None
)
connection
=
getNewHttpConnection
(
api_netloc
)
connection
.
request
(
method
=
request
_link_dict
.
get
(
'method'
,
'GET'
),
url
=
request
_link_dict
[
'href'
],
method
=
hosting
_link_dict
.
get
(
'method'
,
'GET'
),
url
=
hosting
_link_dict
[
'href'
],
headers
=
{
'REMOTE_USER'
:
remote_user
,
'Accept'
:
content_type
,
...
...
master/bt5/slapos_hypermedia/TestTemplateItem/testSlapOSHypermediaSkins.py
View file @
65b98642
...
...
@@ -354,9 +354,8 @@ class TestSlapOSBase_getHateoasMaster(TestSlapOSHypermediaMixin):
"self"
:
{
"href"
:
"http://example.org/bar"
},
"action_object_jump"
:
{
"href"
:
"%s/ERP5Document_getHateoas"
%
person_user
.
absolute_url
(),
"title"
:
"Person"
"me"
:
{
"href"
:
"urn:jio:get:%s/ERP5Document_getHateoas"
%
person_user
.
getRelativeUrl
(),
},
},
},
indent
=
2
))
...
...
@@ -381,9 +380,8 @@ class TestSlapOSBase_getHateoasMaster(TestSlapOSHypermediaMixin):
"self"
:
{
"href"
:
"http://example.org/bar"
},
"action_object_jump"
:
{
"href"
:
"%s/ERP5Document_getHateoas"
%
self
.
software_instance
.
absolute_url
(),
"title"
:
"Software Instance"
"me"
:
{
"href"
:
"urn:jio:get:%s/ERP5Document_getHateoas"
%
self
.
software_instance
.
getRelativeUrl
(),
},
},
},
indent
=
2
))
...
...
master/bt5/slapos_hypermedia/bt/revision
View file @
65b98642
5
\ No newline at end of file
6
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment