]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Adapt RFC4533 ldap_sync tests to validate new cookie store behaviour
authorNick Porter <nick@portercomputing.co.uk>
Wed, 2 Nov 2022 19:44:18 +0000 (19:44 +0000)
committerNick Porter <nick@portercomputing.co.uk>
Fri, 4 Nov 2022 16:38:32 +0000 (16:38 +0000)
src/tests/ldap_sync/rfc4533/all.mk
src/tests/ldap_sync/rfc4533/config/radiusd.conf

index 1c4a009e71fe8f7a08810a325ece722bc7df2138..fec35fdbb49d4db3d93c956249a47932fb17411d 100644 (file)
@@ -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/$@
index 45bcb7920d75350bbc0bff57902b266d264c2327..c96b2cd5d8fc9967bbebb35306a0965dab1be844 100644 (file)
@@ -138,6 +138,7 @@ server test {
 
        listen {
                transport = ldap
+               cookie_changes = 2
 
                ldap {
                        server = $ENV{RFC4533_TEST_SERVER}