citrix_hypervisor: apply tls_verify to XML-RPC session login - #24909
citrix_hypervisor: apply tls_verify to XML-RPC session login#24909ian28223 wants to merge 4 commits into
Conversation
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
🎉 All green!🧪 All tests passed 🎯 Code Coverage (details) 🔗 Commit SHA: 4789975 | Docs | View more details | Give us feedback! |
evalya-impact-summaryevalya impact analysis |
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 38896c9383
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| check.open_session() | ||
|
|
||
| _, kwargs = server_proxy.call_args | ||
| assert kwargs['context'].verify_mode == ssl.CERT_NONE |
There was a problem hiding this comment.
Verify the TLS login behavior instead
For the self-signed HTTPS scenario this regression test mocks ServerProxy and only inspects the constructed context, so it never verifies the behavior that matters: whether open_session() can complete an XML-RPC login with tls_verify=False. It could pass even if the transport failed to use the context, while also breaking after a behavior-preserving transport refactor; exercise an HTTPS XML-RPC endpoint with a self-signed certificate and assert the session succeeds instead.
AGENTS.md reference: AGENTS.md:L174-L180
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Good catch — replaced the mocked assertion with a real self-signed HTTPS XML-RPC server (the tls_xenserver fixture in conftest.py, following the same pattern as datadog_checks_base/tests/base/utils/http/test_http.py's openssl_https_server). Two tests now exercise the actual handshake: test_open_session_fails_on_self_signed_cert_by_default and test_open_session_succeeds_with_tls_verify_false. Verified both fail without the context=self.get_tls_context() fix (the "succeeds" test hits the real [SSL: CERTIFICATE_VERIFY_FAILED] error) and pass with it, in commit 4789975.
Replace the mocked ServerProxy assertion with a real self-signed HTTPS XML-RPC server, verifying open_session() actually fails by default and succeeds with tls_verify: false, per review feedback. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Validation ReportAll 21 validations passed. Show details
|
What does this PR do?
context=self.get_tls_context()to theServerProxyused for XenAPI session login inopen_session()tls_verify/tls_ca_certinstance config already used by the RRD metrics HTTP client, instead of always using Python's default verifying SSL contextMotivation
ServerProxy(self._base_url)ignored the instance'stls_verify: falsesetting entirely, since it never went throughself.http[SSL: CERTIFICATE_VERIFY_FAILED]on every check run even withtls_verify: falseset, producing noisy, misleading SSL warnings in the Agent logReview checklist (to be filled by reviewers)
qa/requiredif this PR needs QA validation, orqa/skip-qaif it does not. Exactly one of the two is required.backport/<branch-name>label to the PR and it will automatically open a backport PR once this one is merged