diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 09:49:46 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 09:49:46 +0000 |
commit | 50b37d4a27d3295a29afca2286f1a5a086142cec (patch) | |
tree | 9212f763934ee090ef72d823f559f52ce387f268 /src/tests/xlat | |
parent | Initial commit. (diff) | |
download | freeradius-upstream/3.2.1+dfsg.tar.xz freeradius-upstream/3.2.1+dfsg.zip |
Adding upstream version 3.2.1+dfsg.upstream/3.2.1+dfsgupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/tests/xlat')
-rw-r--r-- | src/tests/xlat/all.mk | 57 | ||||
-rw-r--r-- | src/tests/xlat/expr.txt | 20 | ||||
-rw-r--r-- | src/tests/xlat/radiusd.conf | 37 |
3 files changed, 114 insertions, 0 deletions
diff --git a/src/tests/xlat/all.mk b/src/tests/xlat/all.mk new file mode 100644 index 0000000..190a1ed --- /dev/null +++ b/src/tests/xlat/all.mk @@ -0,0 +1,57 @@ +# +# Unit tests for dynamic xlat expansions +# + +# +# The test files are files without extensions. +# The list is unordered. The order is added in the next step by looking +# at precursors. +# +XLAT_FILES := $(subst $(DIR)/,,$(wildcard $(DIR)/*.txt)) + +# +# Create the output directory +# +.PHONY: $(BUILD_DIR)/tests/xlat +$(BUILD_DIR)/tests/xlat: + @mkdir -p $@ + +# +# Files in the output dir depend on the unit tests +# +# src/tests/xlat/FOO input file +# build/tests/xlat/FOO updated if the test succeeds +# build/tests/xlat/FOO.log debug output for the test +# +# Auto-depend on modules via $(shell grep INCLUDE $(DIR)/radiusd.conf | grep mods-enabled | sed 's/.*}/raddb/')) +# +# If the test fails, then look for ERROR in the input. No error +# means it's unexpected, so we die. +# +# Otherwise, check the log file for a parse error which matches the +# ERROR line in the input. +# +$(BUILD_DIR)/tests/xlat/%: $(DIR)/% $(TESTBINDIR)/unittest | $(BUILD_DIR)/tests/xlat build.raddb + @echo XLAT-TEST $(notdir $@) + @if ! $(TESTBIN)/unittest -D share -d src/tests/xlat/ -i $< -xx -O xlat_only > $@.log 2>&1; then \ + cat $@.log; \ + echo "./$(TESTBIN)/unittest -D share -d src/tests/xlat/ -i $< -xx -O xlat_only"; \ + exit 1; \ + fi + @touch $@ + +# +# Get all of the unit test output files +# +TESTS.XLAT_FILES := $(addprefix $(BUILD_DIR)/tests/xlat/,$(XLAT_FILES)) + +# +# Depend on the output files, and create the directory first. +# +tests.xlat: $(TESTS.XLAT_FILES) + +$(TESTS.XLAT_FILES): $(TESTS.UNIT_FILES) + +.PHONY: clean.tests.xlat +clean.tests.xlat: + @rm -rf $(BUILD_DIR)/tests/xlat/ diff --git a/src/tests/xlat/expr.txt b/src/tests/xlat/expr.txt new file mode 100644 index 0000000..e2d9f10 --- /dev/null +++ b/src/tests/xlat/expr.txt @@ -0,0 +1,20 @@ +xlat %{md5:This is a string\n} +data 9ac4dbbc3c0ad2429e61d0df5dc28add + +xlat %{expr: 1 + 2 + 3 + 4} +data 10 + +xlat %{expr: 1 & ~1} +data 0 + +xlat %{expr: 2 - -1} +data 3 + +xlat %{expr: -1 * 2} +data -2 + +xlat %{expr: 1 << 2 | 1} +data 5 + +xlat %{expr: 6 + -(1 + 3)} +data 2 diff --git a/src/tests/xlat/radiusd.conf b/src/tests/xlat/radiusd.conf new file mode 100644 index 0000000..89e7f24 --- /dev/null +++ b/src/tests/xlat/radiusd.conf @@ -0,0 +1,37 @@ +# +# Minimal radiusd.conf for testing keywords +# + +raddb = raddb + +modconfdir = ${raddb}/mods-config + +correct_escapes = true + +# Only for testing! +# Setting this on a production system is a BAD IDEA. +security { + allow_vulnerable_openssl = yes +} + +modules { + $INCLUDE ${raddb}/mods-enabled/always + + $INCLUDE ${raddb}/mods-enabled/pap + + $INCLUDE ${raddb}/mods-enabled/expr +} + +server default { + authorize { + update control { + Cleartext-Password := 'hello' + } + + pap + } + + authenticate { + pap + } +} |