Blame


1 ff260661 2022-11-17 thomas REGRESS_TARGETS=test_repo_read test_repo_read_group test_repo_read_bad_group \
2 ff260661 2022-11-17 thomas test_repo_write test_repo_write_empty
3 f2900386 2022-10-31 thomas NOOBJ=Yes
4 f2900386 2022-10-31 thomas
5 f2900386 2022-10-31 thomas .PHONY: ensure_root prepare_test_repo check_test_repo start_gotd
6 f2900386 2022-10-31 thomas
7 f2900386 2022-10-31 thomas GOTD_TEST_ROOT=/tmp
8 f2900386 2022-10-31 thomas GOTD_DEVUSER?=gotdev
9 a0934206 2022-10-31 thomas GOTD_DEVUSER_HOME!=userinfo $(GOTD_DEVUSER) | awk '/^dir/ {print $$2}'
10 f2900386 2022-10-31 thomas GOTD_TEST_REPO!?=mktemp -d "$(GOTD_TEST_ROOT)/gotd-test-repo-XXXXXXXXX"
11 f2900386 2022-10-31 thomas GOTD_TEST_REPO_URL=ssh://${GOTD_DEVUSER}@127.0.0.1/test-repo
12 f2900386 2022-10-31 thomas
13 f2900386 2022-10-31 thomas GOTD_TEST_USER?=${LOGNAME}
14 a0934206 2022-10-31 thomas GOTD_TEST_USER_HOME!=userinfo $(GOTD_TEST_USER) | awk '/^dir/ {print $$2}'
15 f2900386 2022-10-31 thomas
16 f2900386 2022-10-31 thomas # gotd.conf parameters
17 f2900386 2022-10-31 thomas GOTD_USER?=got
18 f2900386 2022-10-31 thomas GOTD_GROUP?=gotsh
19 f2900386 2022-10-31 thomas GOTD_SOCK=${GOTD_DEVUSER_HOME}/gotd.sock
20 f2900386 2022-10-31 thomas
21 f2900386 2022-10-31 thomas GOTD_START_CMD=../../gotd/obj/gotd -vv -f $(PWD)/gotd.conf
22 f2900386 2022-10-31 thomas GOTD_STOP_CMD=../../gotctl/obj/gotctl -f $(GOTD_SOCK) stop
23 f2900386 2022-10-31 thomas GOTD_TRAP=trap "$(GOTD_STOP_CMD)" HUP INT QUIT PIPE TERM
24 f2900386 2022-10-31 thomas
25 f2900386 2022-10-31 thomas GOTD_TEST_ENV=GOTD_TEST_ROOT=$(GOTD_TEST_ROOT) \
26 f2900386 2022-10-31 thomas GOTD_TEST_REPO_URL=$(GOTD_TEST_REPO_URL) \
27 f2900386 2022-10-31 thomas GOTD_TEST_REPO=$(GOTD_TEST_REPO) \
28 f2900386 2022-10-31 thomas GOTD_SOCK=$(GOTD_SOCK) \
29 a07c01e0 2022-11-08 thomas GOTD_DEVUSER=$(GOTD_DEVUSER) \
30 f2900386 2022-10-31 thomas HOME=$(GOTD_TEST_USER_HOME) \
31 f2900386 2022-10-31 thomas PATH=$(GOTD_TEST_USER_HOME)/bin:$(PATH)
32 f2900386 2022-10-31 thomas
33 f2900386 2022-10-31 thomas ensure_root:
34 f2900386 2022-10-31 thomas @if [[ `id -u` -ne 0 ]]; then \
35 f2900386 2022-10-31 thomas echo gotd test suite must be run by root >&2; \
36 f2900386 2022-10-31 thomas false; \
37 f2900386 2022-10-31 thomas fi
38 f2900386 2022-10-31 thomas
39 729a7e24 2022-11-17 thomas start_gotd_ro: ensure_root
40 f2900386 2022-10-31 thomas @echo 'unix_socket "$(GOTD_SOCK)"' > $(PWD)/gotd.conf
41 f2900386 2022-10-31 thomas @echo "unix_group $(GOTD_GROUP)" >> $(PWD)/gotd.conf
42 f2900386 2022-10-31 thomas @echo "user $(GOTD_USER)" >> $(PWD)/gotd.conf
43 f2900386 2022-10-31 thomas @echo 'repository "test-repo" {' >> $(PWD)/gotd.conf
44 f2900386 2022-10-31 thomas @echo ' path "$(GOTD_TEST_REPO)"' >> $(PWD)/gotd.conf
45 729a7e24 2022-11-17 thomas @echo ' permit ro $(GOTD_DEVUSER)' >> $(PWD)/gotd.conf
46 f2900386 2022-10-31 thomas @echo "}" >> $(PWD)/gotd.conf
47 f2900386 2022-10-31 thomas @$(GOTD_TRAP); $(GOTD_START_CMD)
48 f2900386 2022-10-31 thomas @$(GOTD_TRAP); sleep .5
49 f2900386 2022-10-31 thomas
50 ff260661 2022-11-17 thomas start_gotd_ro_group: ensure_root
51 ff260661 2022-11-17 thomas @echo 'unix_socket "$(GOTD_SOCK)"' > $(PWD)/gotd.conf
52 ff260661 2022-11-17 thomas @echo "unix_group $(GOTD_GROUP)" >> $(PWD)/gotd.conf
53 ff260661 2022-11-17 thomas @echo "user $(GOTD_USER)" >> $(PWD)/gotd.conf
54 ff260661 2022-11-17 thomas @echo 'repository "test-repo" {' >> $(PWD)/gotd.conf
55 ff260661 2022-11-17 thomas @echo ' path "$(GOTD_TEST_REPO)"' >> $(PWD)/gotd.conf
56 ff260661 2022-11-17 thomas @echo ' permit ro :$(GOTD_DEVUSER)' >> $(PWD)/gotd.conf
57 ff260661 2022-11-17 thomas @echo "}" >> $(PWD)/gotd.conf
58 ff260661 2022-11-17 thomas @$(GOTD_TRAP); $(GOTD_START_CMD)
59 ff260661 2022-11-17 thomas @$(GOTD_TRAP); sleep .5
60 ff260661 2022-11-17 thomas
61 ff260661 2022-11-17 thomas # $GOTD_DEVUSER should not be in group wheel
62 ff260661 2022-11-17 thomas start_gotd_ro_bad_group: ensure_root
63 ff260661 2022-11-17 thomas @echo 'unix_socket "$(GOTD_SOCK)"' > $(PWD)/gotd.conf
64 ff260661 2022-11-17 thomas @echo "unix_group $(GOTD_GROUP)" >> $(PWD)/gotd.conf
65 ff260661 2022-11-17 thomas @echo "user $(GOTD_USER)" >> $(PWD)/gotd.conf
66 ff260661 2022-11-17 thomas @echo 'repository "test-repo" {' >> $(PWD)/gotd.conf
67 ff260661 2022-11-17 thomas @echo ' path "$(GOTD_TEST_REPO)"' >> $(PWD)/gotd.conf
68 ff260661 2022-11-17 thomas @echo ' permit ro :wheel' >> $(PWD)/gotd.conf
69 ff260661 2022-11-17 thomas @echo "}" >> $(PWD)/gotd.conf
70 ff260661 2022-11-17 thomas @$(GOTD_TRAP); $(GOTD_START_CMD)
71 ff260661 2022-11-17 thomas @$(GOTD_TRAP); sleep .5
72 ff260661 2022-11-17 thomas
73 ff260661 2022-11-17 thomas
74 729a7e24 2022-11-17 thomas start_gotd_rw: ensure_root
75 729a7e24 2022-11-17 thomas @echo 'unix_socket "$(GOTD_SOCK)"' > $(PWD)/gotd.conf
76 729a7e24 2022-11-17 thomas @echo "unix_group $(GOTD_GROUP)" >> $(PWD)/gotd.conf
77 729a7e24 2022-11-17 thomas @echo "user $(GOTD_USER)" >> $(PWD)/gotd.conf
78 729a7e24 2022-11-17 thomas @echo 'repository "test-repo" {' >> $(PWD)/gotd.conf
79 729a7e24 2022-11-17 thomas @echo ' path "$(GOTD_TEST_REPO)"' >> $(PWD)/gotd.conf
80 729a7e24 2022-11-17 thomas @echo ' permit rw $(GOTD_DEVUSER)' >> $(PWD)/gotd.conf
81 729a7e24 2022-11-17 thomas @echo "}" >> $(PWD)/gotd.conf
82 729a7e24 2022-11-17 thomas @$(GOTD_TRAP); $(GOTD_START_CMD)
83 729a7e24 2022-11-17 thomas @$(GOTD_TRAP); sleep .5
84 729a7e24 2022-11-17 thomas
85 f2900386 2022-10-31 thomas prepare_test_repo: ensure_root
86 f2900386 2022-10-31 thomas @chown ${GOTD_USER} "${GOTD_TEST_REPO}"
87 f2900386 2022-10-31 thomas @su -m ${GOTD_USER} -c 'env $(GOTD_TEST_ENV) sh ./prepare_test_repo.sh'
88 f2900386 2022-10-31 thomas
89 a07c01e0 2022-11-08 thomas prepare_test_repo_empty: ensure_root
90 a07c01e0 2022-11-08 thomas @chown ${GOTD_USER} "${GOTD_TEST_REPO}"
91 a07c01e0 2022-11-08 thomas @su -m ${GOTD_USER} -c 'env $(GOTD_TEST_ENV) sh ./prepare_test_repo.sh 1'
92 a07c01e0 2022-11-08 thomas
93 729a7e24 2022-11-17 thomas test_repo_read: prepare_test_repo start_gotd_ro
94 f2900386 2022-10-31 thomas @-$(GOTD_TRAP); su ${GOTD_TEST_USER} -c \
95 f2900386 2022-10-31 thomas 'env $(GOTD_TEST_ENV) sh ./repo_read.sh'
96 f2900386 2022-10-31 thomas @$(GOTD_STOP_CMD) 2>/dev/null
97 f2900386 2022-10-31 thomas @su -m ${GOTD_USER} -c 'env $(GOTD_TEST_ENV) sh ./check_test_repo.sh'
98 f2900386 2022-10-31 thomas
99 ff260661 2022-11-17 thomas test_repo_read_group: prepare_test_repo start_gotd_ro_group
100 ff260661 2022-11-17 thomas @-$(GOTD_TRAP); su ${GOTD_TEST_USER} -c \
101 ff260661 2022-11-17 thomas 'env $(GOTD_TEST_ENV) sh ./repo_read.sh'
102 ff260661 2022-11-17 thomas @$(GOTD_STOP_CMD) 2>/dev/null
103 ff260661 2022-11-17 thomas @su -m ${GOTD_USER} -c 'env $(GOTD_TEST_ENV) sh ./check_test_repo.sh'
104 ff260661 2022-11-17 thomas
105 ff260661 2022-11-17 thomas test_repo_read_bad_group: prepare_test_repo start_gotd_ro_bad_group
106 ff260661 2022-11-17 thomas @-$(GOTD_TRAP); su ${GOTD_TEST_USER} -c \
107 ff260661 2022-11-17 thomas 'env $(GOTD_TEST_ENV) sh ./repo_read_access_denied.sh'
108 ff260661 2022-11-17 thomas @$(GOTD_STOP_CMD) 2>/dev/null
109 ff260661 2022-11-17 thomas @su -m ${GOTD_USER} -c 'env $(GOTD_TEST_ENV) sh ./check_test_repo.sh'
110 ff260661 2022-11-17 thomas
111 729a7e24 2022-11-17 thomas test_repo_write: prepare_test_repo start_gotd_rw
112 f2900386 2022-10-31 thomas @-$(GOTD_TRAP); su ${GOTD_TEST_USER} -c \
113 f2900386 2022-10-31 thomas 'env $(GOTD_TEST_ENV) sh ./repo_write.sh'
114 f2900386 2022-10-31 thomas @$(GOTD_STOP_CMD) 2>/dev/null
115 f2900386 2022-10-31 thomas @su -m ${GOTD_USER} -c 'env $(GOTD_TEST_ENV) sh ./check_test_repo.sh'
116 a07c01e0 2022-11-08 thomas
117 729a7e24 2022-11-17 thomas test_repo_write_empty: prepare_test_repo_empty start_gotd_rw
118 a07c01e0 2022-11-08 thomas @-$(GOTD_TRAP); su ${GOTD_TEST_USER} -c \
119 a07c01e0 2022-11-08 thomas 'env $(GOTD_TEST_ENV) sh ./repo_write_empty.sh'
120 a07c01e0 2022-11-08 thomas @$(GOTD_STOP_CMD) 2>/dev/null
121 a07c01e0 2022-11-08 thomas @su -m ${GOTD_USER} -c 'env $(GOTD_TEST_ENV) sh ./check_test_repo.sh'
122 f2900386 2022-10-31 thomas
123 f2900386 2022-10-31 thomas .include <bsd.regress.mk>