summaryrefslogtreecommitdiffstats
path: root/nova/tests
diff options
context:
space:
mode:
authorSoren Hansen <soren.hansen@rackspace.com>2010-09-09 12:35:46 +0200
committerSoren Hansen <soren.hansen@rackspace.com>2010-09-09 12:35:46 +0200
commitbd07d6b3b3e9ed3ef3e65e99b628c8b1aaf2f82c (patch)
treedbf10c1cac86e17702155ed61346c560389ea9d0 /nova/tests
parent4da60c687706da55b828411cb912cc38179fffe1 (diff)
Alright, first hole poked all the way through. We can now create security groups and read them back.
Diffstat (limited to 'nova/tests')
-rw-r--r--nova/tests/api_unittest.py34
1 files changed, 31 insertions, 3 deletions
diff --git a/nova/tests/api_unittest.py b/nova/tests/api_unittest.py
index 462d1b295..87d99607d 100644
--- a/nova/tests/api_unittest.py
+++ b/nova/tests/api_unittest.py
@@ -185,6 +185,9 @@ class ApiEc2TestCase(test.BaseTestCase):
self.host = '127.0.0.1'
self.app = api.APIServerApplication({'Cloud': self.cloud})
+
+ def expect_http(self, host=None, is_secure=False):
+ """Returns a new EC2 connection"""
self.ec2 = boto.connect_ec2(
aws_access_key_id='fake',
aws_secret_access_key='fake',
@@ -194,9 +197,6 @@ class ApiEc2TestCase(test.BaseTestCase):
path='/services/Cloud')
self.mox.StubOutWithMock(self.ec2, 'new_http_connection')
-
- def expect_http(self, host=None, is_secure=False):
- """Returns a new EC2 connection"""
http = FakeHttplibConnection(
self.app, '%s:%d' % (self.host, FLAGS.cc_port), False)
# pylint: disable-msg=E1103
@@ -231,3 +231,31 @@ class ApiEc2TestCase(test.BaseTestCase):
self.assertEquals(len(results), 1)
self.manager.delete_project(project)
self.manager.delete_user(user)
+
+ def test_get_all_security_groups(self):
+ """Test that operations on security groups stick"""
+ self.expect_http()
+ self.mox.ReplayAll()
+ security_group_name = "".join(random.choice("sdiuisudfsdcnpaqwertasd") \
+ for x in range(random.randint(4, 8)))
+ user = self.manager.create_user('fake', 'fake', 'fake', admin=True)
+ project = self.manager.create_project('fake', 'fake', 'fake')
+
+ rv = self.ec2.get_all_security_groups()
+ self.assertEquals(len(rv), 1)
+ self.assertEquals(rv[0].name, 'default')
+
+ self.expect_http()
+ self.mox.ReplayAll()
+
+ self.ec2.create_security_group(security_group_name, 'test group')
+
+ self.expect_http()
+ self.mox.ReplayAll()
+
+ rv = self.ec2.get_all_security_groups()
+ self.assertEquals(len(rv), 2)
+ self.assertTrue(security_group_name in [group.name for group in rv])
+
+ self.manager.delete_project(project)
+ self.manager.delete_user(user)