summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Walker (Daviey) <DaveWalker@ubuntu.com>2011-07-18 00:06:48 +0100
committerDave Walker (Daviey) <DaveWalker@ubuntu.com>2011-07-18 00:06:48 +0100
commit64a03d48bd714672a3d68136d365bf941201affa (patch)
treece116f859476f61ce145d4a8eebd04ab43a1bee3
parent5c6e4aa80672966ad4449007feea970cd62dee10 (diff)
downloadnova-64a03d48bd714672a3d68136d365bf941201affa.tar.gz
nova-64a03d48bd714672a3d68136d365bf941201affa.tar.xz
nova-64a03d48bd714672a3d68136d365bf941201affa.zip
Extended test to check for error specific error code and test cover for bad chars.
-rw-r--r--nova/tests/test_api.py24
1 files changed, 22 insertions, 2 deletions
diff --git a/nova/tests/test_api.py b/nova/tests/test_api.py
index 63f040ffd..de399d76e 100644
--- a/nova/tests/test_api.py
+++ b/nova/tests/test_api.py
@@ -304,12 +304,32 @@ class ApiEc2TestCase(test.TestCase):
self.manager.add_role('fake', 'netadmin')
project.add_role('fake', 'netadmin')
+ # Test block group_name of non alphanumeric characters, spaces,
+ # dashes, and underscores.
+ security_group_name = "aa #$% -=99"
+
+ try:
+ self.ec2.create_security_group(security_group_name, 'test group')
+ except EC2ResponseError, e:
+ if e.code == 'InvalidParameterValue':
+ pass
+ else:
+ self.fail("Unexpected EC2ResponseError: %s "
+ "(expected InvalidParameterValue)" % e.code)
+ else:
+ self.fail('Exception not raised.')
+
+ # Test block group_name > 255 chars
security_group_name = "".join(random.choice("poiuytrewqasdfghjklmnbvc")
for x in range(random.randint(256, 266)))
try:
self.ec2.create_security_group(security_group_name, 'test group')
- except:
- pass
+ except EC2ResponseError, e:
+ if e.code == 'InvalidParameterValue':
+ pass
+ else:
+ self.fail("Unexpected EC2ResponseError: %s "
+ "(expected InvalidParameterValue)" % e.code)
else:
self.fail('Exception not raised.')