]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Run tests on Active Directory LDAP server
authorNick Porter <nick@portercomputing.co.uk>
Fri, 19 Aug 2022 16:01:46 +0000 (17:01 +0100)
committerNick Porter <nick@portercomputing.co.uk>
Tue, 30 Aug 2022 12:52:13 +0000 (13:52 +0100)
src/tests/ldap_sync/active_directory/all.mk [new file with mode: 0644]

diff --git a/src/tests/ldap_sync/active_directory/all.mk b/src/tests/ldap_sync/active_directory/all.mk
new file mode 100644 (file)
index 0000000..1d65437
--- /dev/null
@@ -0,0 +1,56 @@
+#
+#      Tests against Persistent Search implementing LDAP directories
+#
+
+#
+#      Test name
+#
+TEST := test.ldap_sync/active_directory
+FILES := $(subst $(DIR)/,,$(wildcard $(DIR)/*.sh))
+
+$(eval $(call TEST_BOOTSTRAP))
+
+#
+#      Generic rules to start /stop the radius service
+#
+include src/tests/radiusd.mk
+$(eval $(call RADIUSD_SERVICE,radiusd,$(OUTPUT)))
+
+#
+#      There is a delay of up to 30 seconds looking for the output file
+#      as samba only sends results of persistent LDAP searches on a polled
+#      basis.  Real Active Directory sends the results immediately.
+#
+$(OUTPUT)/%: $(DIR)/% | $(TEST).radiusd_kill $(TEST).radiusd_start
+       $(eval TARGET   := $(notdir $<))
+       $(eval EXPECTED := $(patsubst %.sh,%.out,$<))
+       $(eval FOUND    := $(patsubst %.sh,%.out,$@))
+       $(eval ARGV     := $(shell grep "#.*ARGV:" $< | cut -f2))
+       $(eval OUT_DIR  := $(BUILD_DIR)/tests/ldap_sync/active_directory)
+
+       $(Q)echo "LDAPSYNC-TEST active_directory $(TARGET)"
+       $(Q)[ -f $(dir $@)/radiusd.pid ] || exit 1
+       $(Q)rm -f $(OUT_DIR)/linelog.out
+       $(Q)$<
+       $(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 .5
+       $(Q)mv $(OUT_DIR)/linelog.out $(FOUND)
+
+       $(Q)if [ -e "$(EXPECTED)" ] && ! cmp -s $(FOUND) $(EXPECTED); then      \
+               echo "LDAP_SYNC FAILED $@";                                     \
+               rm -rf $(BUILD_DIR)/tests/test.ldap_sync/active_directory;      \
+               $(MAKE) --no-print-directory test.ldap_sync/active_directory.radiusd_kill; \
+               exit 1;                                                         \
+       fi
+       $(Q)touch $@
+
+$(TEST):
+       $(Q)$(MAKE) --no-print-directory $@.radiusd_stop
+       @touch $(BUILD_DIR)/tests/$@