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
Arnaud Véron
slapos.core
Commits
d0680302
Commit
d0680302
authored
May 15, 2012
by
Łukasz Nowak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cover discovery protocol.
parent
e734c863
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
91 additions
and
4 deletions
+91
-4
master/bt5/vifib_slapos_rest_api_v1_test/TestTemplateItem/testVifibSlaposRestAPIV1.py
..._api_v1_test/TestTemplateItem/testVifibSlaposRestAPIV1.py
+90
-3
master/bt5/vifib_slapos_rest_api_v1_test/bt/revision
master/bt5/vifib_slapos_rest_api_v1_test/bt/revision
+1
-1
No files found.
master/bt5/vifib_slapos_rest_api_v1_test/TestTemplateItem/testVifibSlaposRestAPIV1.py
View file @
d0680302
...
...
@@ -53,6 +53,9 @@ class VifibSlaposRestAPIV1Mixin(TestVifibSlapWebServiceMixin):
return
str
(
self
.
getPortalObject
().
portal_ids
.
generateNewId
(
id_group
=
(
'slapos_rest_api_v1_test'
)))
def
assertCacheControlHeader
(
self
):
self
.
assertEqual
(
'public'
,
self
.
response
.
getheader
(
'Cache-Control'
))
def
createPerson
(
self
):
customer
=
self
.
cloneByPath
(
'person_module/template_member'
)
customer_reference
=
'P'
+
self
.
generateNewId
()
...
...
@@ -443,9 +446,6 @@ class VifibSlaposRestAPIV1InstanceMixin(VifibSlaposRestAPIV1Mixin):
calculated
=
rfc1123_date
(
self
.
software_instance
.
getModificationDate
())
self
.
assertEqual
(
calculated
,
self
.
response
.
getheader
(
'Last-Modified'
))
def
assertCacheControlHeader
(
self
):
self
.
assertEqual
(
'public'
,
self
.
response
.
getheader
(
'Cache-Control'
))
def
createSoftwareInstance
(
self
,
person
):
software_instance
=
self
.
cloneByPath
(
'software_instance_module/template_software_instance'
)
...
...
@@ -1158,3 +1158,90 @@ class TestInstanceGETlist(VifibSlaposRestAPIV1InstanceMixin):
self
.
assertTrue
(
'Bearer realm="'
in
auth
)
self
.
assertPersonRequestSimulatorEmpty
()
class
TestGET_discovery
(
VifibSlaposRestAPIV1Mixin
):
def
afterSetUp
(
self
):
super
(
TestGET_discovery
,
self
).
afterSetUp
()
self
.
api_date
=
self
.
portal
.
portal_vifib_rest_api_v1
.
api_modification_date
def
assertLastModifiedHeader
(
self
):
self
.
assertEqual
(
rfc1123_date
(
self
.
api_date
),
self
.
response
.
getheader
(
'Last-Modified'
))
def
assertAPIDiscoveryDict
(
self
):
self
.
assertSameSet
(
self
.
json_response
.
keys
(),
[
'instance_certificate'
,
'request_instance'
,
'instance_list'
,
'instance_edit'
,
'instance_bang'
,
'instance_info'
,
'discovery'
,
])
def
test
(
self
):
self
.
connection
.
request
(
method
=
'GET'
,
url
=
self
.
api_path
)
self
.
prepareResponse
()
self
.
assertBasicResponse
()
self
.
assertResponseCode
(
200
)
self
.
assertLastModifiedHeader
()
self
.
assertCacheControlHeader
()
self
.
assertResponseJson
()
self
.
assertAPIDiscoveryDict
()
def
test_if_modified_since_equal
(
self
):
self
.
connection
.
request
(
method
=
'GET'
,
url
=
self
.
api_path
,
headers
=
{
'If-Modified-Since'
:
rfc1123_date
(
self
.
api_date
)})
self
.
prepareResponse
()
self
.
assertBasicResponse
()
self
.
assertResponseCode
(
304
)
def
test_if_modified_since_after
(
self
):
if_modified
=
self
.
api_date
.
timeTime
()
+
2
# check the test: is calculated time *before* now?
self
.
assertTrue
(
int
(
if_modified
)
<
int
(
DateTime
().
timeTime
()))
self
.
connection
.
request
(
method
=
'GET'
,
url
=
self
.
api_path
,
headers
=
{
'If-Modified-Since'
:
rfc1123_date
(
DateTime
(
if_modified
))})
self
.
prepareResponse
()
self
.
assertBasicResponse
()
self
.
assertResponseCode
(
304
)
def
test_if_modified_since_before
(
self
):
self
.
connection
.
request
(
method
=
'GET'
,
url
=
self
.
api_path
,
headers
=
{
'If-Modified-Since'
:
rfc1123_date
(
self
.
api_date
-
1
)})
self
.
prepareResponse
()
self
.
assertBasicResponse
()
self
.
assertResponseCode
(
200
)
self
.
assertLastModifiedHeader
()
self
.
assertCacheControlHeader
()
self
.
assertResponseJson
()
self
.
assertAPIDiscoveryDict
()
def
test_if_modified_since_date_not_date
(
self
):
self
.
connection
.
request
(
method
=
'GET'
,
url
=
self
.
api_path
,
headers
=
{
'If-Modified-Since'
:
'This Is Not A date'
})
self
.
prepareResponse
()
self
.
assertBasicResponse
()
self
.
assertResponseCode
(
200
)
self
.
assertLastModifiedHeader
()
self
.
assertCacheControlHeader
()
self
.
assertResponseJson
()
self
.
assertAPIDiscoveryDict
()
def
test_if_modified_since_date_future
(
self
):
self
.
connection
.
request
(
method
=
'GET'
,
url
=
self
.
api_path
,
headers
=
{
'If-Modified-Since'
:
rfc1123_date
(
DateTime
()
+
1
)})
self
.
prepareResponse
()
self
.
assertBasicResponse
()
self
.
assertResponseCode
(
200
)
self
.
assertLastModifiedHeader
()
self
.
assertCacheControlHeader
()
self
.
assertResponseJson
()
self
.
assertAPIDiscoveryDict
()
master/bt5/vifib_slapos_rest_api_v1_test/bt/revision
View file @
d0680302
49
\ No newline at end of file
50
\ 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