kumquat-buildroot/support/testing/tests/package/test_shadow.py
Thomas Petazzoni 9c3cdee11a support/testing/tests/package/test_shadow.py: drop blank line at end of file
Fixes:

support/testing/tests/package/test_shadow.py:55:1: W391 blank line at end of file
1     W391 blank line at end of file
make: *** [Makefile:1253: check-flake8] Error 123

https://gitlab.com/buildroot.org/buildroot/-/jobs/3918132888

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2023-03-12 20:27:31 +01:00

55 lines
1.8 KiB
Python

import os
from infra.basetest import BRTest, BASIC_TOOLCHAIN_CONFIG
class TestShadow(BRTest):
username = 'user_test'
config = BASIC_TOOLCHAIN_CONFIG + \
"""
BR2_arm=y
BR2_PACKAGE_SHADOW=y
BR2_TARGET_ROOTFS_EXT2=y
BR2_TARGET_ROOTFS_EXT2_4=y
BR2_TARGET_ROOTFS_EXT2_SIZE="65536"
"""
timeout = 60
def login(self):
img = os.path.join(self.builddir, "images", "rootfs.ext4")
self.emulator.boot(arch="armv7",
kernel="builtin",
kernel_cmdline=["root=/dev/mmcblk0",
"rootfstype=ext4"],
options=["-drive", f"file={img},if=sd,format=raw"])
self.emulator.login()
def test_nologin(self):
self.login()
self.assertRunOk("! nologin")
cmd = 'test "$(nologin)" = "This account is currently not available."'
self.assertRunOk(cmd)
def test_useradd_del(self):
username = self.username
self.login()
self.assertRunOk(f'userdel {username} || true')
self.assertRunOk(f'groupdel {username} || true')
self.assertRunOk(f'useradd -s /bin/sh {username}')
self.assertRunOk(f'test $(su {username} -c "whoami") = {username}')
self.assertRunOk(f'userdel {username}')
def test_usermod(self):
username = self.username
new_home = '/tmp'
self.login()
self.assertRunOk(f'userdel {username} || true')
self.assertRunOk(f'groupdel {username} || true')
self.assertRunOk(f'useradd -s /bin/sh {username}')
self.assertRunOk(f'usermod {username} --home {new_home}')
self.assertRunOk(f'test $(su {username} -c \'echo $HOME\') = {new_home}')
self.assertRunOk(f'userdel {username}')