[gnome-boxes] tests: Add "Verify user with password" step



commit ab35c4c72a8334f2e24fb56ea93ee50c6a058e58
Author: Vladimir Benes <benesv email cz>
Date:   Wed Jun 10 13:30:27 2015 +0200

    tests: Add "Verify user with password" step
    
    Check over ssh (using pexpect) that user is able to log into VM with
    password.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=748006

 tests/steps/express-install.py |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)
---
diff --git a/tests/steps/express-install.py b/tests/steps/express-install.py
index 9124f64..a6294c2 100644
--- a/tests/steps/express-install.py
+++ b/tests/steps/express-install.py
@@ -4,6 +4,7 @@ from __future__ import unicode_literals
 import libvirt
 from time import sleep
 from general import libvirt_domain_get_val, libvirt_domain_get_context
+import pexpect
 
 def libvirt_domain_get_install_state(title):
     state = None
@@ -35,3 +36,16 @@ def check_finished_installation(context, machine, max_time):
             sleep(60)
 
     assert state == 'installed', "%s is not installed but still in %s after %s minutes" %(machine, state, 
max_time)
+
+ step('Verify "{user}" user with "{passwd}" password in "{machine}"')
+def verify_user_in_machine(context, user, passwd, machine):
+    # using pexpect to spawn ssh session
+    ssh = pexpect.spawn("ssh -o 'StrictHostKeyChecking no' %s %s'" %(user, context.ips[machine]))
+    # waiting for password: keyword
+    ssh.expect('password:')
+    # sending password
+    ssh.sendline(passwd)
+    # check for prompt shown after login. ~ is correct, otherwise not.
+    out = ssh.expect(['~', 'Permission denied', pexpect.EOF])
+    if out != 0:
+        raise Exception('Got an Error while authenticating %s on %s' % (user, passwd))


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