1010# License for the specific language governing permissions and limitations
1111# under the License.
1212
13+ import os
1314import uuid
1415
1516from functional .common import test
1617
1718
19+ PUBLIC_KEY = (
20+ 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDWNGczJxNaFUrJJVhta4dWsZY6bU'
21+ '5HUMPbyfSMu713ca3mYtG848W4dfDCB98KmSQx2Bl0D6Q2nrOszOXEQWAXNdfMadnW'
22+ 'c4mNwhZcPBVohIFoC1KZJC8kcBTvFZcoz3mdIijxJtywZNpGNh34VRJlZeHyYjg8/D'
23+ 'esHzdoBVd5c/4R36emQSIV9ukY6PHeZ3scAH4B3K9PxItJBwiFtouSRphQG0bJgOv/'
24+ 'gjAjMElAvg5oku98cb4QiHZ8T8WY68id804raHR6pJxpVVJN4TYJmlUs+NOVM+pPKb'
25+ 'KJttqrIBTkawGK9pLHNfn7z6v1syvUo/4enc1l0Q/Qn2kWiz67 fake@openstack'
26+ )
27+
28+
1829class KeypairTests (test .TestCase ):
1930 """Functional tests for compute keypairs. """
2031 NAME = uuid .uuid4 ().hex
@@ -32,6 +43,21 @@ def tearDownClass(cls):
3243 raw_output = cls .openstack ('keypair delete ' + cls .NAME )
3344 cls .assertOutput ('' , raw_output )
3445
46+ def test_keypair_create (self ):
47+ TMP_FILE = uuid .uuid4 ().hex
48+ self .addCleanup (os .remove , TMP_FILE )
49+ with open (TMP_FILE , 'w' ) as f :
50+ f .write (PUBLIC_KEY )
51+
52+ raw_output = self .openstack (
53+ 'keypair create --public-key ' + TMP_FILE + ' tmpkey' ,
54+ )
55+ self .addCleanup (
56+ self .openstack ,
57+ 'keypair delete tmpkey' ,
58+ )
59+ self .assertIn ('tmpkey' , raw_output )
60+
3561 def test_keypair_list (self ):
3662 opts = self .get_list_opts (self .HEADERS )
3763 raw_output = self .openstack ('keypair list' + opts )
0 commit comments