From ae1a077dac6669c158c5f20a611c616cf778c7a8 Mon Sep 17 00:00:00 2001 From: npalaska Date: Wed, 8 Feb 2023 11:21:17 -0500 Subject: [PATCH] fix json import --- lib/pbench/client/oidc_admin.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/pbench/client/oidc_admin.py b/lib/pbench/client/oidc_admin.py index 800c43f012..6d60110848 100644 --- a/lib/pbench/client/oidc_admin.py +++ b/lib/pbench/client/oidc_admin.py @@ -1,3 +1,4 @@ +import json from typing import Dict, Optional, Union from urllib.parse import urljoin @@ -21,7 +22,7 @@ def _method( self, method: str, path: str, - data: Union[Dict, None], + data: Union[Dict, str, None], headers: Optional[Dict] = None, raise_error: bool = True, **kwargs, @@ -70,7 +71,11 @@ def get( return self._method("GET", path, None, headers=headers, **kwargs) def post( - self, path: str, data: Dict, headers: Optional[Dict] = None, **kwargs + self, + path: str, + data: Union[Dict, str], + headers: Optional[Dict] = None, + **kwargs, ) -> requests.Response: """POST wrapper to handle an authenticated POST operation on the Resource at a given path. @@ -120,7 +125,7 @@ def create_new_user( "Content-Type": "application/json", "Authorization": f"Bearer {admin_token}", } - json = { + data = { "username": username, "email": email, "emailVerified": True, @@ -131,7 +136,7 @@ def create_new_user( {"type": "password", "value": password, "temporary": False} ], } - response = self.post(path=url_path, data=json.dumps(json), headers=headers) + response = self.post(path=url_path, data=json.dumps(data), headers=headers) return response def user_login(