Skip to content
Permalink
Browse files
Finish testing in Firewalls
  • Loading branch information
brogand93 committed Jun 8, 2014
1 parent 880891a commit 18815dbbe0ac5cba3ff37d27a36131136f76391a
Showing 1 changed file with 43 additions and 0 deletions.
@@ -47,3 +47,46 @@ def test_get_firewall_firewall_not_found(self):
self.assert_not_found(response)
assert 'The resource \'/compute/v1/projects/exampleproject/global/firewalls/securitygroupname\' was not found' \
in response.data

def test_add_firewall(self):
data = {
"kind": "compute#firewall",
"network": "https://localhost:5000/compute/v1/projects/brogand93@darrenbrogan.ie/global/networks/default",
"description": "",
"sourceRanges": ["0.0.0.0/0"],
"allowed": [{
"IPProtocol": "6",
"ports": ["22"]
}],
"name": "ssh"
}

data = json.dumps(data)

get = mock.Mock()
get.return_value.text = read_file('tests/data/valid_create_security_group.json')
get.return_value.status_code = 200

with mock.patch('requests.get', get):
headers = {
'authorization': 'Bearer ' + str(GStackAppTestCase.access_token),
}

response = self.post_json('/compute/v1/projects/exampleproject/global/firewalls', data=data, headers=headers)

self.assert_ok(response)

def test_delete_firewall(self):

get = mock.Mock()
get.return_value.text = read_file('tests/data/valid_delete_security_group.json')
get.return_value.status_code = 200

with mock.patch('requests.get', get):
headers = {
'authorization': 'Bearer ' + str(GStackAppTestCase.access_token),
}

response = self.delete('/compute/v1/projects/exampleproject/global/firewalls/firewallname', headers=headers)

self.assert_ok(response)

0 comments on commit 18815db

Please sign in to comment.