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
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Łukasz Nowak
slapos.core
Commits
45cbfc0c
Commit
45cbfc0c
authored
Oct 23, 2014
by
Cédric de Saint Martin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[SlapTool] Add getHateoasUrl method.
parent
7c4da172
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
1 deletion
+46
-1
master/bt5/slapos_slap_tool/TestTemplateItem/testSlapOSSlapTool.py
...5/slapos_slap_tool/TestTemplateItem/testSlapOSSlapTool.py
+22
-0
master/bt5/slapos_slap_tool/bt/revision
master/bt5/slapos_slap_tool/bt/revision
+1
-1
master/product/Vifib/Tool/SlapTool.py
master/product/Vifib/Tool/SlapTool.py
+23
-0
No files found.
master/bt5/slapos_slap_tool/TestTemplateItem/testSlapOSSlapTool.py
View file @
45cbfc0c
...
@@ -2789,3 +2789,25 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
...
@@ -2789,3 +2789,25 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
finally
:
finally
:
if
os
.
path
.
exists
(
self
.
revoke_computer_certificate_simulator
):
if
os
.
path
.
exists
(
self
.
revoke_computer_certificate_simulator
):
os
.
unlink
(
self
.
revoke_computer_certificate_simulator
)
os
.
unlink
(
self
.
revoke_computer_certificate_simulator
)
def
test_getHateoasUrl_NotConfigured
(
self
):
for
preference
in
\
self
.
portal
.
portal_catalog
(
portal_type
=
"System Preference"
):
preference
=
preference
.
getObject
()
if
preference
.
getPreferenceState
()
==
'global'
:
preference
.
setPreferredHateoasUrl
(
''
)
self
.
tic
()
self
.
login
(
self
.
person_reference
)
self
.
assertRaises
(
NotFound
,
self
.
portal_slap
.
getHateoasUrl
)
def
test_getHateoasUrl
(
self
):
for
preference
in
\
self
.
portal
.
portal_catalog
(
portal_type
=
"System Preference"
):
preference
=
preference
.
getObject
()
if
preference
.
getPreferenceState
()
==
'global'
:
preference
.
setPreferredHateoasUrl
(
'foo'
)
self
.
tic
()
self
.
login
(
self
.
person_reference
)
response
=
self
.
portal_slap
.
getHateoasUrl
()
self
.
assertEqual
(
200
,
response
.
status
)
self
.
assertEqual
(
'foo'
,
response
.
body
)
master/bt5/slapos_slap_tool/bt/revision
View file @
45cbfc0c
37
38
\ No newline at end of file
\ No newline at end of file
master/product/Vifib/Tool/SlapTool.py
View file @
45cbfc0c
...
@@ -425,6 +425,28 @@ class SlapTool(BaseTool):
...
@@ -425,6 +425,28 @@ class SlapTool(BaseTool):
for
software_release
in
software_release_list
for
software_release
in
software_release_list
if
software_release
.
getValidationState
()
==
'published'
])
if
software_release
.
getValidationState
()
==
'published'
])
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'getHateoasUrl'
)
def
getHateoasUrl
(
self
):
"""
Return preferred HATEOAS URL.
"""
try
:
url
=
self
.
getPortalObject
().
portal_preferences
.
getPreferredHateoasUrl
()
except
AttributeError
:
raise
NotFound
if
not
url
:
raise
NotFound
# Keep in cache server for 7 days
self
.
REQUEST
.
response
.
setStatus
(
200
)
self
.
REQUEST
.
response
.
setHeader
(
'Cache-Control'
,
'public, max-age=1, stale-if-error=604800'
)
self
.
REQUEST
.
response
.
setHeader
(
'Vary'
,
'REMOTE_USER'
)
self
.
REQUEST
.
response
.
setHeader
(
'Last-Modified'
,
rfc1123_date
(
DateTime
()))
self
.
REQUEST
.
response
.
setHeader
(
'content-type'
,
'text; charset=utf-8'
)
self
.
REQUEST
.
response
.
setBody
(
url
)
return
self
.
REQUEST
.
response
####################################################
####################################################
# Public POST methods
# Public POST methods
...
@@ -774,6 +796,7 @@ class SlapTool(BaseTool):
...
@@ -774,6 +796,7 @@ class SlapTool(BaseTool):
self
.
REQUEST
.
response
.
setBody
(
result
)
self
.
REQUEST
.
response
.
setBody
(
result
)
return
self
.
REQUEST
.
response
return
self
.
REQUEST
.
response
####################################################
####################################################
# Internal methods
# Internal methods
####################################################
####################################################
...
...
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