Merge "Clients subclass the RestClient to allow attributes to be overrided by each client and allow better code reuse."
diff --git a/stress/README.rst b/stress/README.rst
index 1667e31..d935289 100644
--- a/stress/README.rst
+++ b/stress/README.rst
@@ -17,7 +17,7 @@
 controlling rate of fire and stuff like that.

 

 This test framework is designed to stress test a Nova cluster. Hence,

-you must have a working Nova cluster.

+you must have a working Nova cluster with rate limiting turned off.

 

 Environment

 ------------

@@ -34,12 +34,16 @@
   controller=<hostname for calling nova-manage>

   max_instances=<limit on instances that will be created>

 

+Also, make sure to set

+

+log_level=CRITICAL

+

+so that the API client does not log failed calls which are expected while

+running stress tests.

+

 The stress test needs the top-level tempest directory to be on PYTHONPATH

 if you are not using nosetests to run.

 

-For real stress, you need to remove "ratelimit" from the pipeline in

-api-paste.ini.

-

 

 Running the sample test

 -----------------------

diff --git a/tempest/tests/test_keypairs.py b/tempest/tests/test_keypairs.py
index baedbb6..40d00dc 100644
--- a/tempest/tests/test_keypairs.py
+++ b/tempest/tests/test_keypairs.py
@@ -2,7 +2,6 @@
 import unittest2 as unittest
 from tempest import openstack
 from tempest.common.utils.data_utils import rand_name
-import tempest.config
 from tempest import exceptions
 
 
@@ -12,7 +11,6 @@
     def setUpClass(cls):
         cls.os = openstack.Manager()
         cls.client = cls.os.keypairs_client
-        cls.config = cls.os.config
 
     @attr(type='smoke')
     def test_keypairs_create_list_delete(self):
@@ -110,6 +108,30 @@
             self.fail('nonexistent key')
 
     @attr(type='negative')
+    def test_create_keypair_with_empty_public_key(self):
+        """Keypair should not be created with an empty public key"""
+        k_name = rand_name("keypair-")
+        pub_key = ' '
+        try:
+            resp, _ = self.client.create_keypair(k_name, pub_key)
+        except exceptions.BadRequest:
+            pass
+        else:
+            self.fail('Expected BadRequest for empty public key')
+
+    @attr(type='negative')
+    def test_create_keypair_when_public_key_bits_exceeds_maximum(self):
+        """Keypair should not be created when public key bits are too long"""
+        k_name = rand_name("keypair-")
+        pub_key = 'ssh-rsa ' + 'A' * 2048 + ' openstack@ubuntu'
+        try:
+            resp, _ = self.client.create_keypair(k_name, pub_key)
+        except exceptions.BadRequest:
+            pass
+        else:
+            self.fail('Expected BadRequest for too long public key')
+
+    @attr(type='negative')
     def test_create_keypair_with_duplicate_name(self):
         """Keypairs with duplicate names should not be created"""
         k_name = rand_name('keypair-')
@@ -146,3 +168,14 @@
             pass
         else:
             self.fail('too long')
+
+    @attr(type='negative')
+    def test_create_keypair_invalid_name(self):
+        """Keypairs with name being an invalid name should not be created"""
+        k_name = 'key_/.\@:'
+        try:
+            resp, _ = self.client.create_keypair(k_name)
+        except exceptions.BadRequest:
+            pass
+        else:
+            self.fail('invalid name')