From: Nick Porter Date: Wed, 13 Apr 2022 09:29:57 +0000 (+0100) Subject: Run tests on RFC4533 LDAP server X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=25a32cd7bb1a6e6e42197623f65528ad45c63af1;p=thirdparty%2Ffreeradius-server.git Run tests on RFC4533 LDAP server --- diff --git a/src/tests/ldap_sync/rfc4533/all.mk b/src/tests/ldap_sync/rfc4533/all.mk new file mode 100644 index 00000000000..2be2c16494d --- /dev/null +++ b/src/tests/ldap_sync/rfc4533/all.mk @@ -0,0 +1,65 @@ +# +# Tests against RFC4533 implementing LDAP directories +# + +# +# Test name +# +TEST := test.ldap_sync/rfc4533 +FILES := $(subst $(DIR)/,,$(wildcard $(DIR)/*.ldif)) + +$(eval $(call TEST_BOOTSTRAP)) + +# +# Generic rules to start /stop the radius service +# +include src/tests/radiusd.mk +$(eval $(call RADIUSD_SERVICE,radiusd,$(OUTPUT))) + +$(OUTPUT)/%: $(DIR)/% | $(TEST).radiusd_kill $(TEST).radiusd_start + $(eval TARGET := $(notdir $<)) + $(eval EXPECTED := $(patsubst %.ldif,%.out,$<)) + $(eval FOUND := $(patsubst %.ldif,%.out,$@)) + $(eval ARGV := $(shell grep "#.*ARGV:" $< | cut -f2 -d ':')) + $(eval OUT_DIR := $(BUILD_DIR)/tests/ldap_sync/rfc4533) + + $(Q)echo "LDAPSYNC-TEST rfc4533 $(TARGET)" + $(Q)[ -f $(dir $@)/radiusd.pid ] || exit 1 + $(Q)rm -f $(OUT_DIR)/linelog.out + $(Q)rm -f $(OUT_DIR)/cookielog.out > /dev/null 2>&1 + $(Q)ldapmodify $(ARGV) -f $< > /dev/null + $(Q)i=0; while [ $$i -lt 300 ] ; \ + do if [ -e $(OUT_DIR)/linelog.out ] ; \ + then \ + break; \ + fi; \ + sleep .1; \ + i=$$((i+1)); \ + done ; + $(Q)sleep .1 + $(Q)mv $(OUT_DIR)/linelog.out $(FOUND) + +# +# Cookies are not guaranteed for every update, according to the RFC, +# though experience shows they do arrive. +# + $(Q)if [ -e $(OUT_DIR)/cookielog.out ]; then \ + if [ `grep -v -P 'Cookie = rid=\d{3},csn=\d{14}\.\d{6}Z#\d{6}#\d{3}#\d{6}' $(OUT_DIR)/cookielog.out | wc -l` -ne 0 ]; then \ + echo "LDAP_SYNC FAILED $@ - invalid cookie stored"; \ + rm -f $(BUILD_DIR)/tests/test.ldap_sync/rfc4533; \ + $(MAKE) --no-print-direcotry test.ldap_sync/rfc4533.radiusd_kill; \ + exit 1; \ + fi; \ + fi + + $(Q)if [ -e "$(EXPECTED)" ] && ! cmp -s $(FOUND) $(EXPECTED); then \ + echo "LDAP_SYNC FAILED $@"; \ + rm -rf $(BUILD_DIR)/tests/test.ldap_sync/rfc4533; \ + $(MAKE) --no-print-directory test.ldap_sync/rfc4533.radiusd_kill; \ + exit 1; \ + fi + $(Q)touch $@ + +$(TEST): + $(Q)$(MAKE) --no-print-directory $@.radiusd_stop + @touch $(BUILD_DIR)/tests/$@