]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Fix literal keys in cache module
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Thu, 25 Apr 2024 00:00:11 +0000 (20:00 -0400)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Thu, 25 Apr 2024 00:00:11 +0000 (20:00 -0400)
src/lib/unlang/call_env.c
src/tests/modules/cache_rbtree/cache-update.unlang
src/tests/modules/cache_rbtree/module.conf
src/tests/modules/cache_redis/module.conf

index 57feccefa8ea234c026f6382ea3d7d7b86786783..dd133e4e4fc0ee397918678950e22a89519121d6 100644 (file)
@@ -378,7 +378,10 @@ int call_env_parse_pair(TALLOC_CTX *ctx, void *out, tmpl_rules_t const *t_rules,
        }
        *(void **)out = parsed_tmpl;
 
-       return 0;
+       /*
+        *      All attributes and functions should be resolved at this point
+        */
+       return tmpl_resolve(parsed_tmpl, NULL);
 }
 
 /** Parse per call env
index d09bac4020e3106e11a20137921361fd9ffe388f..41df64bb77fe5e70dd1fcb84180a2f7c81ad4a23 100644 (file)
@@ -72,4 +72,7 @@ if (&Login-LAT-Service[2] != 'baz') {
 # Clear out the reply list
 &reply := {}
 
+# Need to test if thie cache env parses correctly, we dont really care about testing the static key
+static_key
+
 test_pass
index 58ced1dccbe8e2c909aa93381c904a782851adc0..f91c03255dc7a164fbc235e1d2599afa48cc0a0b 100644 (file)
@@ -94,3 +94,15 @@ cache cache_empty_update {
        key = "%{Filter-Id}"
        ttl = 5
 }
+
+# Regression test for literal data
+# Previously failed with "I-Am-A-Static-Key' expands to invalid tmpl type data-unresolved"
+cache static_key {
+       driver = "rbtree"
+       key = "I-Am-A-Static-Key"
+       ttl = 5
+
+       update {
+               &Callback-Id := &Callback-Id[0]
+       }
+}
index 515dde3fc65b766878413374939ec1a9fed5416b..1fad7a2ee7e5990c30140ecde642a63a57c9995c 100644 (file)
@@ -128,3 +128,24 @@ cache cache_empty_update {
        key = "%{Filter-Id}"
        ttl = 5
 }
+
+# Regression test for literal data
+cache static_key {
+       driver = "redis"
+
+       redis {
+               server = $ENV{CACHE_REDIS_TEST_SERVER}:30001
+               server = $ENV{CACHE_REDIS_TEST_SERVER}:30002
+               server = $ENV{CACHE_REDIS_TEST_SERVER}:30003
+               server = $ENV{CACHE_REDIS_TEST_SERVER}:30004
+               server = $ENV{CACHE_REDIS_TEST_SERVER}:30005
+               server = $ENV{CACHE_REDIS_TEST_SERVER}:30006
+       }
+
+       key = "I-Am-A-Static-Key"
+       ttl = 5
+
+       update {
+               &Callback-Id := &Callback-Id[0]
+       }
+}