diff options
| author | Jenkins <jenkins@review.openstack.org> | 2017-03-08 02:51:48 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2017-03-08 02:51:48 +0000 |
| commit | dcb2de9db2ea9ff3b4673f9250b593c2aca3c241 (patch) | |
| tree | 6b5f6ab1f54fdbd345e71c50f45f745d7bb4e6f8 /openstackclient/tests/functional/compute | |
| parent | 054060cbef033b36d22caf47ae44f47e26da597f (diff) | |
| parent | dee22d8faa0c8a0da1d6ff62c0997c2cc770b759 (diff) | |
| download | python-openstackclient-dcb2de9db2ea9ff3b4673f9250b593c2aca3c241.tar.gz | |
Merge "Add "--private-key" option for "keypair create""
Diffstat (limited to 'openstackclient/tests/functional/compute')
| -rw-r--r-- | openstackclient/tests/functional/compute/v2/test_keypair.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/openstackclient/tests/functional/compute/v2/test_keypair.py b/openstackclient/tests/functional/compute/v2/test_keypair.py index 01078c61..1e1a03d6 100644 --- a/openstackclient/tests/functional/compute/v2/test_keypair.py +++ b/openstackclient/tests/functional/compute/v2/test_keypair.py @@ -10,6 +10,7 @@ # License for the specific language governing permissions and limitations # under the License. +import json import tempfile from openstackclient.tests.functional import base @@ -100,6 +101,26 @@ class KeypairTests(KeypairBase): ) self.assertIn('tmpkey', raw_output) + def test_keypair_create_private_key(self): + """Test for create keypair with --private-key option. + + Test steps: + 1) Create keypair with private key file + 2) Delete keypair + """ + with tempfile.NamedTemporaryFile() as f: + cmd_output = json.loads(self.openstack( + 'keypair create -f json --private-key %s tmpkey' % f.name, + )) + self.addCleanup(self.openstack, 'keypair delete tmpkey') + self.assertEqual('tmpkey', cmd_output.get('name')) + self.assertIsNotNone(cmd_output.get('user_id')) + self.assertIsNotNone(cmd_output.get('fingerprint')) + pk_content = f.read() + self.assertInOutput('-----BEGIN RSA PRIVATE KEY-----', pk_content) + self.assertRegex(pk_content, "[0-9A-Za-z+/]+[=]{0,3}\n") + self.assertInOutput('-----END RSA PRIVATE KEY-----', pk_content) + def test_keypair_create(self): """Test keypair create command. |
