1#- 2# Copyright (c) 2022 Baptiste Daroussin <bapt@FreeBSD.org> 3# 4# SPDX-License-Identifier: BSD-2-Clause 5# 6 7export NUAGE_FAKE_ROOTDIR="$PWD" 8 9atf_test_case sethostname 10atf_test_case addsshkey 11atf_test_case adduser 12atf_test_case addgroup 13 14sethostname_body() 15{ 16 atf_check /usr/libexec/flua $(atf_get_srcdir)/sethostname.lua 17 if [ ! -f etc/rc.conf.d/hostname ]; then 18 atf_fail "hostname not written" 19 fi 20 atf_check -o inline:"hostname=\"myhostname\"\n" cat etc/rc.conf.d/hostname 21} 22 23addsshkey_body() 24{ 25 atf_check /usr/libexec/flua $(atf_get_srcdir)/addsshkey.lua 26 if [ ! -f .ssh/authorized_keys ]; then 27 atf_fail "ssh key not added" 28 fi 29 atf_check -o inline:"40700\n" stat -f %p .ssh 30 atf_check -o inline:"100600\n" stat -f %p .ssh/authorized_keys 31 atf_check -o inline:"mykey\n" cat .ssh/authorized_keys 32 atf_check /usr/libexec/flua $(atf_get_srcdir)/addsshkey.lua 33 atf_check -o inline:"mykey\nmykey\n" cat .ssh/authorized_keys 34} 35 36adduser_head() 37{ 38 atf_set "require.user" root 39} 40adduser_body() 41{ 42 mkdir etc 43 printf "root:*:0:0::0:0:Charlie &:/root:/bin/sh\n" > etc/master.passwd 44 pwd_mkdb -d etc etc/master.passwd 45 printf "wheel:*:0:root\n" > etc/group 46 atf_check -e inline:"nuageinit: Argument should be a table\nnuageinit: Argument should be a table\n" /usr/libexec/flua $(atf_get_srcdir)/adduser.lua 47 test -d home/impossible_username || atf_fail "home not created" 48 atf_check -o inline:"impossible_username::1001:1001::0:0:impossible_username User:/home/impossible_username:/bin/sh\n" grep impossible_username etc/master.passwd 49} 50 51addgroup_body() 52{ 53 mkdir etc 54 printf "wheel:*:0:root\n" > etc/group 55 atf_check -e inline:"nuageinit: Argument should be a table\nnuageinit: Argument should be a table\n" /usr/libexec/flua $(atf_get_srcdir)/addgroup.lua 56 atf_check -o inline:"impossible_groupname:*:1001:\n" grep impossible_groupname etc/group 57} 58 59atf_init_test_cases() 60{ 61 atf_add_test_case sethostname 62 atf_add_test_case addsshkey 63 atf_add_test_case adduser 64 atf_add_test_case addgroup 65} 66