@@ -76,40 +76,29 @@ def run(test, params, env):
76
76
ret = process .run (cmd , shell = True )
77
77
libvirt .check_exit_status (ret )
78
78
en_passwd = str (ret .stdout_text .strip ())
79
- passwd = en_passwd
79
+ passwd = en_passwd . replace ( '$' , r'\$' )
80
80
81
81
ret = virsh .set_user_password (vm_name , set_user_name , passwd ,
82
82
encrypted = encrypted , option = option , debug = True )
83
83
libvirt .check_exit_status (ret )
84
84
85
85
# Login with new password
86
+ logging .debug ("Trying to log in with new password" )
86
87
try :
87
88
session = remote .wait_for_login ("ssh" , vm_ip , "22" , set_user_name , new_passwd ,
88
89
r"[\#\$]\s*$" , timeout = 30 )
89
90
session .close ()
90
91
except remote .LoginAuthenticationError as e :
91
92
logging .debug (e )
93
+ test .fail ("Failed to login with new password" )
92
94
93
- # Login with old password
94
- try :
95
- session = remote .wait_for_login ("ssh" , vm_ip , "22" , set_user_name , ori_passwd ,
96
- r"[\#\$]\s*$" , timeout = 10 )
97
- session .close ()
98
- except remote .LoginAuthenticationError :
99
- logging .debug ("Login with old password failed as expected." )
100
-
101
- # Change the password back in VM
102
- ret = virsh .set_user_password (vm_name , set_user_name , ori_passwd , False ,
103
- option = option , debug = True )
104
- libvirt .check_exit_status (ret )
105
-
106
- # Login with the original password
107
- try :
108
- session = remote .wait_for_login ("ssh" , vm_ip , "22" , set_user_name , ori_passwd ,
109
- r"[\#\$]\s*$" , timeout = 30 )
110
- session .close ()
111
- except remote .LoginAuthenticationError as e :
112
- logging .debug (e )
95
+ finally :
96
+ # Recover VM
97
+ if vm .is_alive ():
98
+ # always restore root password in case previously case execution is broken
99
+ if status_error != "yes" :
100
+ virsh .set_user_password (vm_name , set_user_name , ori_passwd , False ,
101
+ option = option , debug = True )
113
102
114
103
if start_ga :
115
104
# Stop guest agent in vm
@@ -124,12 +113,5 @@ def run(test, params, env):
124
113
test .error ("Deleting user '%s' got failed: '%s'" %
125
114
(set_user_name , output ))
126
115
session .close ()
127
- finally :
128
- # Recover VM
129
- if vm .is_alive ():
130
- # always restore root password in case previously case execution is broken
131
- if status_error != "yes" :
132
- virsh .set_user_password (vm_name , set_user_name , ori_passwd , False ,
133
- option = option , debug = True )
134
116
vm .destroy (gracefully = False )
135
117
vmxml_bak .sync ()
0 commit comments