git: fc34a2463c16 - main - nuageinit: add test for the password
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 20 Nov 2024 09:42:20 UTC
The branch main has been updated by bapt: URL: https://cgit.FreeBSD.org/src/commit/?id=fc34a2463c16fd47acbc8e5c3bbbb6b2ce1b1469 commit fc34a2463c16fd47acbc8e5c3bbbb6b2ce1b1469 Author: Baptiste Daroussin <bapt@FreeBSD.org> AuthorDate: 2024-11-20 09:32:16 +0000 Commit: Baptiste Daroussin <bapt@FreeBSD.org> CommitDate: 2024-11-20 09:41:46 +0000 nuageinit: add test for the password --- libexec/nuageinit/tests/Makefile | 7 +++++++ libexec/nuageinit/tests/nuage.sh | 15 +++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/libexec/nuageinit/tests/Makefile b/libexec/nuageinit/tests/Makefile index ccb81c090445..bb2f0d7c747e 100644 --- a/libexec/nuageinit/tests/Makefile +++ b/libexec/nuageinit/tests/Makefile @@ -1,10 +1,17 @@ PACKAGE= tests +.PATH: ${SRCTOP}/usr.sbin/pw/tests + +BINDIR= ${TESTSDIR} + +PROGS= crypt +LIBADD= crypt ATF_TESTS_SH= nuage utils nuageinit ${PACKAGE}FILES+= addgroup.lua ${PACKAGE}FILES+= addsshkey.lua ${PACKAGE}FILES+= adduser.lua +${PACKAGE}FILES+= adduser_passwd.lua ${PACKAGE}FILES+= dirname.lua ${PACKAGE}FILES+= err.lua ${PACKAGE}FILES+= sethostname.lua diff --git a/libexec/nuageinit/tests/nuage.sh b/libexec/nuageinit/tests/nuage.sh index 293a0a4a9a83..a5451561202f 100644 --- a/libexec/nuageinit/tests/nuage.sh +++ b/libexec/nuageinit/tests/nuage.sh @@ -9,6 +9,7 @@ export NUAGE_FAKE_ROOTDIR="$PWD" atf_test_case sethostname atf_test_case addsshkey atf_test_case adduser +atf_test_case adduser_passwd atf_test_case addgroup sethostname_body() @@ -48,6 +49,19 @@ adduser_body() 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 } +adduser_passwd_body() +{ + mkdir etc + printf "root:*:0:0::0:0:Charlie &:/root:/bin/sh\n" > etc/master.passwd + pwd_mkdb -d etc etc/master.passwd + printf "wheel:*:0:root\n" > etc/group + atf_check /usr/libexec/flua $(atf_get_srcdir)/adduser_passwd.lua + test -d home/foo || atf_fail "home not created" + passhash=`awk -F ':' '/^foo:/ {print $2}' etc/master.passwd` + atf_check -s exit:0 -o inline:$passhash \ + $(atf_get_srcdir)/crypt $passhash "bar" +} + addgroup_body() { mkdir etc @@ -61,5 +75,6 @@ atf_init_test_cases() atf_add_test_case sethostname atf_add_test_case addsshkey atf_add_test_case adduser + atf_add_test_case adduser_passwd atf_add_test_case addgroup }