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
Titouan Soulard
slapos.core
Commits
7384823f
Commit
7384823f
authored
Sep 17, 2012
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Parameters are now provided in the URL
parent
8cae8537
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
70 additions
and
162 deletions
+70
-162
master/bt5/vifib_slapos_rest_api_v1_test/TestTemplateItem/testVifibSlaposRestAPIV1.py
..._api_v1_test/TestTemplateItem/testVifibSlaposRestAPIV1.py
+69
-161
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 @
7384823f
...
@@ -4,6 +4,7 @@ from Products.Vifib.tests.testVifibSlapWebService import \
...
@@ -4,6 +4,7 @@ from Products.Vifib.tests.testVifibSlapWebService import \
from
Products.ERP5Type.Base
import
WorkflowMethod
from
Products.ERP5Type.Base
import
WorkflowMethod
import
transaction
import
transaction
import
httplib
import
httplib
import
urllib
import
urlparse
import
urlparse
import
json
import
json
import
tempfile
import
tempfile
...
@@ -836,32 +837,8 @@ class TestInstanceAllocableGET(VifibSlaposRestAPIV1InstanceMixin):
...
@@ -836,32 +837,8 @@ class TestInstanceAllocableGET(VifibSlaposRestAPIV1InstanceMixin):
auth
=
self
.
response
.
getheader
(
'WWW-Authenticate'
)
auth
=
self
.
response
.
getheader
(
'WWW-Authenticate'
)
self
.
assertTrue
(
auth
is
not
None
)
self
.
assertTrue
(
auth
is
not
None
)
self
.
assertTrue
(
'Bearer realm="'
in
auth
)
self
.
assertTrue
(
'Bearer realm="'
in
auth
)
self
.
assertPersonRequestSimulatorEmpty
()
def
test_no_json
(
self
):
self
.
connection
.
request
(
method
=
'GET'
,
url
=
'/'
.
join
([
self
.
api_path
,
'instance'
,
'request'
]),
headers
=
{
'REMOTE_USER'
:
self
.
customer_reference
})
self
.
prepareResponse
()
self
.
assertBasicResponse
()
self
.
assertResponseCode
(
400
)
self
.
assertResponseJson
()
self
.
assertEqual
({
'error'
:
"Data is not json object."
},
self
.
json_response
)
self
.
assertPersonRequestSimulatorEmpty
()
def
test_bad_json
(
self
):
self
.
connection
.
request
(
method
=
'GET'
,
url
=
'/'
.
join
([
self
.
api_path
,
'instance'
,
'request'
]),
body
=
'This is not JSON'
,
headers
=
{
'REMOTE_USER'
:
self
.
customer_reference
})
self
.
prepareResponse
()
self
.
assertBasicResponse
()
self
.
assertResponseCode
(
400
)
self
.
assertResponseJson
()
self
.
assertEqual
({
'error'
:
"Data is not json object."
},
self
.
json_response
)
self
.
assertPersonRequestSimulatorEmpty
()
def
test_empty_
json
(
self
):
def
test_empty_
parameter
(
self
):
self
.
connection
.
request
(
method
=
'GET'
,
self
.
connection
.
request
(
method
=
'GET'
,
url
=
'/'
.
join
([
self
.
api_path
,
'instance'
,
'request'
]),
url
=
'/'
.
join
([
self
.
api_path
,
'instance'
,
'request'
]),
body
=
'{}'
,
body
=
'{}'
,
...
@@ -871,118 +848,58 @@ class TestInstanceAllocableGET(VifibSlaposRestAPIV1InstanceMixin):
...
@@ -871,118 +848,58 @@ class TestInstanceAllocableGET(VifibSlaposRestAPIV1InstanceMixin):
self
.
assertResponseCode
(
400
)
self
.
assertResponseCode
(
400
)
self
.
assertResponseJson
()
self
.
assertResponseJson
()
self
.
assertEqual
({
self
.
assertEqual
({
"status"
:
"Missing."
,
"slave"
:
"Missing."
,
"slave"
:
"Missing."
,
"title"
:
"Missing."
,
"software_release"
:
"Missing."
,
"software_release"
:
"Missing."
,
"software_type"
:
"Missing."
,
"software_type"
:
"Missing."
,
"parameter"
:
"Missing."
,
"sla"
:
"Missing."
},
"sla"
:
"Missing."
},
self
.
json_response
)
self
.
json_response
)
self
.
assertPersonRequestSimulatorEmpty
()
def
test_status_slave_missing_json
(
self
):
def
test_bad_sla_json
(
self
):
self
.
connection
.
request
(
method
=
'GET'
,
url
=
'/'
.
join
([
self
.
api_path
,
'instance'
,
'request'
]),
body
=
"""
{
"title": "My unique instance",
"software_release": "http://example.com/example.cfg",
"software_type": "type_provided_by_the_software",
"parameter": {
"Custom1": "one string",
"Custom2": "one float",
"Custom3": [
"abc",
"def"
]
},
"sla": {
"computer_id": "COMP-0"
}
}"""
,
headers
=
{
'REMOTE_USER'
:
self
.
customer_reference
})
self
.
prepareResponse
()
self
.
assertBasicResponse
()
self
.
assertResponseCode
(
400
)
self
.
assertResponseJson
()
self
.
assertEqual
({
"status"
:
"Missing."
,
"slave"
:
"Missing."
},
self
.
json_response
)
self
.
assertPersonRequestSimulatorEmpty
()
def
test_slave_not_bool
(
self
):
kwargs
=
{
kwargs
=
{
'parameter'
:
{
'Custom1'
:
'one string'
,
'Custom2'
:
'one float'
,
'Custom3'
:
[
'abc'
,
'def'
]},
'title'
:
'My unique instance'
,
'software_release'
:
'http://example.com/example.cfg'
,
'software_release'
:
'http://example.com/example.cfg'
,
'status'
:
'started'
,
'sla'
:
'This is not JSON'
,
'sla'
:
{
'computer_id'
:
'COMP-0'
},
'software_type'
:
'type_provided_by_the_software'
,
'software_type'
:
'type_provided_by_the_software'
,
'slave'
:
"True"
}
'slave'
:
'true'
}
self
.
connection
.
request
(
method
=
'GET'
,
self
.
connection
.
request
(
method
=
'GET'
,
url
=
'/'
.
join
([
self
.
api_path
,
'instance'
,
'request'
])
,
url
=
'/'
.
join
([
self
.
api_path
,
'instance'
,
'request'
])
+
\
body
=
json
.
dumps
(
kwargs
),
'?%s'
%
urllib
.
urlencode
(
kwargs
),
headers
=
{
'REMOTE_USER'
:
self
.
customer_reference
})
headers
=
{
'REMOTE_USER'
:
self
.
customer_reference
})
self
.
prepareResponse
()
self
.
prepareResponse
()
self
.
assertBasicResponse
()
self
.
assertBasicResponse
()
self
.
assertResponseCode
(
400
)
self
.
assertResponseCode
(
400
)
self
.
assertResponseJson
()
self
.
assertResponseJson
()
self
.
assertEqual
({
self
.
assertEqual
({
'sla'
:
"Malformed value."
},
self
.
json_response
)
"slave"
:
"unicode is not bool."
,
},
self
.
json_response
)
self
.
assertPersonRequestSimulatorEmpty
()
def
test_
incorrect_status
(
self
):
def
test_
slave_not_bool
(
self
):
kwargs
=
{
kwargs
=
{
'parameter'
:
{
'Custom1'
:
'one string'
,
'Custom2'
:
'one float'
,
'Custom3'
:
[
'abc'
,
'def'
]},
'title'
:
'My unique instance'
,
'software_release'
:
'http://example.com/example.cfg'
,
'software_release'
:
'http://example.com/example.cfg'
,
'status'
:
'badstatus'
,
'sla'
:
json
.
dumps
({
'sla'
:
{
'computer_id'
:
'COMP-0'
}),
'computer_id'
:
'COMP-0'
},
'software_type'
:
'type_provided_by_the_software'
,
'software_type'
:
'type_provided_by_the_software'
,
'slave'
:
True
}
'slave'
:
'this is not a JSON boolean'
}
self
.
connection
.
request
(
method
=
'GET'
,
self
.
connection
.
request
(
method
=
'GET'
,
url
=
'/'
.
join
([
self
.
api_path
,
'instance'
,
'request'
])
,
url
=
'/'
.
join
([
self
.
api_path
,
'instance'
,
'request'
])
+
\
body
=
json
.
dumps
(
kwargs
),
'?%s'
%
urllib
.
urlencode
(
kwargs
),
headers
=
{
'REMOTE_USER'
:
self
.
customer_reference
})
headers
=
{
'REMOTE_USER'
:
self
.
customer_reference
})
self
.
prepareResponse
()
self
.
prepareResponse
()
self
.
assertBasicResponse
()
self
.
assertBasicResponse
()
self
.
assertResponseCode
(
400
)
self
.
assertResponseCode
(
400
)
self
.
assertResponseJson
()
self
.
assertResponseJson
()
self
.
assertEqual
({
self
.
assertEqual
({
"s
tatus"
:
"Status shall be one of: started, stopped, destroyed
."
,
"s
lave"
:
"Malformed value
."
,
},
},
self
.
json_response
)
self
.
json_response
)
self
.
assertPersonRequestSimulatorEmpty
()
def
test_correct
(
self
):
def
test_correct
(
self
):
kwargs
=
{
kwargs
=
{
'parameter'
:
{
'Custom1'
:
'one string'
,
'Custom2'
:
'one float'
,
'Custom3'
:
[
'abc'
,
'def'
]},
'title'
:
'My unique instance'
,
'software_release'
:
'http://example.com/example.cfg'
,
'software_release'
:
'http://example.com/example.cfg'
,
'status'
:
'started'
,
'sla'
:
json
.
dumps
({
'sla'
:
{
'computer_id'
:
'COMP-0'
}),
'computer_id'
:
'COMP-0'
},
'software_type'
:
'type_provided_by_the_software'
,
'software_type'
:
'type_provided_by_the_software'
,
'slave'
:
True
}
'slave'
:
'true'
}
self
.
connection
.
request
(
method
=
'GET'
,
self
.
connection
.
request
(
method
=
'GET'
,
url
=
'/'
.
join
([
self
.
api_path
,
'instance'
,
'request'
])
,
url
=
'/'
.
join
([
self
.
api_path
,
'instance'
,
'request'
])
+
\
body
=
json
.
dumps
(
kwargs
),
'?%s'
%
urllib
.
urlencode
(
kwargs
),
headers
=
{
'REMOTE_USER'
:
self
.
customer_reference
})
headers
=
{
'REMOTE_USER'
:
self
.
customer_reference
})
self
.
prepareResponse
()
self
.
prepareResponse
()
self
.
assertBasicResponse
()
self
.
assertBasicResponse
()
...
@@ -991,22 +908,16 @@ class TestInstanceAllocableGET(VifibSlaposRestAPIV1InstanceMixin):
...
@@ -991,22 +908,16 @@ class TestInstanceAllocableGET(VifibSlaposRestAPIV1InstanceMixin):
def
test_additional_key_json
(
self
):
def
test_additional_key_json
(
self
):
kw_request
=
{
kw_request
=
{
'parameter'
:
{
'Custom1'
:
'one string'
,
'Custom2'
:
'one float'
,
'Custom3'
:
[
'abc'
,
'def'
]},
'title'
:
'My unique instance'
,
'software_release'
:
'http://example.com/example.cfg'
,
'software_release'
:
'http://example.com/example.cfg'
,
'status'
:
'started'
,
'sla'
:
json
.
dumps
({
'sla'
:
{
'computer_id'
:
'COMP-0'
}),
'computer_id'
:
'COMP-0'
},
'software_type'
:
'type_provided_by_the_software'
,
'software_type'
:
'type_provided_by_the_software'
,
'slave'
:
True
}
'slave'
:
'true'
}
kwargs
=
kw_request
.
copy
()
kwargs
=
kw_request
.
copy
()
kwargs
.
update
(
**
{
'wrong_key'
:
'Be ignored'
})
kwargs
.
update
(
**
{
'wrong_key'
:
'Be ignored'
})
self
.
connection
.
request
(
method
=
'GET'
,
self
.
connection
.
request
(
method
=
'GET'
,
url
=
'/'
.
join
([
self
.
api_path
,
'instance'
,
'request'
])
,
url
=
'/'
.
join
([
self
.
api_path
,
'instance'
,
'request'
])
+
\
body
=
json
.
dumps
(
kwargs
),
'?%s'
%
urllib
.
urlencode
(
kwargs
),
headers
=
{
'REMOTE_USER'
:
self
.
customer_reference
})
headers
=
{
'REMOTE_USER'
:
self
.
customer_reference
})
self
.
prepareResponse
()
self
.
prepareResponse
()
self
.
assertBasicResponse
()
self
.
assertBasicResponse
()
...
@@ -1041,54 +952,51 @@ class TestInstanceAllocableGET(VifibSlaposRestAPIV1InstanceMixin):
...
@@ -1041,54 +952,51 @@ class TestInstanceAllocableGET(VifibSlaposRestAPIV1InstanceMixin):
# "error": "There is system issue, please try again later.",
# "error": "There is system issue, please try again later.",
# },
# },
# self.json_response)
# self.json_response)
# self.assertPersonRequestSimulatorEmpty()
def
test_content_negotiation_headers
(
self
):
# def test_content_negotiation_headers(self):
self
.
connection
=
CustomHeaderHTTPConnection
(
host
=
self
.
api_netloc
,
# self.connection = CustomHeaderHTTPConnection(host=self.api_netloc,
custom_header
=
{
# custom_header={
'Access-Control-Request-Headers'
:
self
.
access_control_allow_headers
# 'Access-Control-Request-Headers': self.access_control_allow_headers
})
# })
kwargs
=
{
# kwargs = {
'parameter'
:
{
# 'parameter': {
'Custom1'
:
'one string'
,
# 'Custom1': 'one string',
'Custom2'
:
'one float'
,
# 'Custom2': 'one float',
'Custom3'
:
[
'abc'
,
'def'
]},
# 'Custom3': ['abc', 'def']},
'title'
:
'My unique instance'
,
# 'title': 'My unique instance',
'software_release'
:
'http://example.com/example.cfg'
,
# 'software_release': 'http://example.com/example.cfg',
'status'
:
'started'
,
# 'status': 'started',
'sla'
:
{
# 'sla': {
'computer_id'
:
'COMP-0'
},
# 'computer_id': 'COMP-0'},
'software_type'
:
'type_provided_by_the_software'
,
# 'software_type': 'type_provided_by_the_software',
'slave'
:
True
}
# 'slave': True}
self
.
connection
.
request
(
method
=
'GET'
,
# self.connection.request(method='GET',
url
=
'/'
.
join
([
self
.
api_path
,
'instance'
,
'request'
]),
# url='/'.join([self.api_path, 'instance', 'request']),
body
=
json
.
dumps
(
kwargs
),
# body=json.dumps(kwargs),
headers
=
{
'REMOTE_USER'
:
self
.
customer_reference
})
# headers={'REMOTE_USER': self.customer_reference})
self
.
prepareResponse
()
# self.prepareResponse()
self
.
assertBasicResponse
()
# self.assertBasicResponse()
self
.
assertResponseCode
(
400
)
# self.assertResponseCode(400)
self
.
assertResponseJson
()
# self.assertResponseJson()
self
.
assertEqual
({
# self.assertEqual({
'Content-Type'
:
"Header with value '^application/json.*' is required."
},
# 'Content-Type': "Header with value '^application/json.*' is required."},
self
.
json_response
)
# self.json_response)
self
.
assertPersonRequestSimulatorEmpty
()
#
# # now check with incorrect headers
# now check with incorrect headers
# self.connection.request(method='GET',
self
.
connection
.
request
(
method
=
'GET'
,
# url='/'.join([self.api_path, 'instance', 'request']),
url
=
'/'
.
join
([
self
.
api_path
,
'instance'
,
'request'
]),
# body=json.dumps(kwargs),
body
=
json
.
dumps
(
kwargs
),
# headers={'REMOTE_USER': self.customer_reference,
headers
=
{
'REMOTE_USER'
:
self
.
customer_reference
,
# 'Content-Type': 'please/complain',
'Content-Type'
:
'please/complain'
,
# 'Accept': 'be/silent'})
'Accept'
:
'be/silent'
})
# self.prepareResponse()
self
.
prepareResponse
()
# self.assertBasicResponse()
self
.
assertBasicResponse
()
# self.assertResponseCode(400)
self
.
assertResponseCode
(
400
)
# self.assertResponseJson()
self
.
assertResponseJson
()
# self.assertEqual({
self
.
assertEqual
({
# 'Content-Type': "Header with value '^application/json.*' is required."},
'Content-Type'
:
"Header with value '^application/json.*' is required."
},
# self.json_response)
self
.
json_response
)
# # and with correct ones are set by default
self
.
assertPersonRequestSimulatorEmpty
()
# and with correct ones are set by default
def
VifibSlaposRestAPIV1BangMixin_afterSetUp
(
self
):
def
VifibSlaposRestAPIV1BangMixin_afterSetUp
(
self
):
VifibSlaposRestAPIV1BangMixin_afterSetUp
(
self
)
VifibSlaposRestAPIV1BangMixin_afterSetUp
(
self
)
...
...
master/bt5/vifib_slapos_rest_api_v1_test/bt/revision
View file @
7384823f
80
81
\ No newline at end of file
\ 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