Skip to content

Commit de9c6a8

Browse files
committed
Add test to verify proxy conflict raises ValueError for mismatched proxy settings
1 parent aa63891 commit de9c6a8

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

tests/test_resources.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import pytest
22
import yaml
3+
import kubernetes
4+
import os
35
from testcontainers.k3s import K3SContainer
46

57
from ocp_resources.exceptions import ResourceTeardownError
@@ -103,3 +105,15 @@ def test_resource_context_manager_exit(self, client):
103105
with pytest.raises(ResourceTeardownError):
104106
with TestSecretExit(name="test-context-manager-exit", namespace="default", client=client):
105107
pass
108+
109+
def test_proxy_conflict_raises_value_error(self):
110+
os.environ["OPENSHIFT_PYTHON_WRAPPER_CLIENT_USE_PROXY"] = "1"
111+
os.environ["HTTPS_PROXY"] = "http://env-proxy.com"
112+
client_configuration = kubernetes.client.Configuration()
113+
client_configuration.proxy = "http://not-env-proxy.com"
114+
with pytest.raises(
115+
ValueError,
116+
match="Conflicting proxy settings: client_configuration.proxy=http://not-env-proxy.com, "
117+
"but the environment variable 'OPENSHIFT_PYTHON_WRAPPER_CLIENT_USE_PROXY' defines proxy as http://env-proxy.com.",
118+
):
119+
get_client(client_configuration=client_configuration)

0 commit comments

Comments
 (0)