File tree Expand file tree Collapse file tree 2 files changed +31
-2
lines changed
Expand file tree Collapse file tree 2 files changed +31
-2
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,6 @@ def cli(env, identifier):
1717 nw_mgr = SoftLayer .NetworkManager (env .client )
1818 result = nw_mgr .get_nas_credentials (identifier )
1919 table = formatting .Table (['username' , 'password' ])
20- table .add_row ([result [ 'username' ] ,
21- result [ 'password' ] ])
20+ table .add_row ([result . get ( 'username' , 'None' ) ,
21+ result . get ( 'password' , 'None' ) ])
2222 env .fout (table )
Original file line number Diff line number Diff line change @@ -19,3 +19,32 @@ def test_list_nas(self):
1919 'server' : '127.0.0.1' ,
2020 'id' : 1 ,
2121 'size' : 10 }])
22+
23+ def test_nas_credentials (self ):
24+ result = self .run_command (['nas' , 'credentials' , '12345' ])
25+ self .assert_no_fail (result )
26+ self .assertEqual (json .loads (result .output ),
27+ [{
28+ 'password' : '' ,
29+ 'username' : 'username'
30+ }])
31+
32+ def test_server_credentials_exception_password_not_found (self ):
33+ mock = self .set_mock ('SoftLayer_Network_Storage' , 'getObject' )
34+
35+ mock .return_value = {
36+ "accountId" : 11111 ,
37+ "capacityGb" : 20 ,
38+ "id" : 22222 ,
39+ "nasType" : "NAS" ,
40+ "serviceProviderId" : 1 ,
41+ "username" : "SL01SEV307" ,
42+ "credentials" : []
43+ }
44+
45+ result = self .run_command (['nas' , 'credentials' , '12345' ])
46+
47+ self .assertEqual (
48+ 'None' ,
49+ str (result .exception )
50+ )
You can’t perform that action at this time.
0 commit comments