summaryrefslogtreecommitdiffstats
path: root/nova/tests
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2012-06-01 17:02:50 +0000
committerGerrit Code Review <review@openstack.org>2012-06-01 17:02:50 +0000
commit44ac6e69a0a98f92584c8d3a1fec997ec653812d (patch)
tree3adaf3f19c5a666f2d6d6c800e9fe52e7fc2779e /nova/tests
parentaae9f614090c8eca9f596efcc5238d5b8200061b (diff)
parenta8d9bf7705d01fc40a652e7e35624a1488d3a44f (diff)
Merge "[PATCH] Allow [:print:] chars for security group names"
Diffstat (limited to 'nova/tests')
-rw-r--r--nova/tests/test_api.py48
1 files changed, 35 insertions, 13 deletions
diff --git a/nova/tests/test_api.py b/nova/tests/test_api.py
index 37fdec74a..b2afb54d9 100644
--- a/nova/tests/test_api.py
+++ b/nova/tests/test_api.py
@@ -34,10 +34,14 @@ from nova.api.ec2 import ec2utils
from nova import block_device
from nova import context
from nova import exception
+from nova import flags
from nova import test
from nova import utils
+FLAGS = flags.FLAGS
+
+
class FakeHttplibSocket(object):
"""a fake socket implementation for httplib.HTTPResponse, trivial"""
def __init__(self, response_string):
@@ -344,19 +348,37 @@ class ApiEc2TestCase(test.TestCase):
def test_group_name_valid_chars_security_group(self):
""" Test that we sanely handle invalid security group names.
- API Spec states we should only accept alphanumeric characters,
- spaces, dashes, and underscores. """
- self.expect_http()
- self.mox.ReplayAll()
-
- # Test block group_name of non alphanumeric characters, spaces,
- # dashes, and underscores.
- security_group_name = "aa #^% -=99"
-
- self.assertRaises(boto_exc.EC2ResponseError,
- self.ec2.create_security_group,
- security_group_name,
- 'test group')
+ EC2 API Spec states we should only accept alphanumeric characters,
+ spaces, dashes, and underscores. Amazon implementation
+ accepts more characters - so, [:print:] is ok. """
+
+ bad_strict_ec2 = "aa \t\x01\x02\x7f"
+ bad_amazon_ec2 = "aa #^% -=99"
+ test_raise = [
+ (True, bad_amazon_ec2, "test desc"),
+ (True, "test name", bad_amazon_ec2),
+ (False, bad_strict_ec2, "test desc"),
+ ]
+ for test in test_raise:
+ self.expect_http()
+ self.mox.ReplayAll()
+ FLAGS.ec2_strict_validation = test[0]
+ self.assertRaises(boto_exc.EC2ResponseError,
+ self.ec2.create_security_group,
+ test[1],
+ test[2])
+ test_accept = [
+ (False, bad_amazon_ec2, "test desc"),
+ (False, "test name", bad_amazon_ec2),
+ ]
+ for test in test_accept:
+ self.expect_http()
+ self.mox.ReplayAll()
+ FLAGS.ec2_strict_validation = test[0]
+ self.ec2.create_security_group(test[1], test[2])
+ self.expect_http()
+ self.mox.ReplayAll()
+ self.ec2.delete_security_group(test[1])
def test_group_name_valid_length_security_group(self):
"""Test that we sanely handle invalid security group names.