summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Walker (Daviey) <DaveWalker@ubuntu.com>2011-05-23 22:15:10 +0100
committerDave Walker (Daviey) <DaveWalker@ubuntu.com>2011-05-23 22:15:10 +0100
commit63dbfeb2cb5b834a0cb4dd23c30522f540ac539b (patch)
treefb6cc9dc4ea9fc93fa4e19d4a6f6a1bcc89a8f19
parent57a405d630176ab6cb2b8e37ac123fa91d9f089b (diff)
downloadnova-63dbfeb2cb5b834a0cb4dd23c30522f540ac539b.tar.gz
nova-63dbfeb2cb5b834a0cb4dd23c30522f540ac539b.tar.xz
nova-63dbfeb2cb5b834a0cb4dd23c30522f540ac539b.zip
Added test case for attempting to create a duplicate keypair
-rw-r--r--nova/tests/test_api.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/nova/tests/test_api.py b/nova/tests/test_api.py
index 97f401b87..7c0331eff 100644
--- a/nova/tests/test_api.py
+++ b/nova/tests/test_api.py
@@ -224,6 +224,29 @@ class ApiEc2TestCase(test.TestCase):
self.manager.delete_project(project)
self.manager.delete_user(user)
+ def test_create_duplicate_key_pair(self):
+ """Test that, after successfully generating a keypair,
+ requesting a second keypair with the same name fails sanely"""
+ self.expect_http()
+ self.mox.ReplayAll()
+ keyname = "".join(random.choice("sdiuisudfsdcnpaqwertasd") \
+ for x in range(random.randint(4, 8)))
+ user = self.manager.create_user('fake', 'fake', 'fake')
+ project = self.manager.create_project('fake', 'fake', 'fake')
+ # NOTE(vish): create depends on pool, so call helper directly
+ self.ec2.create_key_pair('test')
+
+ try:
+ self.ec2.create_key_pair('test')
+ except EC2ResponseError, e:
+ if e.code == 'KeyPairExists':
+ pass
+ else:
+ self.fail("Unexpected EC2ResponseError: %s "
+ "(expected KeyPairExists)" % e.code)
+ else:
+ self.fail('Exception not raised.')
+
def test_get_all_security_groups(self):
"""Test that we can retrieve security groups"""
self.expect_http()