From e11e3a07979c7466af8af06fc478b2292a502f03 Mon Sep 17 00:00:00 2001 From: Arran Cudbard-Bell Date: Wed, 24 Apr 2024 20:00:11 -0400 Subject: [PATCH] Fix literal keys in cache module --- src/lib/unlang/call_env.c | 5 ++++- .../modules/cache_rbtree/cache-update.unlang | 3 +++ src/tests/modules/cache_rbtree/module.conf | 12 +++++++++++ src/tests/modules/cache_redis/module.conf | 21 +++++++++++++++++++ 4 files changed, 40 insertions(+), 1 deletion(-) diff --git a/src/lib/unlang/call_env.c b/src/lib/unlang/call_env.c index 57feccefa8..dd133e4e4f 100644 --- a/src/lib/unlang/call_env.c +++ b/src/lib/unlang/call_env.c @@ -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 diff --git a/src/tests/modules/cache_rbtree/cache-update.unlang b/src/tests/modules/cache_rbtree/cache-update.unlang index d09bac4020..41df64bb77 100644 --- a/src/tests/modules/cache_rbtree/cache-update.unlang +++ b/src/tests/modules/cache_rbtree/cache-update.unlang @@ -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 diff --git a/src/tests/modules/cache_rbtree/module.conf b/src/tests/modules/cache_rbtree/module.conf index 58ced1dccb..f91c03255d 100644 --- a/src/tests/modules/cache_rbtree/module.conf +++ b/src/tests/modules/cache_rbtree/module.conf @@ -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] + } +} diff --git a/src/tests/modules/cache_redis/module.conf b/src/tests/modules/cache_redis/module.conf index 515dde3fc6..1fad7a2ee7 100644 --- a/src/tests/modules/cache_redis/module.conf +++ b/src/tests/modules/cache_redis/module.conf @@ -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] + } +} -- 2.47.3