Blame


1 ead70407 2022-11-17 thomas REGRESS_TARGETS=test_repo_read test_repo_read_group \
2 5667a3a5 2022-11-17 thomas test_repo_read_denied_user test_repo_read_denied_group \
3 ead70407 2022-11-17 thomas test_repo_read_bad_user test_repo_read_bad_group \
4 ff260661 2022-11-17 thomas test_repo_write test_repo_write_empty
5 f2900386 2022-10-31 thomas NOOBJ=Yes
6 f2900386 2022-10-31 thomas
7 f2900386 2022-10-31 thomas .PHONY: ensure_root prepare_test_repo check_test_repo start_gotd
8 f2900386 2022-10-31 thomas
9 f2900386 2022-10-31 thomas GOTD_TEST_ROOT=/tmp
10 f2900386 2022-10-31 thomas GOTD_DEVUSER?=gotdev
11 a0934206 2022-10-31 thomas GOTD_DEVUSER_HOME!=userinfo $(GOTD_DEVUSER) | awk '/^dir/ {print $$2}'
12 f2900386 2022-10-31 thomas GOTD_TEST_REPO!?=mktemp -d "$(GOTD_TEST_ROOT)/gotd-test-repo-XXXXXXXXX"
13 f2900386 2022-10-31 thomas GOTD_TEST_REPO_URL=ssh://${GOTD_DEVUSER}@127.0.0.1/test-repo
14 f2900386 2022-10-31 thomas
15 69e99a59 2022-12-08 thomas GOTD_TEST_USER?=${USERNAME}
16 a0934206 2022-10-31 thomas GOTD_TEST_USER_HOME!=userinfo $(GOTD_TEST_USER) | awk '/^dir/ {print $$2}'
17 f2900386 2022-10-31 thomas
18 f2900386 2022-10-31 thomas # gotd.conf parameters
19 f2900386 2022-10-31 thomas GOTD_USER?=got
20 f2900386 2022-10-31 thomas GOTD_GROUP?=gotsh
21 f2900386 2022-10-31 thomas GOTD_SOCK=${GOTD_DEVUSER_HOME}/gotd.sock
22 f2900386 2022-10-31 thomas
23 f2900386 2022-10-31 thomas GOTD_START_CMD=../../gotd/obj/gotd -vv -f $(PWD)/gotd.conf
24 f2900386 2022-10-31 thomas GOTD_STOP_CMD=../../gotctl/obj/gotctl -f $(GOTD_SOCK) stop
25 f2900386 2022-10-31 thomas GOTD_TRAP=trap "$(GOTD_STOP_CMD)" HUP INT QUIT PIPE TERM
26 f2900386 2022-10-31 thomas
27 f2900386 2022-10-31 thomas GOTD_TEST_ENV=GOTD_TEST_ROOT=$(GOTD_TEST_ROOT) \
28 f2900386 2022-10-31 thomas GOTD_TEST_REPO_URL=$(GOTD_TEST_REPO_URL) \
29 f2900386 2022-10-31 thomas GOTD_TEST_REPO=$(GOTD_TEST_REPO) \
30 f2900386 2022-10-31 thomas GOTD_SOCK=$(GOTD_SOCK) \
31 a07c01e0 2022-11-08 thomas GOTD_DEVUSER=$(GOTD_DEVUSER) \
32 f2900386 2022-10-31 thomas HOME=$(GOTD_TEST_USER_HOME) \
33 f2900386 2022-10-31 thomas PATH=$(GOTD_TEST_USER_HOME)/bin:$(PATH)
34 f2900386 2022-10-31 thomas
35 f2900386 2022-10-31 thomas ensure_root:
36 f2900386 2022-10-31 thomas @if [[ `id -u` -ne 0 ]]; then \
37 69e99a59 2022-12-08 thomas echo gotd test suite must be started by root >&2; \
38 f2900386 2022-10-31 thomas false; \
39 69e99a59 2022-12-08 thomas fi ; \
40 69e99a59 2022-12-08 thomas if [[ "$(GOTD_TEST_USER)" = "root" ]]; then \
41 69e99a59 2022-12-08 thomas echo GOTD_TEST_USER must be a non-root user >&2; \
42 69e99a59 2022-12-08 thomas false; \
43 f2900386 2022-10-31 thomas fi
44 f2900386 2022-10-31 thomas
45 729a7e24 2022-11-17 thomas start_gotd_ro: ensure_root
46 f2900386 2022-10-31 thomas @echo 'unix_socket "$(GOTD_SOCK)"' > $(PWD)/gotd.conf
47 f2900386 2022-10-31 thomas @echo "unix_group $(GOTD_GROUP)" >> $(PWD)/gotd.conf
48 f2900386 2022-10-31 thomas @echo "user $(GOTD_USER)" >> $(PWD)/gotd.conf
49 f2900386 2022-10-31 thomas @echo 'repository "test-repo" {' >> $(PWD)/gotd.conf
50 f2900386 2022-10-31 thomas @echo ' path "$(GOTD_TEST_REPO)"' >> $(PWD)/gotd.conf
51 729a7e24 2022-11-17 thomas @echo ' permit ro $(GOTD_DEVUSER)' >> $(PWD)/gotd.conf
52 f2900386 2022-10-31 thomas @echo "}" >> $(PWD)/gotd.conf
53 f2900386 2022-10-31 thomas @$(GOTD_TRAP); $(GOTD_START_CMD)
54 f2900386 2022-10-31 thomas @$(GOTD_TRAP); sleep .5
55 f2900386 2022-10-31 thomas
56 ff260661 2022-11-17 thomas start_gotd_ro_group: ensure_root
57 ff260661 2022-11-17 thomas @echo 'unix_socket "$(GOTD_SOCK)"' > $(PWD)/gotd.conf
58 ff260661 2022-11-17 thomas @echo "unix_group $(GOTD_GROUP)" >> $(PWD)/gotd.conf
59 ff260661 2022-11-17 thomas @echo "user $(GOTD_USER)" >> $(PWD)/gotd.conf
60 ff260661 2022-11-17 thomas @echo 'repository "test-repo" {' >> $(PWD)/gotd.conf
61 ff260661 2022-11-17 thomas @echo ' path "$(GOTD_TEST_REPO)"' >> $(PWD)/gotd.conf
62 ff260661 2022-11-17 thomas @echo ' permit ro :$(GOTD_DEVUSER)' >> $(PWD)/gotd.conf
63 ff260661 2022-11-17 thomas @echo "}" >> $(PWD)/gotd.conf
64 ff260661 2022-11-17 thomas @$(GOTD_TRAP); $(GOTD_START_CMD)
65 ff260661 2022-11-17 thomas @$(GOTD_TRAP); sleep .5
66 ff260661 2022-11-17 thomas
67 b40156b3 2022-11-17 thomas # try a permit rule followed by a deny rule; last matched rule wins
68 b40156b3 2022-11-17 thomas start_gotd_ro_denied_user: ensure_root
69 b40156b3 2022-11-17 thomas @echo 'unix_socket "$(GOTD_SOCK)"' > $(PWD)/gotd.conf
70 b40156b3 2022-11-17 thomas @echo "unix_group $(GOTD_GROUP)" >> $(PWD)/gotd.conf
71 b40156b3 2022-11-17 thomas @echo "user $(GOTD_USER)" >> $(PWD)/gotd.conf
72 b40156b3 2022-11-17 thomas @echo 'repository "test-repo" {' >> $(PWD)/gotd.conf
73 b40156b3 2022-11-17 thomas @echo ' path "$(GOTD_TEST_REPO)"' >> $(PWD)/gotd.conf
74 b40156b3 2022-11-17 thomas @echo ' permit ro $(GOTD_DEVUSER)' >> $(PWD)/gotd.conf
75 b40156b3 2022-11-17 thomas @echo ' deny $(GOTD_DEVUSER)' >> $(PWD)/gotd.conf
76 b40156b3 2022-11-17 thomas @echo "}" >> $(PWD)/gotd.conf
77 b40156b3 2022-11-17 thomas @$(GOTD_TRAP); $(GOTD_START_CMD)
78 b40156b3 2022-11-17 thomas @$(GOTD_TRAP); sleep .5
79 b40156b3 2022-11-17 thomas
80 5667a3a5 2022-11-17 thomas # try a permit rule followed by a deny rule; last matched rule wins
81 5667a3a5 2022-11-17 thomas start_gotd_ro_denied_group: ensure_root
82 5667a3a5 2022-11-17 thomas @echo 'unix_socket "$(GOTD_SOCK)"' > $(PWD)/gotd.conf
83 5667a3a5 2022-11-17 thomas @echo "unix_group $(GOTD_GROUP)" >> $(PWD)/gotd.conf
84 5667a3a5 2022-11-17 thomas @echo "user $(GOTD_USER)" >> $(PWD)/gotd.conf
85 5667a3a5 2022-11-17 thomas @echo 'repository "test-repo" {' >> $(PWD)/gotd.conf
86 5667a3a5 2022-11-17 thomas @echo ' path "$(GOTD_TEST_REPO)"' >> $(PWD)/gotd.conf
87 5667a3a5 2022-11-17 thomas @echo ' permit ro $(GOTD_DEVUSER)' >> $(PWD)/gotd.conf
88 5667a3a5 2022-11-17 thomas @echo ' deny :$(GOTD_DEVUSER)' >> $(PWD)/gotd.conf
89 5667a3a5 2022-11-17 thomas @echo "}" >> $(PWD)/gotd.conf
90 5667a3a5 2022-11-17 thomas @$(GOTD_TRAP); $(GOTD_START_CMD)
91 5667a3a5 2022-11-17 thomas @$(GOTD_TRAP); sleep .5
92 5667a3a5 2022-11-17 thomas
93 ead70407 2022-11-17 thomas # $GOTD_DEVUSER should not equal $GOTD_USER
94 ead70407 2022-11-17 thomas start_gotd_ro_bad_user: ensure_root
95 ead70407 2022-11-17 thomas @echo 'unix_socket "$(GOTD_SOCK)"' > $(PWD)/gotd.conf
96 ead70407 2022-11-17 thomas @echo "unix_group $(GOTD_GROUP)" >> $(PWD)/gotd.conf
97 ead70407 2022-11-17 thomas @echo "user $(GOTD_USER)" >> $(PWD)/gotd.conf
98 ead70407 2022-11-17 thomas @echo 'repository "test-repo" {' >> $(PWD)/gotd.conf
99 ead70407 2022-11-17 thomas @echo ' path "$(GOTD_TEST_REPO)"' >> $(PWD)/gotd.conf
100 ead70407 2022-11-17 thomas @echo ' permit ro $(GOTD_USER)' >> $(PWD)/gotd.conf
101 ead70407 2022-11-17 thomas @echo "}" >> $(PWD)/gotd.conf
102 ead70407 2022-11-17 thomas @$(GOTD_TRAP); $(GOTD_START_CMD)
103 ead70407 2022-11-17 thomas @$(GOTD_TRAP); sleep .5
104 ead70407 2022-11-17 thomas
105 ff260661 2022-11-17 thomas # $GOTD_DEVUSER should not be in group wheel
106 ff260661 2022-11-17 thomas start_gotd_ro_bad_group: ensure_root
107 ff260661 2022-11-17 thomas @echo 'unix_socket "$(GOTD_SOCK)"' > $(PWD)/gotd.conf
108 ff260661 2022-11-17 thomas @echo "unix_group $(GOTD_GROUP)" >> $(PWD)/gotd.conf
109 ff260661 2022-11-17 thomas @echo "user $(GOTD_USER)" >> $(PWD)/gotd.conf
110 ff260661 2022-11-17 thomas @echo 'repository "test-repo" {' >> $(PWD)/gotd.conf
111 ff260661 2022-11-17 thomas @echo ' path "$(GOTD_TEST_REPO)"' >> $(PWD)/gotd.conf
112 ff260661 2022-11-17 thomas @echo ' permit ro :wheel' >> $(PWD)/gotd.conf
113 ff260661 2022-11-17 thomas @echo "}" >> $(PWD)/gotd.conf
114 ff260661 2022-11-17 thomas @$(GOTD_TRAP); $(GOTD_START_CMD)
115 ff260661 2022-11-17 thomas @$(GOTD_TRAP); sleep .5
116 ff260661 2022-11-17 thomas
117 729a7e24 2022-11-17 thomas start_gotd_rw: ensure_root
118 729a7e24 2022-11-17 thomas @echo 'unix_socket "$(GOTD_SOCK)"' > $(PWD)/gotd.conf
119 729a7e24 2022-11-17 thomas @echo "unix_group $(GOTD_GROUP)" >> $(PWD)/gotd.conf
120 729a7e24 2022-11-17 thomas @echo "user $(GOTD_USER)" >> $(PWD)/gotd.conf
121 729a7e24 2022-11-17 thomas @echo 'repository "test-repo" {' >> $(PWD)/gotd.conf
122 729a7e24 2022-11-17 thomas @echo ' path "$(GOTD_TEST_REPO)"' >> $(PWD)/gotd.conf
123 729a7e24 2022-11-17 thomas @echo ' permit rw $(GOTD_DEVUSER)' >> $(PWD)/gotd.conf
124 729a7e24 2022-11-17 thomas @echo "}" >> $(PWD)/gotd.conf
125 729a7e24 2022-11-17 thomas @$(GOTD_TRAP); $(GOTD_START_CMD)
126 729a7e24 2022-11-17 thomas @$(GOTD_TRAP); sleep .5
127 729a7e24 2022-11-17 thomas
128 f2900386 2022-10-31 thomas prepare_test_repo: ensure_root
129 f2900386 2022-10-31 thomas @chown ${GOTD_USER} "${GOTD_TEST_REPO}"
130 f2900386 2022-10-31 thomas @su -m ${GOTD_USER} -c 'env $(GOTD_TEST_ENV) sh ./prepare_test_repo.sh'
131 f2900386 2022-10-31 thomas
132 a07c01e0 2022-11-08 thomas prepare_test_repo_empty: ensure_root
133 a07c01e0 2022-11-08 thomas @chown ${GOTD_USER} "${GOTD_TEST_REPO}"
134 a07c01e0 2022-11-08 thomas @su -m ${GOTD_USER} -c 'env $(GOTD_TEST_ENV) sh ./prepare_test_repo.sh 1'
135 a07c01e0 2022-11-08 thomas
136 729a7e24 2022-11-17 thomas test_repo_read: prepare_test_repo start_gotd_ro
137 f2900386 2022-10-31 thomas @-$(GOTD_TRAP); su ${GOTD_TEST_USER} -c \
138 f2900386 2022-10-31 thomas 'env $(GOTD_TEST_ENV) sh ./repo_read.sh'
139 f2900386 2022-10-31 thomas @$(GOTD_STOP_CMD) 2>/dev/null
140 f2900386 2022-10-31 thomas @su -m ${GOTD_USER} -c 'env $(GOTD_TEST_ENV) sh ./check_test_repo.sh'
141 f2900386 2022-10-31 thomas
142 ff260661 2022-11-17 thomas test_repo_read_group: prepare_test_repo start_gotd_ro_group
143 ff260661 2022-11-17 thomas @-$(GOTD_TRAP); su ${GOTD_TEST_USER} -c \
144 ff260661 2022-11-17 thomas 'env $(GOTD_TEST_ENV) sh ./repo_read.sh'
145 ff260661 2022-11-17 thomas @$(GOTD_STOP_CMD) 2>/dev/null
146 ff260661 2022-11-17 thomas @su -m ${GOTD_USER} -c 'env $(GOTD_TEST_ENV) sh ./check_test_repo.sh'
147 ff260661 2022-11-17 thomas
148 b40156b3 2022-11-17 thomas test_repo_read_denied_user: prepare_test_repo start_gotd_ro_denied_user
149 b40156b3 2022-11-17 thomas @-$(GOTD_TRAP); su ${GOTD_TEST_USER} -c \
150 b40156b3 2022-11-17 thomas 'env $(GOTD_TEST_ENV) sh ./repo_read_access_denied.sh'
151 b40156b3 2022-11-17 thomas @$(GOTD_STOP_CMD) 2>/dev/null
152 b40156b3 2022-11-17 thomas @su -m ${GOTD_USER} -c 'env $(GOTD_TEST_ENV) sh ./check_test_repo.sh'
153 b40156b3 2022-11-17 thomas
154 5667a3a5 2022-11-17 thomas test_repo_read_denied_group: prepare_test_repo start_gotd_ro_denied_group
155 5667a3a5 2022-11-17 thomas @-$(GOTD_TRAP); su ${GOTD_TEST_USER} -c \
156 5667a3a5 2022-11-17 thomas 'env $(GOTD_TEST_ENV) sh ./repo_read_access_denied.sh'
157 5667a3a5 2022-11-17 thomas @$(GOTD_STOP_CMD) 2>/dev/null
158 5667a3a5 2022-11-17 thomas @su -m ${GOTD_USER} -c 'env $(GOTD_TEST_ENV) sh ./check_test_repo.sh'
159 5667a3a5 2022-11-17 thomas
160 ead70407 2022-11-17 thomas test_repo_read_bad_user: prepare_test_repo start_gotd_ro_bad_user
161 ead70407 2022-11-17 thomas @-$(GOTD_TRAP); su ${GOTD_TEST_USER} -c \
162 ead70407 2022-11-17 thomas 'env $(GOTD_TEST_ENV) sh ./repo_read_access_denied.sh'
163 ead70407 2022-11-17 thomas @$(GOTD_STOP_CMD) 2>/dev/null
164 ead70407 2022-11-17 thomas @su -m ${GOTD_USER} -c 'env $(GOTD_TEST_ENV) sh ./check_test_repo.sh'
165 ead70407 2022-11-17 thomas
166 ff260661 2022-11-17 thomas test_repo_read_bad_group: prepare_test_repo start_gotd_ro_bad_group
167 ff260661 2022-11-17 thomas @-$(GOTD_TRAP); su ${GOTD_TEST_USER} -c \
168 ff260661 2022-11-17 thomas 'env $(GOTD_TEST_ENV) sh ./repo_read_access_denied.sh'
169 ff260661 2022-11-17 thomas @$(GOTD_STOP_CMD) 2>/dev/null
170 ff260661 2022-11-17 thomas @su -m ${GOTD_USER} -c 'env $(GOTD_TEST_ENV) sh ./check_test_repo.sh'
171 ff260661 2022-11-17 thomas
172 729a7e24 2022-11-17 thomas test_repo_write: prepare_test_repo start_gotd_rw
173 f2900386 2022-10-31 thomas @-$(GOTD_TRAP); su ${GOTD_TEST_USER} -c \
174 f2900386 2022-10-31 thomas 'env $(GOTD_TEST_ENV) sh ./repo_write.sh'
175 f2900386 2022-10-31 thomas @$(GOTD_STOP_CMD) 2>/dev/null
176 f2900386 2022-10-31 thomas @su -m ${GOTD_USER} -c 'env $(GOTD_TEST_ENV) sh ./check_test_repo.sh'
177 a07c01e0 2022-11-08 thomas
178 729a7e24 2022-11-17 thomas test_repo_write_empty: prepare_test_repo_empty start_gotd_rw
179 a07c01e0 2022-11-08 thomas @-$(GOTD_TRAP); su ${GOTD_TEST_USER} -c \
180 a07c01e0 2022-11-08 thomas 'env $(GOTD_TEST_ENV) sh ./repo_write_empty.sh'
181 a07c01e0 2022-11-08 thomas @$(GOTD_STOP_CMD) 2>/dev/null
182 a07c01e0 2022-11-08 thomas @su -m ${GOTD_USER} -c 'env $(GOTD_TEST_ENV) sh ./check_test_repo.sh'
183 f2900386 2022-10-31 thomas
184 f2900386 2022-10-31 thomas .include <bsd.regress.mk>