]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Add basic tests for dollar expansions in conditions
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Wed, 29 Jun 2022 16:08:47 +0000 (11:08 -0500)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Wed, 29 Jun 2022 16:08:47 +0000 (11:08 -0500)
src/tests/modules/test/dollar_expansions.attr [new file with mode: 0644]
src/tests/modules/test/dollar_expansions.unlang [new file with mode: 0644]
src/tests/modules/test/global.conf [new file with mode: 0644]
src/tests/modules/test/policy.conf

diff --git a/src/tests/modules/test/dollar_expansions.attr b/src/tests/modules/test/dollar_expansions.attr
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/src/tests/modules/test/dollar_expansions.unlang b/src/tests/modules/test/dollar_expansions.unlang
new file mode 100644 (file)
index 0000000..853b27a
--- /dev/null
@@ -0,0 +1,16 @@
+# Should be compiled out
+if ('${a_term}' != '${a_term}') {
+        test_fail
+}
+
+# Check it's not just expanded to a zero length string
+if ('${a_term}' == '${b_term}') {
+        test_fail
+}
+
+# Check against dynamic attributes
+if ('${c_term}' != &User-Name) {
+        test_fail
+}
+dollar_expansions
+test_pass
diff --git a/src/tests/modules/test/global.conf b/src/tests/modules/test/global.conf
new file mode 100644 (file)
index 0000000..b1cfb76
--- /dev/null
@@ -0,0 +1,3 @@
+a_term = 'foo'
+b_term = 'bar'
+c_term = 'bob'
index 5a675fb4f92f89c752d6c13efa60d21b52b26d1d..47af41e58ed489dd9811f033d20de63f32645a52 100644 (file)
@@ -35,3 +35,20 @@ section_names {
                test_fail
        }
 }
+
+dollar_expansions {
+       # Should be compiled out
+       if ('${a_term}' != '${a_term}') {
+               test_fail
+       }
+
+       # Check it's not just expanded to a zero length string
+       if ('${a_term}' == '${b_term}') {
+               test_fail
+       }
+
+       # Check against dynamic attributes
+       if ('${c_term}' != &User-Name) {
+               test_fail
+       }
+}