Skip to content

Commit

Permalink
Add unit tests for env var logic
Browse files Browse the repository at this point in the history
  • Loading branch information
dkirov-dd committed Dec 23, 2024
1 parent 6390fd8 commit 402ce03
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions datadog_checks_base/tests/base/checks/test_agent_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# Licensed under a 3-clause BSD style license (see LICENSE)
import json
import logging
import os
from typing import Any # noqa: F401

import mock
Expand Down Expand Up @@ -1293,3 +1294,21 @@ def test_detect_typos_configuration_models(
assert "Detected potential typo in configuration option" not in caplog.text

assert typos == set(unknown_options)


def test_env_var_logic_default():
with mock.patch.dict('os.environ', {'GOFIPS': '0'}):
AgentCheck()
assert os.getenv('OPENSSL_CONF', None) is None
assert os.getenv('OPENSSL_MODULES', None) is None


def test_env_var_logic_preset():
preset_conf = 'path/to/openssl.cnf'
preset_modules = 'path/to/ossl-modules'
with mock.patch.dict(
'os.environ', {'GOFIPS': '1', 'OPENSSL_CONF': preset_conf, 'OPENSSL_MODULES': preset_modules}
):
AgentCheck()
assert os.getenv('OPENSSL_CONF', None) == preset_conf
assert os.getenv('OPENSSL_MODULES', None) == preset_modules

0 comments on commit 402ce03

Please sign in to comment.