From: Nick Porter Date: Wed, 2 Nov 2022 19:44:18 +0000 (+0000) Subject: Adapt RFC4533 ldap_sync tests to validate new cookie store behaviour X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d73c0560fccdc57ee1026f63b5d614b241242ebf;p=thirdparty%2Ffreeradius-server.git Adapt RFC4533 ldap_sync tests to validate new cookie store behaviour --- diff --git a/src/tests/ldap_sync/rfc4533/all.mk b/src/tests/ldap_sync/rfc4533/all.mk index 1c4a009e71f..fec35fdbb49 100644 --- a/src/tests/ldap_sync/rfc4533/all.mk +++ b/src/tests/ldap_sync/rfc4533/all.mk @@ -7,6 +7,7 @@ # TEST := test.ldap_sync/rfc4533 FILES := $(subst $(DIR)/,,$(wildcard $(DIR)/*.ldif)) +TEST_COUNT := $(words $(FILES)) $(eval $(call TEST_BOOTSTRAP)) @@ -27,7 +28,6 @@ $(OUTPUT)/%: $(DIR)/% | $(TEST).radiusd_kill $(TEST).radiusd_start $(Q)echo "LDAPSYNC-TEST rfc4533 $(TARGET)" $(Q)[ -f $(dir $@)/radiusd.pid ] || exit 1 $(Q)rm -f $(OUT_DIR)/$(OUT).out - $(Q)rm -f $(OUT_DIR)/cookielog.out > /dev/null 2>&1 $(Q)sleep 1 $(Q)ldapmodify $(ARGV) -f $< > /dev/null $(Q)i=0; while [ $$i -lt 600 ] ; \ @@ -40,20 +40,6 @@ $(OUTPUT)/%: $(DIR)/% | $(TEST).radiusd_kill $(TEST).radiusd_start done ; $(Q)sleep .1 $(Q)mv $(OUT_DIR)/$(OUT).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; \ @@ -63,5 +49,31 @@ $(OUTPUT)/%: $(DIR)/% | $(TEST).radiusd_kill $(TEST).radiusd_start $(Q)touch $@ $(TEST): + $(eval OUT_DIR := $(BUILD_DIR)/tests/ldap_sync/rfc4533) $(Q)$(MAKE) --no-print-directory $@.radiusd_stop + +# +# Once all the individual tests are run, there should be cookies in the cookie log. +# The site config has been set to write a cookie after each 2 changes - so the number +# of cookies should be at least the number of tests / 2 since OpenLDAP sends a cookie +# with each search result. +# Since the tests open two searches, and each receives the cookeis, it can be more than +# number of tests / 2. +# + $(Q)echo "LDAPSYNC-TEST rfc4533 cookie" + $(Q)if [ ! -e $(OUT_DIR)/cookielog.out ]; then \ + echo "LDAP_SYNC FAILED $@ - no cookie stored"; \ + exit 1; \ + fi + $(Q)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 + $(Q)if [ "`cat $(OUT_DIR)/cookielog.out | wc -l`" -lt "`expr $(TEST_COUNT) / 2`" ]; then \ + echo "LDAP_SYNC_FAILED $@ - insufficient cookies stored"; \ + exit 1; \ + fi + @touch $(BUILD_DIR)/tests/$@ diff --git a/src/tests/ldap_sync/rfc4533/config/radiusd.conf b/src/tests/ldap_sync/rfc4533/config/radiusd.conf index 45bcb7920d7..c96b2cd5d8f 100644 --- a/src/tests/ldap_sync/rfc4533/config/radiusd.conf +++ b/src/tests/ldap_sync/rfc4533/config/radiusd.conf @@ -138,6 +138,7 @@ server test { listen { transport = ldap + cookie_changes = 2 ldap { server = $ENV{RFC4533_TEST_SERVER}