@@ -37,3 +37,73 @@ def test_list_endpoints(self):
3737 [{'datacenter' : 'dal05' ,
3838 'private' : 'https://dal05/auth/v1.0/' ,
3939 'public' : 'https://dal05/auth/v1.0/' }])
40+
41+ def test_create_credential (self ):
42+ accounts = self .set_mock ('SoftLayer_Network_Storage_Hub_Cleversafe_Account' , 'credentialCreate' )
43+ accounts .return_value = {
44+ "accountId" : "12345" ,
45+ "createDate" : "2019-04-05T13:25:25-06:00" ,
46+ "id" : 11111 ,
47+ "password" : "nwUEUsx6PiEoN0B1Xe9z9hUCy" ,
48+ "username" : "XfHhBNBPlPdl" ,
49+ "type" : {
50+ "description" : "A credential for generating S3 Compatible Signatures." ,
51+ "keyName" : "S3_COMPATIBLE_SIGNATURE" ,
52+ "name" : "S3 Compatible Signature"
53+ }
54+ }
55+
56+ result = self .run_command (['object-storage' , 'credential' , 'create' , '100' ])
57+
58+ self .assert_no_fail (result )
59+ self .assertEqual (json .loads (result .output ),
60+ [{'id' : 11111 ,
61+ 'password' : 'nwUEUsx6PiEoN0B1Xe9z9hUCy' ,
62+ 'type_name' : 'S3 Compatible Signature' ,
63+ 'username' : 'XfHhBNBPlPdl' }]
64+ )
65+
66+ def test_delete_credential (self ):
67+ accounts = self .set_mock ('SoftLayer_Network_Storage_Hub_Cleversafe_Account' , 'credentialDelete' )
68+ accounts .return_value = True
69+
70+ result = self .run_command (['object-storage' , 'credential' , 'delete' , '-id=100' , '100' ])
71+
72+ self .assert_no_fail (result )
73+ self .assertEqual (json .loads (result .output ),
74+ 'The credential was deleted successful'
75+ )
76+
77+ def test_limit_credential (self ):
78+ accounts = self .set_mock ('SoftLayer_Network_Storage_Hub_Cleversafe_Account' , 'getCredentialLimit' )
79+ accounts .return_value = 2
80+
81+ result = self .run_command (['object-storage' , 'credential' , 'limit' , '100' ])
82+
83+ self .assert_no_fail (result )
84+ self .assertEqual (json .loads (result .output ), [{'limit' : 2 }])
85+
86+ def test_list_credential (self ):
87+ accounts = self .set_mock ('SoftLayer_Network_Storage_Hub_Cleversafe_Account' , 'getCredentials' )
88+ accounts .return_value = [{'id' : 1103123 ,
89+ 'password' : 'nwUEUsx6PiEoN0B1Xe9z9hUCyXM' ,
90+ 'type' : {'name' : 'S3 Compatible Signature' },
91+ 'username' : 'XfHhBNBPlPdlWya' },
92+ {'id' : 1103333 ,
93+ 'password' : 'nwUEUsx6PiEoN0B1Xe9z9' ,
94+ 'type' : {'name' : 'S3 Compatible Signature' },
95+ 'username' : 'XfHhBNBPlPd' }]
96+
97+ result = self .run_command (['object-storage' , 'credential' , 'list' , '100' ])
98+
99+ self .assert_no_fail (result )
100+ print (json .loads (result .output ))
101+ self .assertEqual (json .loads (result .output ),
102+ [{'id' : 1103123 ,
103+ 'password' : 'nwUEUsx6PiEoN0B1Xe9z9hUCyXM' ,
104+ 'type_name' : 'S3 Compatible Signature' ,
105+ 'username' : 'XfHhBNBPlPdlWya' },
106+ {'id' : 1103333 ,
107+ 'password' : 'nwUEUsx6PiEoN0B1Xe9z9' ,
108+ 'type_name' : 'S3 Compatible Signature' ,
109+ 'username' : 'XfHhBNBPlPd' }])
0 commit comments