@@ -25,6 +25,58 @@ def test_server_cancel_reasons(self):
2525 output = json .loads (result .output )
2626 self .assert_no_fail (result )
2727 self .assertEqual (len (output ), 10 )
28+
29+ def test_server_credentials (self ):
30+ result = self .run_command (['hardware' , 'credentials' , '12345' ])
31+
32+ self .assert_no_fail (result )
33+ self .assertEqual (json .loads (result .output ),
34+ [{
35+ 'username' : 'root' ,
36+ 'password' : 'abc123'
37+ }])
38+
39+ def test_server_credentials_exception_passwords_not_found (self ):
40+ mock = self .set_mock ('SoftLayer_Hardware_Server' , 'getObject' )
41+ mock .return_value = {
42+ "accountId" : 11111 ,
43+ "domain" : "chechu.com" ,
44+ "fullyQualifiedDomainName" : "host3.vmware.chechu.com" ,
45+ "hardwareStatusId" : 5 ,
46+ "hostname" : "host3.vmware" ,
47+ "id" : 12345 ,
48+ "operatingSystem" : {}
49+ }
50+
51+ result = self .run_command (['hardware' , 'credentials' , '12345' ])
52+
53+ self .assertEqual (
54+ 'No passwords found in operatingSystem' ,
55+ str (result .exception )
56+ )
57+
58+ def test_server_credentials_exception_password_not_found (self ):
59+ mock = self .set_mock ('SoftLayer_Hardware_Server' , 'getObject' )
60+ mock .return_value = {
61+ "accountId" : 11111 ,
62+ "domain" : "chechu.com" ,
63+ "fullyQualifiedDomainName" : "host3.vmware.chechu.com" ,
64+ "hardwareStatusId" : 5 ,
65+ "hostname" : "host3.vmware" ,
66+ "id" : 12345 ,
67+ "operatingSystem" : {
68+ "hardwareId" : 22222 ,
69+ "id" : 333333 ,
70+ "passwords" : [{}]
71+ }
72+ }
73+
74+ result = self .run_command (['hardware' , 'credentials' , '12345' ])
75+
76+ self .assertEqual (
77+ 'No password found in operatingSystem passwords' ,
78+ str (result .exception )
79+ )
2880
2981 def test_server_details (self ):
3082 result = self .run_command (['server' , 'detail' , '1234' ,
0 commit comments