diff options
author | Christian Poessinger <christian@poessinger.com> | 2020-02-09 15:39:26 +0100 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2020-02-09 15:39:26 +0100 |
commit | 1b96bcb56ffbf3b6161eb95383ac6726be0281c1 (patch) | |
tree | cb07c06b95e2a522d06f2cec284ec4870935666e | |
parent | bcc0b5bd6e11a9fbc2fcb3c450fdb48bb85499e8 (diff) | |
download | vyos-1x-1b96bcb56ffbf3b6161eb95383ac6726be0281c1.tar.gz vyos-1x-1b96bcb56ffbf3b6161eb95383ac6726be0281c1.zip |
login: check if our newly created users can login to the system
-rwxr-xr-x | scripts/cli/test_system_login.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/scripts/cli/test_system_login.py b/scripts/cli/test_system_login.py index 88e5695e7..9e95a445d 100755 --- a/scripts/cli/test_system_login.py +++ b/scripts/cli/test_system_login.py @@ -18,6 +18,7 @@ import os import re import unittest +from subprocess import Popen, PIPE from vyos.config import Config from vyos.configsession import ConfigSession, ConfigSessionError import vyos.util as util @@ -53,5 +54,17 @@ class TestSystemLogin(unittest.TestCase): self.session.commit() + for user in users: + cmd = ['su','-', user] + proc = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE) + tmp = "{}\nuname -a".format(user) + proc.stdin.write(tmp.encode()) + proc.stdin.flush() + (stdout, stderr) = proc.communicate() + + # stdout is something like this: + # b'Linux vyos 4.19.101-amd64-vyos #1 SMP Sun Feb 2 10:18:07 UTC 2020 x86_64 GNU/Linux\n' + self.assertTrue(len(stdout) > 40) + if __name__ == '__main__': unittest.main() |