diff options
author | Baptiste Daroussin <bapt@FreeBSD.org> | 2015-07-05 09:48:03 +0000 |
---|---|---|
committer | Baptiste Daroussin <bapt@FreeBSD.org> | 2015-07-05 09:48:03 +0000 |
commit | ede1c7addbd047595d4ca1701f0d4f9b143694ed (patch) | |
tree | 54ff1bf0f8e84899345fc0a865e84db115196e86 /pw/tests/pw_useradd.sh | |
parent | 61380b9ab922279f463e451be86a4f9515d8003d (diff) | |
download | pw-darwin-ede1c7addbd047595d4ca1701f0d4f9b143694ed.tar.gz pw-darwin-ede1c7addbd047595d4ca1701f0d4f9b143694ed.tar.zst pw-darwin-ede1c7addbd047595d4ca1701f0d4f9b143694ed.zip |
Validate expiration dates
Use strptime_l(3) to validate the dates provided in input
Diffstat (limited to 'pw/tests/pw_useradd.sh')
-rwxr-xr-x | pw/tests/pw_useradd.sh | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/pw/tests/pw_useradd.sh b/pw/tests/pw_useradd.sh index 27a8624..93cde50 100755 --- a/pw/tests/pw_useradd.sh +++ b/pw/tests/pw_useradd.sh @@ -176,6 +176,31 @@ user_add_name_too_long_body() { ${PW} useradd name_very_vert_very_very_very_long } +atf_test_case user_add_expiration +user_add_expiration_body() { + populate_etc_skel + + atf_check -s exit:0 \ + ${PW} useradd foo -e 20-03-2043 + atf_check -o inline:"foo:*:1001:1001::0:2310422400:User &:/home/foo:/bin/sh\n" \ + -s exit:0 grep "^foo" ${HOME}/master.passwd + atf_check -s exit:0 ${PW} userdel foo + atf_check -s exit:0 \ + ${PW} useradd foo -e 20-03-43 + atf_check -o inline:"foo:*:1001:1001::0:2310422400:User &:/home/foo:/bin/sh\n" \ + -s exit:0 grep "^foo" ${HOME}/master.passwd + atf_check -s exit:0 ${PW} userdel foo + atf_check -s exit:0 \ + ${PW} useradd foo -e 20-Mar-2043 + atf_check -o inline:"foo:*:1001:1001::0:2310422400:User &:/home/foo:/bin/sh\n" \ + -s exit:0 grep "^foo" ${HOME}/master.passwd + atf_check -s exit:0 ${PW} userdel foo + atf_check -e inline:"pw: Invalid date\n" -s exit:1 \ + ${PW} useradd foo -e 20-Foo-2043 + atf_check -e inline:"pw: Invalid date\n" -s exit:1 \ + ${PW} useradd foo -e 20-13-2043 +} + atf_init_test_cases() { atf_add_test_case user_add atf_add_test_case user_add_noupdate @@ -193,4 +218,5 @@ atf_init_test_cases() { atf_add_test_case user_add_password_expiration_date_month atf_add_test_case user_add_password_expiration_date_relative atf_add_test_case user_add_name_too_long + atf_add_test_case user_add_expiration } |