Commit 3fa0c523 authored by Kostas Papadimitriou's avatar Kostas Papadimitriou
Browse files

cyclades: Test invalid http method endpoint calls

parent b0383033
......@@ -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):
......
......@@ -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)
......@@ -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')
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment