From 50c9cedc1438914ce21f85de8941a1b7b7a683ac Mon Sep 17 00:00:00 2001 From: jpic Date: Thu, 21 Sep 2023 12:44:33 +0200 Subject: [PATCH] Allow transport override on winrm backend --- doc/source/backends.rst | 1 + testinfra/backend/__init__.py | 1 + testinfra/backend/winrm.py | 3 ++- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/doc/source/backends.rst b/doc/source/backends.rst index 8a14c022..29746c26 100644 --- a/doc/source/backends.rst +++ b/doc/source/backends.rst @@ -178,6 +178,7 @@ The winrm backend uses `pywinrm `_:: $ py.test --hosts='winrm://Administrator:Password@127.0.0.1' $ py.test --hosts='winrm://vagrant@127.0.0.1:2200?no_ssl=true&no_verify_ssl=true' + $ py.test --hosts='winrm://vagrant@127.0.0.1:2200?no_ssl=true&no_verify_ssl=true&transport=plaintext' pywinrm's default read and operation timeout can be overridden using query arguments ``read_timeout_sec`` and ``operation_timeout_sec``:: diff --git a/testinfra/backend/__init__.py b/testinfra/backend/__init__.py index e8bdf91f..3fda5ac4 100644 --- a/testinfra/backend/__init__.py +++ b/testinfra/backend/__init__.py @@ -64,6 +64,7 @@ def parse_hostspec(hostspec: str) -> tuple[str, dict[str, Any]]: "controlpersist", "kubeconfig", "context", + "transport", ): if key in query: kw[key] = query[key][0] diff --git a/testinfra/backend/winrm.py b/testinfra/backend/winrm.py index f801f894..189e624b 100644 --- a/testinfra/backend/winrm.py +++ b/testinfra/backend/winrm.py @@ -56,6 +56,7 @@ def __init__( no_verify_ssl: bool = False, read_timeout_sec: Optional[int] = None, operation_timeout_sec: Optional[int] = None, + transport: str = None, *args: Any, **kwargs: Any, ): @@ -66,7 +67,7 @@ def __init__( self.host.name, ":{}".format(self.host.port) if self.host.port else "", ), - "transport": "ntlm", + "transport": transport or "ntlm", "username": self.host.user, "password": self.host.password, }