Commit 1332fef6 authored by Dionysis Grigoropoulos's avatar Dionysis Grigoropoulos
Browse files

cyclades: Add tests for servers/networks/subnets

Add new tests for changes introduced in commit 35ea7f6
parent 0c3c41fa
......@@ -214,6 +214,13 @@ class NetworkTest(BaseAPITest):
response = self.put(url, test_net.userid, json.dumps(request), 'json')
self.assertFault(response, 403, 'forbidden')
def test_rename_network_invalid_name(self):
test_net = dbmf.NetworkFactory(name="foo")
url = join_urls(NETWORKS_URL, str(test_net.id))
request = {'network': {'name': 'a' * 500}}
response = self.put(url, test_net.userid, json.dumps(request), 'json')
self.assertEqual(response.status_code, 400)
def test_method_not_allowed(self, *args):
# /networks/ allows only POST, GET
response = self.put(NETWORKS_URL, '', '')
......
......@@ -282,6 +282,13 @@ class ServerAPITest(ComputeAPITest):
self.assertSuccess(response)
self.assertEqual(VirtualMachine.objects.get(id=vm.id).name, "new_name")
def test_rename_server_invalid_name(self):
vm = self.vm2
request = {'server': {'name': 'a' * 500}}
response = self.myput('servers/%d' % vm.id, vm.userid,
json.dumps(request), 'json')
self.assertBadRequest(response)
def test_catch_wrong_api_paths(self):
response = self.myget('nonexistent')
self.assertEqual(response.status_code, 400)
......@@ -737,6 +744,10 @@ class ServerActionAPITest(ComputeAPITest):
response = self.mypost('servers/%d/action' % vm.id,
vm.userid, json.dumps(request), 'json')
self.assertItemNotFound(response)
request = {'firewallProfile': {'profile': 'PROTECTED', "nic": "error"}}
response = self.mypost('servers/%d/action' % vm.id,
vm.userid, json.dumps(request), 'json')
self.assertBadRequest(response)
nic = mfactory.NetworkInterfaceFactory(machine=vm)
request = {'firewallProfile': {'profile': 'PROTECTED', "nic": nic.id}}
response = self.mypost('servers/%d/action' % vm.id,
......
......@@ -143,6 +143,19 @@ class SubnetTest(BaseAPITest):
json.dumps(request), "json")
self.assertBadRequest(response)
def test_create_subnet_with_malformed_network_id(self):
"""Test create a subnet with an invalid network ID"""
test_net = mf.NetworkFactory()
request = {
'subnet': {
'network_id': 'error',
'cidr': '192.168.42.0/24',
'ip_version': 4}
}
response = self.post(SUBNETS_URL, test_net.userid,
json.dumps(request), "json")
self.assertBadRequest(response)
def test_create_subnet_success_ipv6(self):
"""Test create an IPv6 subnet successfully"""
test_net = mf.NetworkFactory()
......
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