From ec4686e3edd5600ac973bfa8b31866b0860743a1 Mon Sep 17 00:00:00 2001 From: Dmitry Ivanov <d.ivanov@picodata.io> Date: Wed, 16 Aug 2023 10:04:22 +0000 Subject: [PATCH] fix: pass env variables for LDAP configuration in `main_run` --- src/main.rs | 5 ++++- test/int/test_ldap_env.py | 23 +++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 test/int/test_ldap_env.py diff --git a/src/main.rs b/src/main.rs index 116df0e1b9..4a43ad9a72 100644 --- a/src/main.rs +++ b/src/main.rs @@ -59,7 +59,10 @@ fn main_run(args: args::Run) -> ! { // Tarantool implicitly parses some environment variables. // We don't want them to affect the behavior and thus filter them out. for (k, _) in std::env::vars() { - if k.starts_with("TT_") || k.starts_with("TARANTOOL_") { + // NB: For the moment we'd rather allow LDAP-related variables, + // but see https://git.picodata.io/picodata/tarantool/-/issues/25. + let is_relevant = k.starts_with("TT_") || k.starts_with("TARANTOOL_"); + if !k.starts_with("TT_LDAP") && is_relevant { std::env::remove_var(k) } } diff --git a/test/int/test_ldap_env.py b/test/int/test_ldap_env.py new file mode 100644 index 0000000000..2edcc63b92 --- /dev/null +++ b/test/int/test_ldap_env.py @@ -0,0 +1,23 @@ +from conftest import Cluster, Instance +import pytest + +TT_LDAP_URL = "ldap://localhost:1389" +TT_LDAP_DN_FMT = "cn=$USER,ou=users,dc=example,dc=org" + + +@pytest.fixture +def instance(cluster: Cluster): + instance = cluster.add_instance(wait_online=False) + instance.env["TT_LDAP_URL"] = TT_LDAP_URL + instance.env["TT_LDAP_DN_FMT"] = TT_LDAP_DN_FMT + instance.start() + instance.wait_online() + return instance + + +# Related: https://git.picodata.io/picodata/tarantool/-/issues/25 +def test_ldap_env_variables(instance: Instance): + res = instance.eval("return require('os').getenv('TT_LDAP_URL')") + assert res == TT_LDAP_URL + res = instance.eval("return require('os').getenv('TT_LDAP_DN_FMT')") + assert res == TT_LDAP_DN_FMT -- GitLab