blob: 8a53899c7d006bb97d4c3a00973beb226a9a1b31 [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001from oeqa.selftest.base import oeSelfTest
2from oeqa.utils.commands import runCmd, bitbake, get_bb_var, runqemu
3from oeqa.utils.decorators import testcase
4from oeqa.utils.sshcontrol import SSHControl
5import os
6import sys
7import logging
8
9class ImageFeatures(oeSelfTest):
10
11 test_user = 'tester'
12 root_user = 'root'
13
14 @testcase(1107)
15 def test_non_root_user_can_connect_via_ssh_without_password(self):
16 """
17 Summary: Check if non root user can connect via ssh without password
18 Expected: 1. Connection to the image via ssh using root user without providing a password should be allowed.
19 2. Connection to the image via ssh using tester user without providing a password should be allowed.
20 Product: oe-core
21 Author: Ionut Chisanovici <ionutx.chisanovici@intel.com>
22 AutomatedBy: Daniel Istrate <daniel.alexandrux.istrate@intel.com>
23 """
24
25 features = 'EXTRA_IMAGE_FEATURES = "ssh-server-openssh empty-root-password allow-empty-password"\n'
26 features += 'INHERIT += "extrausers"\n'
27 features += 'EXTRA_USERS_PARAMS = "useradd -p \'\' {}; usermod -s /bin/sh {};"'.format(self.test_user, self.test_user)
Patrick Williamsf1e5d692016-03-30 15:21:19 -050028 self.write_config(features)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050029
30 # Build a core-image-minimal
31 bitbake('core-image-minimal')
32
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050033 with runqemu("core-image-minimal") as qemu:
Patrick Williamsc124f4f2015-09-15 14:41:29 -050034 # Attempt to ssh with each user into qemu with empty password
35 for user in [self.root_user, self.test_user]:
36 ssh = SSHControl(ip=qemu.ip, logfile=qemu.sshlog, user=user)
37 status, output = ssh.run("true")
38 self.assertEqual(status, 0, 'ssh to user %s failed with %s' % (user, output))
39
40 @testcase(1115)
41 def test_all_users_can_connect_via_ssh_without_password(self):
42 """
43 Summary: Check if all users can connect via ssh without password
44 Expected: 1. Connection to the image via ssh using root user without providing a password should NOT be allowed.
45 2. Connection to the image via ssh using tester user without providing a password should be allowed.
46 Product: oe-core
47 Author: Ionut Chisanovici <ionutx.chisanovici@intel.com>
48 AutomatedBy: Daniel Istrate <daniel.alexandrux.istrate@intel.com>
49 """
50
51 features = 'EXTRA_IMAGE_FEATURES = "ssh-server-openssh allow-empty-password"\n'
52 features += 'INHERIT += "extrausers"\n'
53 features += 'EXTRA_USERS_PARAMS = "useradd -p \'\' {}; usermod -s /bin/sh {};"'.format(self.test_user, self.test_user)
Patrick Williamsf1e5d692016-03-30 15:21:19 -050054 self.write_config(features)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050055
56 # Build a core-image-minimal
57 bitbake('core-image-minimal')
58
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050059 with runqemu("core-image-minimal") as qemu:
Patrick Williamsc124f4f2015-09-15 14:41:29 -050060 # Attempt to ssh with each user into qemu with empty password
61 for user in [self.root_user, self.test_user]:
62 ssh = SSHControl(ip=qemu.ip, logfile=qemu.sshlog, user=user)
63 status, output = ssh.run("true")
64 if user == 'root':
65 self.assertNotEqual(status, 0, 'ssh to user root was allowed when it should not have been')
66 else:
67 self.assertEqual(status, 0, 'ssh to user tester failed with %s' % output)
68
69
Patrick Williamsc124f4f2015-09-15 14:41:29 -050070 @testcase(1116)
71 def test_clutter_image_can_be_built(self):
72 """
73 Summary: Check if clutter image can be built
74 Expected: 1. core-image-clutter can be built
75 Product: oe-core
76 Author: Ionut Chisanovici <ionutx.chisanovici@intel.com>
77 AutomatedBy: Daniel Istrate <daniel.alexandrux.istrate@intel.com>
78 """
79
80 # Build a core-image-clutter
81 bitbake('core-image-clutter')
82
83 @testcase(1117)
84 def test_wayland_support_in_image(self):
85 """
86 Summary: Check Wayland support in image
87 Expected: 1. Wayland image can be build
88 2. Wayland feature can be installed
89 Product: oe-core
90 Author: Ionut Chisanovici <ionutx.chisanovici@intel.com>
91 AutomatedBy: Daniel Istrate <daniel.alexandrux.istrate@intel.com>
92 """
93
94 features = 'DISTRO_FEATURES_append = " wayland"\n'
95 features += 'CORE_IMAGE_EXTRA_INSTALL += "wayland weston"'
Patrick Williamsf1e5d692016-03-30 15:21:19 -050096 self.write_config(features)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050097
98 # Build a core-image-weston
99 bitbake('core-image-weston')
100