Skip to content

tests: isolate FromContextTest from ambient TLS env vars - #3431

Merged
vvoland merged 1 commit into
docker:mainfrom
ricardobranco777:dockertls
Sep 14, 2026
Merged

vvoland merged 1 commit into
docker:mainfrom
ricardobranco777:dockertls

Conversation

@ricardobranco777

@ricardobranco777 ricardobranco777 commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

DOCKER_TLS_VERIFY/DOCKER_CERT_PATH leaking from the host running the tests (e.g. openQA) broke from_env()'s base_url scheme and caused TLSParameterError. Pop both in setUp alongside DOCKER_HOST, etc.

Otherwise tests fail on openQA:
https://openqa.opensuse.org/tests/6180415

# Test messages # test_from_env_docker_host_overrides_context
# failure: 

AssertionError: assert 'https://192.168.59.103:2375' == 'http://192.168.59.103:2375'
  
  - http://192.168.59.103:2375
  + https://192.168.59.103:2375
  ?     +
tests/unit/client_test.py:302: in test_from_env_docker_host_overrides_context
    assert client.api.base_url == 'http://192.168.59.103:2375'
E   AssertionError: assert 'https://192.168.59.103:2375' == 'http://192.168.59.103:2375'
E     
E     - http://192.168.59.103:2375
E     + https://192.168.59.103:2375
E     ?     +
# Test messages # test_from_env_use_context_false_skips_context
# failure: 

docker.errors.TLSParameterError: If using TLS, the base_url argument must be provided.. TLS configurations should map the Docker CLI client configurations. See https://docs.docker.com/engine/articles/https/ for API details.
tests/unit/client_test.py:308: in test_from_env_use_context_false_skips_context
    client = docker.from_env(
docker/client.py:110: in from_env
    return cls(
docker/client.py:48: in __init__
    self.api = APIClient(*args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^
docker/api/client.py:123: in __init__
    raise TLSParameterError(
E   docker.errors.TLSParameterError: If using TLS, the base_url argument must be provided.. TLS configurations should map the Docker CLI client configurations. See https://docs.docker.com/engine/articles/https/ for API details.

DOCKER_TLS_VERIFY/DOCKER_CERT_PATH leaking from the host running the
tests (e.g. openQA) broke from_env()'s base_url scheme and caused
TLSParameterError. Pop both in setUp alongside DOCKER_HOST, etc.

Signed-off-by: Ricardo Branco <rbranco@suse.de>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The focused environment cleanup correctly addresses the reported test failures and is restored during teardown.

Pull request overview

Isolates FromContextTest from host TLS environment variables to prevent environment-dependent failures.

Changes:

  • Clears DOCKER_CERT_PATH and DOCKER_TLS_VERIFY during context tests.
  • Documents why Docker environment variables are removed.
File summaries
File Description
tests/unit/client_test.py Prevents ambient TLS settings from affecting context tests.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 0
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@vvoland
vvoland merged commit 9ea965b into docker:main Sep 14, 2026
16 checks passed
@ricardobranco777
ricardobranco777 deleted the dockertls branch September 14, 2026 19:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants