client-python icon indicating copy to clipboard operation
client-python copied to clipboard

"get_config_variable" would not raise ValueError with required = True, if env_var is not set and config dict is empty

Open trend-chehao-hsiao opened this issue 6 months ago • 0 comments

Description

def test_get_opencti_client_missing_url(self):
        """Test client creation with missing URL."""
        sample_config = {}
        with pytest.raises(ValueError, match="The configuration OPENCTI_URL is required"):
            get_config_variable("OPENCTI_URL", ["opencti", "url"], sample_config, required=True)

will test failed Failed: DID NOT RAISE <class 'ValueError'>

Environment

  1. Mac OS 15.5
  2. OpenCTI version: OpenCTI 6.6.12

Reproducible Steps

Steps to create the smallest reproducible scenario: run unit test with get_config_variable

def test_get_opencti_client_missing_url(self):
        """Test client creation with missing URL."""
        sample_config = {}
        with pytest.raises(ValueError, match="The configuration OPENCTI_URL is required"):
            get_config_variable("OPENCTI_URL", ["opencti", "url"], sample_config, required=True)

Expected Output

raise ValueError "The configuration OPENCTI_URL is required"

Actual Output

get None

Additional information

N/A

trend-chehao-hsiao avatar Aug 27 '25 05:08 trend-chehao-hsiao