Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
itminedu
synnefo
Commits
3fa0c523
Commit
3fa0c523
authored
Jun 17, 2013
by
Kostas Papadimitriou
Browse files
cyclades: Test invalid http method endpoint calls
parent
b0383033
Changes
3
Hide whitespace changes
Inline
Side-by-side
snf-cyclades-app/synnefo/api/test/images.py
View file @
3fa0c523
...
...
@@ -240,6 +240,36 @@ class ImageAPITest(ComputeAPITest):
except
ValueError
:
self
.
assertTrue
(
False
)
@
assert_backend_closed
def
test_method_not_allowed
(
self
,
*
args
):
# /images/ allows only POST, GET
response
=
self
.
myput
(
'images'
,
''
,
''
)
self
.
assertMethodNotAllowed
(
response
)
response
=
self
.
mydelete
(
'images'
)
self
.
assertMethodNotAllowed
(
response
)
# /images/<imgid>/ allows only GET, DELETE
response
=
self
.
mypost
(
"images/42"
)
self
.
assertMethodNotAllowed
(
response
)
response
=
self
.
myput
(
'images/42'
,
''
,
''
)
self
.
assertMethodNotAllowed
(
response
)
# /images/<imgid>/metadata/ allows only POST, GET
response
=
self
.
myput
(
'images/42/metadata'
,
''
,
''
)
self
.
assertMethodNotAllowed
(
response
)
response
=
self
.
mydelete
(
'images/42/metadata'
)
self
.
assertMethodNotAllowed
(
response
)
# /images/<imgid>/metadata/ allows only POST, GET
response
=
self
.
myput
(
'images/42/metadata'
,
''
,
''
)
self
.
assertMethodNotAllowed
(
response
)
response
=
self
.
mydelete
(
'images/42/metadata'
)
self
.
assertMethodNotAllowed
(
response
)
# /images/<imgid>/metadata/<key> allows only PUT, GET, DELETE
response
=
self
.
mypost
(
'images/42/metadata/foo'
)
self
.
assertMethodNotAllowed
(
response
)
@
patch
(
'synnefo.plankton.backend.ImageBackend'
)
class
ImageMetadataAPITest
(
ComputeAPITest
):
...
...
snf-cyclades-app/synnefo/api/test/networks.py
View file @
3fa0c523
...
...
@@ -441,3 +441,14 @@ class NetworkAPITest(ComputeAPITest):
error
=
json
.
loads
(
response
.
content
)
except
ValueError
:
self
.
assertTrue
(
False
)
def
test_method_not_allowed
(
self
,
*
args
):
# /networks/ allows only POST, GET
response
=
self
.
myput
(
'networks'
,
''
,
''
)
self
.
assertMethodNotAllowed
(
response
)
response
=
self
.
mydelete
(
'networks'
)
self
.
assertMethodNotAllowed
(
response
)
# /networks/<srvid>/ allows only GET, PUT, DELETE
response
=
self
.
mypost
(
"networks/42"
)
self
.
assertMethodNotAllowed
(
response
)
snf-cyclades-app/synnefo/api/test/servers.py
View file @
3fa0c523
...
...
@@ -203,6 +203,33 @@ class ServerAPITest(ComputeAPITest):
except
ValueError
:
self
.
assertTrue
(
False
)
def
test_method_not_allowed
(
self
,
*
args
):
# /servers/ allows only POST, GET
response
=
self
.
myput
(
'servers'
,
''
,
''
)
self
.
assertMethodNotAllowed
(
response
)
response
=
self
.
mydelete
(
'servers'
)
self
.
assertMethodNotAllowed
(
response
)
# /servers/<srvid>/ allows only GET, PUT, DELETE
response
=
self
.
mypost
(
"servers/42"
)
self
.
assertMethodNotAllowed
(
response
)
# /imags/<srvid>/metadata/ allows only POST, GET
response
=
self
.
myput
(
'servers/42/metadata'
,
''
,
''
)
self
.
assertMethodNotAllowed
(
response
)
response
=
self
.
mydelete
(
'servers/42/metadata'
)
self
.
assertMethodNotAllowed
(
response
)
# /imags/<srvid>/metadata/ allows only POST, GET
response
=
self
.
myput
(
'servers/42/metadata'
,
''
,
''
)
self
.
assertMethodNotAllowed
(
response
)
response
=
self
.
mydelete
(
'servers/42/metadata'
)
self
.
assertMethodNotAllowed
(
response
)
# /imags/<srvid>/metadata/<key> allows only PUT, GET, DELETE
response
=
self
.
mypost
(
'servers/42/metadata/foo'
)
self
.
assertMethodNotAllowed
(
response
)
@
patch
(
'synnefo.api.util.get_image'
)
@
patch
(
'synnefo.logic.rapi_pool.GanetiRapiClient'
)
...
...
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