| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
include ../../Make.inc |
| 10 |
include test_record.mk |
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
ifeq "${VERBOSE}" "" |
| 18 |
Q=@ |
| 19 |
else |
| 20 |
Q= |
| 21 |
endif |
| 22 |
|
| 23 |
BUILD_PATH := $(top_builddir)/build |
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
.PHONY: eapol_test |
| 29 |
eapol_test: $(BUILD_PATH)/tests/eapol_test/eapol_test.mk |
| 30 |
${Q}echo EAPOL_TEST=$(EAPOL_TEST) |
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
ifneq "(findstring eap,$(MAKECMDGOALS))" "" |
| 37 |
$(BUILD_PATH)/tests/eapol_test: |
| 38 |
${Q}mkdir -p $@ |
| 39 |
|
| 40 |
TEST_PATH := $(top_builddir)/src/tests |
| 41 |
DICT_PATH := $(TEST_PATH) |
| 42 |
BIN_PATH := $(BUILD_PATH)/bin/local |
| 43 |
RADIUSD_BIN := $(BIN_PATH)/radiusd |
| 44 |
|
| 45 |
ifeq "$(DICT_PATH)" "$(TEST_PATH)" |
| 46 |
LIB_PATH := $(BUILD_PATH)/lib/local/.libs/ |
| 47 |
DYLD_LIBRARY_PATH := $(DYLD_LIBRARY_PATH):$(LIB_PATH) |
| 48 |
export DYLD_LIBRARY_PATH |
| 49 |
endif |
| 50 |
|
| 51 |
ifneq "$(OPENSSL_LIBS)" "" |
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
ifeq "$(EAPOL_TEST_BIN)" "" |
| 60 |
override EAPOL_TEST_BIN := $(shell $(top_builddir)/scripts/ci/eapol_test-build.sh) |
| 61 |
endif |
| 62 |
|
| 63 |
$(BUILD_PATH)/tests/eapol_test/eapol_test.mk: | $(BUILD_PATH)/tests/eapol_test |
| 64 |
${Q}echo "EAPOL_TEST=$(EAPOL_TEST_BIN)" > $@ |
| 65 |
${Q}echo "TLS1_3=$(shell openssl ciphers -s -v 'ECDHE:!COMPLEMENTOFDEFAULT'| grep -q 'TLSv1.3' && echo yes)" >> $@ |
| 66 |
${Q}echo "OPENSSL_OK=$(shell openssl version | grep -v ' 1\.0' >/dev/null && echo yes)" >> $@ |
| 67 |
${Q}echo "OPENSSL3_OK=$(shell openssl version | grep -q ' OpenSSL 3\.' && echo yes)" >> $@ |
| 68 |
else |
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
.PHONY: $(BUILD_PATH)/tests/eapol_test/eapol_test.mk |
| 73 |
$(BUILD_PATH)/tests/eapol_test/eapol_test.mk: | $(BUILD_PATH)/tests/eapol_test |
| 74 |
${Q}touch $@ |
| 75 |
endif |
| 76 |
|
| 77 |
-include $(BUILD_PATH)/tests/eapol_test/eapol_test.mk |
| 78 |
endif |
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
ifeq "$(OPENSSL_OK)" "" |
| 86 |
SECLEVEL= |
| 87 |
else |
| 88 |
SECLEVEL=@SECLEVEL=1 |
| 89 |
endif |
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
ifeq "$(OPENSSL3_OK)" "yes" |
| 99 |
SECLEVEL=@SECLEVEL=0 |
| 100 |
endif |
| 101 |
|
| 102 |
RADDB_PATH := $(top_builddir)/raddb/ |
| 103 |
|
| 104 |
TESTS = mschapv1 digest-01/digest* \ |
| 105 |
test.example.com |
| 106 |
|
| 107 |
PORT = 12340 |
| 108 |
ACCTPORT = $(shell expr $(PORT) + 1) |
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
SECRET = testing123 |
| 113 |
|
| 114 |
.PHONY: all eap dictionary clean |
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
all: tests |
| 120 |
|
| 121 |
clean: |
| 122 |
@rm -f test.conf dictionary *.ok *.log $(BUILD_DIR)/tests/eap |
| 123 |
|
| 124 |
dictionary: |
| 125 |
@echo "# test dictionary. Do not install. Delete at any time." > dictionary; \ |
| 126 |
echo '$$INCLUDE ' $(top_builddir)/share/dictionary >> dictionary; \ |
| 127 |
echo '$$INCLUDE ' $(top_builddir)/src/tests/dictionary.test >> dictionary; \ |
| 128 |
if [ "$(DICT_PATH)" = "$(TEST_PATH)" ]; then \ |
| 129 |
echo '$$INCLUDE ' $(top_builddir)/share/dictionary.dhcp >> dictionary; \ |
| 130 |
echo '$$INCLUDE ' $(top_builddir)/share/dictionary.vqp >> dictionary; \ |
| 131 |
fi |
| 132 |
|
| 133 |
test.conf: dictionary config/eap-test |
| 134 |
@echo "# test configuration file. Do not install. Delete at any time." > $@ |
| 135 |
${Q}if [ -n "$(LIB_PATH)" ]; then \ |
| 136 |
echo "libdir =" $(LIB_PATH) >> $@; \ |
| 137 |
fi |
| 138 |
${Q}echo "testdir =" $(TEST_PATH) >> $@ |
| 139 |
${Q}echo 'logdir = $${testdir}' >> $@ |
| 140 |
${Q}echo "maindir =" $(RADDB_PATH) >> $@ |
| 141 |
${Q}echo 'radacctdir = $${testdir}' >> $@ |
| 142 |
${Q}echo 'pidfile = $${testdir}/radiusd.pid' >> $@ |
| 143 |
${Q}echo 'panic_action = "gdb -batch -x $${testdir}/panic.gdb %e %p > $${testdir}/gdb.log 2>&1; cat $${testdir}/gdb.log"' >> $@ |
| 144 |
${Q}echo 'security {' >> $@ |
| 145 |
${Q}echo ' allow_vulnerable_openssl = yes' >> $@ |
| 146 |
${Q}echo '}' >> $@ |
| 147 |
${Q}echo >> $@ |
| 148 |
${Q}echo 'modconfdir = $${maindir}mods-config' >> $@ |
| 149 |
${Q}echo 'certdir = $${maindir}/certs' >> $@ |
| 150 |
${Q}echo 'cadir = $${maindir}/certs' >> $@ |
| 151 |
${Q}echo '$$INCLUDE $${testdir}/config/' >> $@ |
| 152 |
${Q}echo '$$INCLUDE $${maindir}/radiusd.conf' >> $@ |
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
config/eap-test-inner-tunnel: $(RADDB_PATH)sites-available/inner-tunnel |
| 158 |
${Q}sed 's/eap/eap-test/;s/server inner-tunnel/server eap-test-inner-tunnel/' < $< > $@ |
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
|
| 166 |
|
| 167 |
|
| 168 |
|
| 169 |
config/eap-test: $(RADDB_PATH)mods-available/eap config/eap-test-inner-tunnel |
| 170 |
${Q}sed -e 's/eap {/eap eap-test {/' \ |
| 171 |
-e 's/= inner-tunnel/= eap-test-inner-tunnel/;s/use_tunneled_reply = no/use_tunneled_reply = yes/' \ |
| 172 |
-e 's/enable = no/enable = yes/' \ |
| 173 |
-e 's/^\(.*\)persist_dir =/ persist_dir =/' \ |
| 174 |
-e 's/#.*softfail =.*/softfail = yes/' \ |
| 175 |
-e 's/tls_min_version = "1.2"/tls_min_version = "1.0"/' \ |
| 176 |
-e '$(if $(TLS1_3),s/tls_max_version = "1.2"/tls_max_version = "1.3"/)' \ |
| 177 |
-e 's/cipher_list = "DEFAULT"/cipher_list = "DEFAULT${SECLEVEL}"/' \ |
| 178 |
< $< > $@ |
| 179 |
|
| 180 |
radiusd.pid: test.conf |
| 181 |
${Q}rm -rf $(TEST_PATH)/gdb.log $(TEST_PATH)/radius.log $(TEST_PATH)/tlscache |
| 182 |
${Q}mkdir -p $(TEST_PATH)/tlscache |
| 183 |
${Q}printf "Starting server... " |
| 184 |
${Q}if ! $(RADIUSD_BIN) -Pxxxxml $(TEST_PATH)/radius.log -d ${top_builddir}/src/tests -n test -i 127.0.0.1 -p $(PORT) -D $(DICT_PATH); then \ |
| 185 |
echo "failed"; \ |
| 186 |
echo "Last log entries were:"; \ |
| 187 |
tail -n 20 "$(TEST_PATH)/radius.log"; \ |
| 188 |
fi |
| 189 |
${Q}echo "ok" |
| 190 |
${Q}echo "radiusd logging to $(TEST_PATH)/radius.log" |
| 191 |
|
| 192 |
|
| 193 |
|
| 194 |
.PHONY: radiusd.kill |
| 195 |
radiusd.kill: |
| 196 |
${Q}if [ -f radiusd.pid ]; then \ |
| 197 |
ret=0; \ |
| 198 |
if ! ps `cat $(TEST_PATH)/radiusd.pid` >/dev/null 2>&1; then \ |
| 199 |
rm -f radiusd.pid; \ |
| 200 |
echo "FreeRADIUS terminated during test"; \ |
| 201 |
echo "GDB output was:"; \ |
| 202 |
cat "$(TEST_PATH)/gdb.log"; \ |
| 203 |
echo "Last log entries were:"; \ |
| 204 |
tail -n 20 $(TEST_PATH)/radius.log; \ |
| 205 |
ret=1; \ |
| 206 |
fi; \ |
| 207 |
if ! kill -TERM `cat $(TEST_PATH)/radiusd.pid` >/dev/null 2>&1; then \ |
| 208 |
ret=1; \ |
| 209 |
fi; \ |
| 210 |
exit $$ret; \ |
| 211 |
fi |
| 212 |
${Q}rm -f radiusd.pid |
| 213 |
|
| 214 |
|
| 215 |
|
| 216 |
|
| 217 |
|
| 218 |
ifneq "$(EAPOL_TEST)" "" |
| 219 |
EAP_FILES = eap-md5.conf |
| 220 |
EAP_FILES += eap-mschapv2.conf |
| 221 |
|
| 222 |
EAP_TLS_FILES = eap-tls.conf |
| 223 |
EAP_TLS_FILES += eap-ttls-eap-gtc.conf |
| 224 |
EAP_TLS_FILES += eap-ttls-eap-mschapv2.conf |
| 225 |
EAP_TLS_FILES += eap-ttls-eap-tls.conf |
| 226 |
EAP_TLS_FILES += eap-ttls-mschapv2.conf |
| 227 |
EAP_TLS_FILES += eap-ttls-pap.conf |
| 228 |
EAP_TLS_FILES += peap-client-mschapv2.conf |
| 229 |
EAP_TLS_FILES += peap-eap-tls.conf |
| 230 |
EAP_TLS_FILES += peap-gtc.conf |
| 231 |
EAP_TLS_FILES += peap-mschapv2.conf |
| 232 |
|
| 233 |
|
| 234 |
|
| 235 |
|
| 236 |
|
| 237 |
EAP_TLS_VERSIONS = 1.1 1.2 |
| 238 |
EAP_TLS_DISABLE_STRING = tls_disable_tlsv1_0=1 tls_disable_tlsv1_1=1 tls_disable_tlsv1_2=1 |
| 239 |
|
| 240 |
ifneq "$(TLS1_3)" "" |
| 241 |
EAP_TLS_VERSIONS += 1.3 |
| 242 |
EAP_TLS_DISABLE_STRING += tls_disable_tlsv1_3=1 |
| 243 |
endif |
| 244 |
|
| 245 |
.PHONY: $(BUILD_PATH)/tests/eap |
| 246 |
$(BUILD_PATH)/tests/eap: |
| 247 |
${Q}mkdir -p $@ |
| 248 |
|
| 249 |
.PHONY: clean.tests.eap |
| 250 |
clean.tests.eap: |
| 251 |
${Q}rm -rf $(BUILD_PATH)/tests/eap config/tlscache config/eap-test config/eap-test-inner-tunnel |
| 252 |
|
| 253 |
|
| 254 |
|
| 255 |
|
| 256 |
|
| 257 |
|
| 258 |
$(BUILD_PATH)/tests/eap/%.ok: NO_MPPE = $(filter eap-md5,$(basename $(notdir $@))) |
| 259 |
$(BUILD_PATH)/tests/eap/%.ok: CMD = $(EAPOL_TEST) -c $< -p $(PORT) -s $(SECRET) $(if $(NO_MPPE),-n) |
| 260 |
$(BUILD_PATH)/tests/eap/%.ok: LOG = $(patsubst %.ok,%,$@).log |
| 261 |
|
| 262 |
$(BUILD_PATH)/tests/eap/%.ok: $(top_builddir)/src/tests/%.conf | radiusd.kill $(BUILD_PATH)/tests/eap radiusd.pid radiusd.kill |
| 263 |
${Q}printf 'EAPOL_TEST %s ' $(notdir $(patsubst %.conf,%,$<)) |
| 264 |
${Q}if ! $(CMD) > $(LOG) 2>&1; then \ |
| 265 |
echo " - " FAILED - command failed; \ |
| 266 |
echo ">>> cmd -" $(CMD); \ |
| 267 |
echo ">>> log -" $(LOG); \ |
| 268 |
echo "===================="; \ |
| 269 |
tail -10 $(LOG); \ |
| 270 |
echo "===================="; \ |
| 271 |
$(MAKE) radiusd.kill; \ |
| 272 |
$(call test_record,eap,$(notdir $(patsubst %.conf,%,$<)),FAIL,$(LOG)); \ |
| 273 |
exit 1; \ |
| 274 |
fi |
| 275 |
@echo |
| 276 |
${Q}$(call test_record,eap,$(notdir $(patsubst %.conf,%,$<)),PASS,$(LOG)) |
| 277 |
${Q}touch $@ |
| 278 |
|
| 279 |
|
| 280 |
|
| 281 |
|
| 282 |
ifneq "$(prefix)" "" |
| 283 |
|
| 284 |
|
| 285 |
|
| 286 |
|
| 287 |
|
| 288 |
|
| 289 |
|
| 290 |
define EAP_TLS_CONFIG |
| 291 |
$(BUILD_PATH)/tests/eap/${1}-${2}.conf: $(top_builddir)/src/tests/${1}.conf |
| 292 |
${Q}sed -e 's/phase1="/phase1="$(subst $(subst .,_,${2})=1,$(subst .,_,${2})=0,$(EAP_TLS_DISABLE_STRING)) /' \ |
| 293 |
-e '/password/s/^//p; /password/s/^.*/ openssl_ciphers="DEFAULT${SECLEVEL}"/' \ |
| 294 |
< $$< > $$@ |
| 295 |
|
| 296 |
$(BUILD_PATH)/tests/eap/${1}-${2}.ok: $(BUILD_PATH)/tests/eap/${1}-${2}.conf |
| 297 |
${Q}printf 'EAPOL_TEST %s' $$(notdir $$(patsubst %.ok,%,$$@)) |
| 298 |
${Q}if ! $$(CMD) -r 1 > $$(LOG) 2>&1; then \ |
| 299 |
echo " - " FAILED - command failed; \ |
| 300 |
echo ">>> cmd -" $$(CMD) -r 1; \ |
| 301 |
echo ">>> log -" $$(LOG); \ |
| 302 |
echo "===================="; \ |
| 303 |
tail -10 $$(LOG); \ |
| 304 |
echo "===================="; \ |
| 305 |
$(MAKE) radiusd.kill; \ |
| 306 |
$$(call test_record,eap,$$(notdir $$(patsubst %.ok,%,$$@)),FAIL,$$(LOG)); \ |
| 307 |
exit 1; \ |
| 308 |
elif ! grep -q '^SSL: Using TLS version TLSv${2}$$$$' $$(patsubst %.ok,%,$$@).log; then \ |
| 309 |
echo " - " FAILED - not using TLS version ${2}; \ |
| 310 |
echo ">>> cmd -" $$(CMD) -r 1; \ |
| 311 |
echo ">>> log -" $$(LOG); \ |
| 312 |
$(MAKE) radiusd.kill; \ |
| 313 |
$$(call test_record,eap,$$(notdir $$(patsubst %.ok,%,$$@)),FAIL,$$(LOG)); \ |
| 314 |
exit 1; \ |
| 315 |
elif ! grep -q '^OpenSSL: Handshake finished - resumed=1$$$$' $$(patsubst %.ok,%,$$@).log; then \ |
| 316 |
echo " - " FAILED - did not use resumption; \ |
| 317 |
echo ">>> cmd -" $$(CMD) -r 1; \ |
| 318 |
echo ">>> log -" $$(LOG); \ |
| 319 |
$(MAKE) radiusd.kill; \ |
| 320 |
$$(call test_record,eap,$$(notdir $$(patsubst %.ok,%,$$@)),FAIL,$$(LOG)); \ |
| 321 |
exit 1; \ |
| 322 |
fi |
| 323 |
@echo |
| 324 |
${Q}$$(call test_record,eap,$$(notdir $$(patsubst %.ok,%,$$@)),PASS,$$(LOG)) |
| 325 |
${Q}touch $$@ |
| 326 |
|
| 327 |
# EAP-FAST doesn't do TLS 1.3 |
| 328 |
ifneq "${1}-${2}" "eap-fast-1.3" |
| 329 |
EAP_TLS_VERSION_FILES += $(BUILD_PATH)/tests/eap/${1}-${2}.ok |
| 330 |
endif |
| 331 |
endef |
| 332 |
|
| 333 |
$(foreach FILE,$(patsubst %.conf,%,$(EAP_TLS_FILES)),$(foreach TLS,$(EAP_TLS_VERSIONS),$(eval $(call EAP_TLS_CONFIG,${FILE},${TLS})))) |
| 334 |
endif |
| 335 |
|
| 336 |
EAPOL_OK_FILES := $(sort $(addprefix $(BUILD_PATH)/tests/eap/,$(patsubst %.conf,%.ok, $(notdir $(EAP_TLS_FILES) $(EAP_FILES)))) $(EAP_TLS_VERSION_FILES)) |
| 337 |
|
| 338 |
tests.eap: $(EAPOL_OK_FILES) | radiusd.kill radiusd.pid |
| 339 |
else |
| 340 |
tests.eap: |
| 341 |
${Q}echo "EAP tests are disabled" |
| 342 |
endif |
| 343 |
|
| 344 |
|
| 345 |
|
| 346 |
|
| 347 |
|
| 348 |
|
| 349 |
tests.runtests: test.conf | radiusd.kill radiusd.pid |
| 350 |
${Q}chmod a+x runtests.sh |
| 351 |
${Q}BIN_PATH="$(BIN_PATH)" PORT="$(PORT)" ./runtests.sh $(TESTS) |
| 352 |
|
| 353 |
tests: tests.runtests tests.eap |
| 354 |
$(MAKE) radiusd.kill |