Skip to content

Commit 835222e

Browse files
committed
Fix bytes vs str for sessionID
Signed-off-by: Justin Cinkelj <justin.cinkelj@xlab.si>
1 parent f0f92d5 commit 835222e

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

plugins/module_utils/client.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def __init__(
8484
self.timeout = timeout
8585
self.auth_method = auth_method
8686

87-
self._auth_header: Optional[dict[str, bytes]] = None
87+
self._auth_header: Optional[dict[str, str]] = None
8888
self._client = Request()
8989

9090
@classmethod
@@ -98,15 +98,15 @@ def get_client(cls, cluster_instance: TypedClusterInstance) -> Client:
9898
)
9999

100100
@property
101-
def auth_header(self) -> dict[str, bytes]:
101+
def auth_header(self) -> dict[str, str]:
102102
if not self._auth_header:
103103
self._auth_header = self._login()
104104
return self._auth_header
105105

106-
def _login(self) -> dict[str, bytes]:
106+
def _login(self) -> dict[str, str]:
107107
return self._login_username_password()
108108

109-
def _login_username_password(self) -> dict[str, bytes]:
109+
def _login_username_password(self) -> dict[str, str]:
110110
headers = {
111111
"Accept": "application/json",
112112
"Content-type": "application/json",

plugins/module_utils/typed_classes.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class TypedClusterInstance(TypedDict):
2121
username: str
2222
password: str
2323
timeout: float
24+
auth_method: str
2425

2526

2627
# Registration to ansible return dict.

tests/unit/plugins/module_utils/test_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def test_basic_auth(self, mocker):
9595
resp_mock = mocker.MagicMock()
9696
resp_mock.status = 200 # Used when testing on Python 3
9797
resp_mock.read.return_value = (
98-
'{"sessionID":"7e3a2a70-7130-41c4-9402-fc0953cc1d7b"}'
98+
'{"sessionID":"7e3a2a70-7130-41c4-9402-fc0953cc1d7b"}'.encode("utf-8")
9999
)
100100

101101
request_mock = mocker.patch.object(client, "Request").return_value

0 commit comments

Comments
 (0)