mirror of
https://github.com/apache/superset.git
synced 2026-05-07 08:54:23 +00:00
fix: support nested function calls in cache_key_wrapper (#38569)
(cherry picked from commit a9def2fc15)
This commit is contained in:
committed by
Michael S. Molina
parent
cfcaaa9db4
commit
f63c0d4caa
@@ -1693,3 +1693,24 @@ def test_undefined_template_variable_not_function(mocker: MockerFixture) -> None
|
||||
template = "SELECT {{ undefined_variable.some_method() }}"
|
||||
with pytest.raises(UndefinedError):
|
||||
processor.process_template(template)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("sql", "expected"),
|
||||
[
|
||||
("SELECT {{ cache_key_wrapper(abc) }}", True),
|
||||
("SELECT {{ cache_key_wrapper(myfunc()) }}", True),
|
||||
("SELECT {{ url_param('foo') }}", True),
|
||||
("SELECT {{ url_param(get_param('foo')) }}", True),
|
||||
("SELECT {{ current_user_id() }}", True),
|
||||
("SELECT {{ current_username() }}", True),
|
||||
("SELECT {{ current_user_email() }}", True),
|
||||
("SELECT {{ current_user_roles() }}", True),
|
||||
("SELECT {{ current_user_rls_rules() }}", True),
|
||||
("SELECT 'cache_key_wrapper(abc)' AS false_positive", False),
|
||||
("SELECT 1", False),
|
||||
("SELECT '{{ 1 + 1 }}'", False),
|
||||
],
|
||||
)
|
||||
def test_extra_cache_regex(sql: str, expected: bool) -> None:
|
||||
assert bool(ExtraCache.regex.search(sql)) is expected
|
||||
|
||||
Reference in New Issue
Block a user