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 f2900386 2022-10-31 thomas GOTD_TEST_USER?=${LOGNAME}
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 f2900386 2022-10-31 thomas echo gotd test suite must be run by root >&2; \
38 f2900386 2022-10-31 thomas false; \
39 f2900386 2022-10-31 thomas fi
40 f2900386 2022-10-31 thomas
41 729a7e24 2022-11-17 thomas start_gotd_ro: ensure_root
42 f2900386 2022-10-31 thomas @echo 'unix_socket "$(GOTD_SOCK)"' > $(PWD)/gotd.conf
43 f2900386 2022-10-31 thomas @echo "unix_group $(GOTD_GROUP)" >> $(PWD)/gotd.conf
44 f2900386 2022-10-31 thomas @echo "user $(GOTD_USER)" >> $(PWD)/gotd.conf
45 f2900386 2022-10-31 thomas @echo 'repository "test-repo" {' >> $(PWD)/gotd.conf
46 f2900386 2022-10-31 thomas @echo ' path "$(GOTD_TEST_REPO)"' >> $(PWD)/gotd.conf
47 729a7e24 2022-11-17 thomas @echo ' permit ro $(GOTD_DEVUSER)' >> $(PWD)/gotd.conf
48 f2900386 2022-10-31 thomas @echo "}" >> $(PWD)/gotd.conf
49 f2900386 2022-10-31 thomas @$(GOTD_TRAP); $(GOTD_START_CMD)
50 f2900386 2022-10-31 thomas @$(GOTD_TRAP); sleep .5
51 f2900386 2022-10-31 thomas
52 ff260661 2022-11-17 thomas start_gotd_ro_group: ensure_root
53 ff260661 2022-11-17 thomas @echo 'unix_socket "$(GOTD_SOCK)"' > $(PWD)/gotd.conf
54 ff260661 2022-11-17 thomas @echo "unix_group $(GOTD_GROUP)" >> $(PWD)/gotd.conf
55 ff260661 2022-11-17 thomas @echo "user $(GOTD_USER)" >> $(PWD)/gotd.conf
56 ff260661 2022-11-17 thomas @echo 'repository "test-repo" {' >> $(PWD)/gotd.conf
57 ff260661 2022-11-17 thomas @echo ' path "$(GOTD_TEST_REPO)"' >> $(PWD)/gotd.conf
58 ff260661 2022-11-17 thomas @echo ' permit ro :$(GOTD_DEVUSER)' >> $(PWD)/gotd.conf
59 ff260661 2022-11-17 thomas @echo "}" >> $(PWD)/gotd.conf
60 ff260661 2022-11-17 thomas @$(GOTD_TRAP); $(GOTD_START_CMD)
61 ff260661 2022-11-17 thomas @$(GOTD_TRAP); sleep .5
62 ff260661 2022-11-17 thomas
63 b40156b3 2022-11-17 thomas # try a permit rule followed by a deny rule; last matched rule wins
64 b40156b3 2022-11-17 thomas start_gotd_ro_denied_user: ensure_root
65 b40156b3 2022-11-17 thomas @echo 'unix_socket "$(GOTD_SOCK)"' > $(PWD)/gotd.conf
66 b40156b3 2022-11-17 thomas @echo "unix_group $(GOTD_GROUP)" >> $(PWD)/gotd.conf
67 b40156b3 2022-11-17 thomas @echo "user $(GOTD_USER)" >> $(PWD)/gotd.conf
68 b40156b3 2022-11-17 thomas @echo 'repository "test-repo" {' >> $(PWD)/gotd.conf
69 b40156b3 2022-11-17 thomas @echo ' path "$(GOTD_TEST_REPO)"' >> $(PWD)/gotd.conf
70 b40156b3 2022-11-17 thomas @echo ' permit ro $(GOTD_DEVUSER)' >> $(PWD)/gotd.conf
71 b40156b3 2022-11-17 thomas @echo ' deny $(GOTD_DEVUSER)' >> $(PWD)/gotd.conf
72 b40156b3 2022-11-17 thomas @echo "}" >> $(PWD)/gotd.conf
73 b40156b3 2022-11-17 thomas @$(GOTD_TRAP); $(GOTD_START_CMD)
74 b40156b3 2022-11-17 thomas @$(GOTD_TRAP); sleep .5
75 b40156b3 2022-11-17 thomas
76 5667a3a5 2022-11-17 thomas # try a permit rule followed by a deny rule; last matched rule wins
77 5667a3a5 2022-11-17 thomas start_gotd_ro_denied_group: ensure_root
78 5667a3a5 2022-11-17 thomas @echo 'unix_socket "$(GOTD_SOCK)"' > $(PWD)/gotd.conf
79 5667a3a5 2022-11-17 thomas @echo "unix_group $(GOTD_GROUP)" >> $(PWD)/gotd.conf
80 5667a3a5 2022-11-17 thomas @echo "user $(GOTD_USER)" >> $(PWD)/gotd.conf
81 5667a3a5 2022-11-17 thomas @echo 'repository "test-repo" {' >> $(PWD)/gotd.conf
82 5667a3a5 2022-11-17 thomas @echo ' path "$(GOTD_TEST_REPO)"' >> $(PWD)/gotd.conf
83 5667a3a5 2022-11-17 thomas @echo ' permit ro $(GOTD_DEVUSER)' >> $(PWD)/gotd.conf
84 5667a3a5 2022-11-17 thomas @echo ' deny :$(GOTD_DEVUSER)' >> $(PWD)/gotd.conf
85 5667a3a5 2022-11-17 thomas @echo "}" >> $(PWD)/gotd.conf
86 5667a3a5 2022-11-17 thomas @$(GOTD_TRAP); $(GOTD_START_CMD)
87 5667a3a5 2022-11-17 thomas @$(GOTD_TRAP); sleep .5
88 5667a3a5 2022-11-17 thomas
89 ead70407 2022-11-17 thomas # $GOTD_DEVUSER should not equal $GOTD_USER
90 ead70407 2022-11-17 thomas start_gotd_ro_bad_user: ensure_root
91 ead70407 2022-11-17 thomas @echo 'unix_socket "$(GOTD_SOCK)"' > $(PWD)/gotd.conf
92 ead70407 2022-11-17 thomas @echo "unix_group $(GOTD_GROUP)" >> $(PWD)/gotd.conf
93 ead70407 2022-11-17 thomas @echo "user $(GOTD_USER)" >> $(PWD)/gotd.conf
94 ead70407 2022-11-17 thomas @echo 'repository "test-repo" {' >> $(PWD)/gotd.conf
95 ead70407 2022-11-17 thomas @echo ' path "$(GOTD_TEST_REPO)"' >> $(PWD)/gotd.conf
96 ead70407 2022-11-17 thomas @echo ' permit ro $(GOTD_USER)' >> $(PWD)/gotd.conf
97 ead70407 2022-11-17 thomas @echo "}" >> $(PWD)/gotd.conf
98 ead70407 2022-11-17 thomas @$(GOTD_TRAP); $(GOTD_START_CMD)
99 ead70407 2022-11-17 thomas @$(GOTD_TRAP); sleep .5
100 ead70407 2022-11-17 thomas
101 ff260661 2022-11-17 thomas # $GOTD_DEVUSER should not be in group wheel
102 ff260661 2022-11-17 thomas start_gotd_ro_bad_group: ensure_root
103 ff260661 2022-11-17 thomas @echo 'unix_socket "$(GOTD_SOCK)"' > $(PWD)/gotd.conf
104 ff260661 2022-11-17 thomas @echo "unix_group $(GOTD_GROUP)" >> $(PWD)/gotd.conf
105 ff260661 2022-11-17 thomas @echo "user $(GOTD_USER)" >> $(PWD)/gotd.conf
106 ff260661 2022-11-17 thomas @echo 'repository "test-repo" {' >> $(PWD)/gotd.conf
107 ff260661 2022-11-17 thomas @echo ' path "$(GOTD_TEST_REPO)"' >> $(PWD)/gotd.conf
108 ff260661 2022-11-17 thomas @echo ' permit ro :wheel' >> $(PWD)/gotd.conf
109 ff260661 2022-11-17 thomas @echo "}" >> $(PWD)/gotd.conf
110 ff260661 2022-11-17 thomas @$(GOTD_TRAP); $(GOTD_START_CMD)
111 ff260661 2022-11-17 thomas @$(GOTD_TRAP); sleep .5
112 ff260661 2022-11-17 thomas
113 729a7e24 2022-11-17 thomas start_gotd_rw: ensure_root
114 729a7e24 2022-11-17 thomas @echo 'unix_socket "$(GOTD_SOCK)"' > $(PWD)/gotd.conf
115 729a7e24 2022-11-17 thomas @echo "unix_group $(GOTD_GROUP)" >> $(PWD)/gotd.conf
116 729a7e24 2022-11-17 thomas @echo "user $(GOTD_USER)" >> $(PWD)/gotd.conf
117 729a7e24 2022-11-17 thomas @echo 'repository "test-repo" {' >> $(PWD)/gotd.conf
118 729a7e24 2022-11-17 thomas @echo ' path "$(GOTD_TEST_REPO)"' >> $(PWD)/gotd.conf
119 729a7e24 2022-11-17 thomas @echo ' permit rw $(GOTD_DEVUSER)' >> $(PWD)/gotd.conf
120 729a7e24 2022-11-17 thomas @echo "}" >> $(PWD)/gotd.conf
121 729a7e24 2022-11-17 thomas @$(GOTD_TRAP); $(GOTD_START_CMD)
122 729a7e24 2022-11-17 thomas @$(GOTD_TRAP); sleep .5
123 729a7e24 2022-11-17 thomas
124 f2900386 2022-10-31 thomas prepare_test_repo: ensure_root
125 f2900386 2022-10-31 thomas @chown ${GOTD_USER} "${GOTD_TEST_REPO}"
126 f2900386 2022-10-31 thomas @su -m ${GOTD_USER} -c 'env $(GOTD_TEST_ENV) sh ./prepare_test_repo.sh'
127 f2900386 2022-10-31 thomas
128 a07c01e0 2022-11-08 thomas prepare_test_repo_empty: ensure_root
129 a07c01e0 2022-11-08 thomas @chown ${GOTD_USER} "${GOTD_TEST_REPO}"
130 a07c01e0 2022-11-08 thomas @su -m ${GOTD_USER} -c 'env $(GOTD_TEST_ENV) sh ./prepare_test_repo.sh 1'
131 a07c01e0 2022-11-08 thomas
132 729a7e24 2022-11-17 thomas test_repo_read: prepare_test_repo start_gotd_ro
133 f2900386 2022-10-31 thomas @-$(GOTD_TRAP); su ${GOTD_TEST_USER} -c \
134 f2900386 2022-10-31 thomas 'env $(GOTD_TEST_ENV) sh ./repo_read.sh'
135 f2900386 2022-10-31 thomas @$(GOTD_STOP_CMD) 2>/dev/null
136 f2900386 2022-10-31 thomas @su -m ${GOTD_USER} -c 'env $(GOTD_TEST_ENV) sh ./check_test_repo.sh'
137 f2900386 2022-10-31 thomas
138 ff260661 2022-11-17 thomas test_repo_read_group: prepare_test_repo start_gotd_ro_group
139 ff260661 2022-11-17 thomas @-$(GOTD_TRAP); su ${GOTD_TEST_USER} -c \
140 ff260661 2022-11-17 thomas 'env $(GOTD_TEST_ENV) sh ./repo_read.sh'
141 ff260661 2022-11-17 thomas @$(GOTD_STOP_CMD) 2>/dev/null
142 ff260661 2022-11-17 thomas @su -m ${GOTD_USER} -c 'env $(GOTD_TEST_ENV) sh ./check_test_repo.sh'
143 ff260661 2022-11-17 thomas
144 b40156b3 2022-11-17 thomas test_repo_read_denied_user: prepare_test_repo start_gotd_ro_denied_user
145 b40156b3 2022-11-17 thomas @-$(GOTD_TRAP); su ${GOTD_TEST_USER} -c \
146 b40156b3 2022-11-17 thomas 'env $(GOTD_TEST_ENV) sh ./repo_read_access_denied.sh'
147 b40156b3 2022-11-17 thomas @$(GOTD_STOP_CMD) 2>/dev/null
148 b40156b3 2022-11-17 thomas @su -m ${GOTD_USER} -c 'env $(GOTD_TEST_ENV) sh ./check_test_repo.sh'
149 b40156b3 2022-11-17 thomas
150 5667a3a5 2022-11-17 thomas test_repo_read_denied_group: prepare_test_repo start_gotd_ro_denied_group
151 5667a3a5 2022-11-17 thomas @-$(GOTD_TRAP); su ${GOTD_TEST_USER} -c \
152 5667a3a5 2022-11-17 thomas 'env $(GOTD_TEST_ENV) sh ./repo_read_access_denied.sh'
153 5667a3a5 2022-11-17 thomas @$(GOTD_STOP_CMD) 2>/dev/null
154 5667a3a5 2022-11-17 thomas @su -m ${GOTD_USER} -c 'env $(GOTD_TEST_ENV) sh ./check_test_repo.sh'
155 5667a3a5 2022-11-17 thomas
156 ead70407 2022-11-17 thomas test_repo_read_bad_user: prepare_test_repo start_gotd_ro_bad_user
157 ead70407 2022-11-17 thomas @-$(GOTD_TRAP); su ${GOTD_TEST_USER} -c \
158 ead70407 2022-11-17 thomas 'env $(GOTD_TEST_ENV) sh ./repo_read_access_denied.sh'
159 ead70407 2022-11-17 thomas @$(GOTD_STOP_CMD) 2>/dev/null
160 ead70407 2022-11-17 thomas @su -m ${GOTD_USER} -c 'env $(GOTD_TEST_ENV) sh ./check_test_repo.sh'
161 ead70407 2022-11-17 thomas
162 ff260661 2022-11-17 thomas test_repo_read_bad_group: prepare_test_repo start_gotd_ro_bad_group
163 ff260661 2022-11-17 thomas @-$(GOTD_TRAP); su ${GOTD_TEST_USER} -c \
164 ff260661 2022-11-17 thomas 'env $(GOTD_TEST_ENV) sh ./repo_read_access_denied.sh'
165 ff260661 2022-11-17 thomas @$(GOTD_STOP_CMD) 2>/dev/null
166 ff260661 2022-11-17 thomas @su -m ${GOTD_USER} -c 'env $(GOTD_TEST_ENV) sh ./check_test_repo.sh'
167 ff260661 2022-11-17 thomas
168 729a7e24 2022-11-17 thomas test_repo_write: prepare_test_repo start_gotd_rw
169 f2900386 2022-10-31 thomas @-$(GOTD_TRAP); su ${GOTD_TEST_USER} -c \
170 f2900386 2022-10-31 thomas 'env $(GOTD_TEST_ENV) sh ./repo_write.sh'
171 f2900386 2022-10-31 thomas @$(GOTD_STOP_CMD) 2>/dev/null
172 f2900386 2022-10-31 thomas @su -m ${GOTD_USER} -c 'env $(GOTD_TEST_ENV) sh ./check_test_repo.sh'
173 a07c01e0 2022-11-08 thomas
174 729a7e24 2022-11-17 thomas test_repo_write_empty: prepare_test_repo_empty start_gotd_rw
175 a07c01e0 2022-11-08 thomas @-$(GOTD_TRAP); su ${GOTD_TEST_USER} -c \
176 a07c01e0 2022-11-08 thomas 'env $(GOTD_TEST_ENV) sh ./repo_write_empty.sh'
177 a07c01e0 2022-11-08 thomas @$(GOTD_STOP_CMD) 2>/dev/null
178 a07c01e0 2022-11-08 thomas @su -m ${GOTD_USER} -c 'env $(GOTD_TEST_ENV) sh ./check_test_repo.sh'
179 f2900386 2022-10-31 thomas
180 f2900386 2022-10-31 thomas .include <bsd.regress.mk>