diff mbox

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

Message ID 1294751618-21631-18-git-send-email-mgoldish@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Michael Goldish Jan. 11, 2011, 1:13 p.m. UTC
None
diff mbox

Patch

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"