[KVM-AUTOTEST PATCH 18/26] KVM test: _remote_login(): fail if a login prompt is received after a password prompt

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



No need to wait for the password prompt to appear twice.  If a login prompt is
received after a password prompt, it means the password/username was incorrect.

Signed-off-by: Michael Goldish <mgoldish@xxxxxxxxxx>
---
 client/tests/kvm/kvm_utils.py |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/client/tests/kvm/kvm_utils.py b/client/tests/kvm/kvm_utils.py
index 178a665..d7e205d 100644
--- a/client/tests/kvm/kvm_utils.py
+++ b/client/tests/kvm/kvm_utils.py
@@ -556,14 +556,17 @@ def _remote_login(session, username, password, prompt, timeout=10):
                     raise LoginAuthenticationError("Got password prompt twice",
                                                    text)
             elif match == 2:  # "login:"
-                if login_prompt_count == 0:
+                if login_prompt_count == 0 and password_prompt_count == 0:
                     logging.debug("Got username prompt; sending '%s'" % username)
                     session.sendline(username)
                     login_prompt_count += 1
                     continue
                 else:
-                    raise LoginAuthenticationError("Got username prompt twice",
-                                                   text)
+                    if login_prompt_count > 0:
+                        msg = "Got username prompt twice"
+                    else:
+                        msg = "Got username prompt after password prompt"
+                    raise LoginAuthenticationError(msg, text)
             elif match == 3:  # "Connection closed"
                 raise LoginError("Client said 'connection closed'", text)
             elif match == 4:  # "Connection refused"
-- 
1.7.3.4

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux