From a168ce9d8f90470b80ae265021bfdd7570bef530 Mon Sep 17 00:00:00 2001 From: Devaev Maxim Date: Thu, 11 Apr 2019 05:36:38 +0300 Subject: better auth testing --- kvmd/plugins/auth/http.py | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) (limited to 'kvmd/plugins/auth') diff --git a/kvmd/plugins/auth/http.py b/kvmd/plugins/auth/http.py index 16c6500d..18ecaae6 100644 --- a/kvmd/plugins/auth/http.py +++ b/kvmd/plugins/auth/http.py @@ -46,7 +46,6 @@ class Plugin(BaseAuthService): self, url: str, verify: bool, - post: bool, user: str, passwd: str, timeout: float, @@ -54,7 +53,6 @@ class Plugin(BaseAuthService): self.__url = url self.__verify = verify - self.__post = post self.__user = user self.__passwd = passwd self.__timeout = timeout @@ -64,31 +62,29 @@ class Plugin(BaseAuthService): @classmethod def get_options(cls) -> Dict[str, Option]: return { - "url": Option("http://localhost/auth_post"), + "url": Option("http://localhost/auth"), "verify": Option(True, type=valid_bool), - "post": Option(True, type=valid_bool), "user": Option(""), "passwd": Option(""), "timeout": Option(5.0, type=valid_float_f01), } async def login(self, user: str, passwd: str) -> bool: - kwargs: Dict = { - "method": "GET", - "url": self.__url, - "timeout": self.__timeout, - "headers": { - "User-Agent": "KVMD/%s" % (__version__), - "X-KVMD-User": user, - }, - } - if self.__post: - kwargs["method"] = "POST" - kwargs["json"] = {"user": user, "passwd": passwd} - session = self.__ensure_session() try: - async with session.request(**kwargs) as response: + async with session.request( + method="POST", + url=self.__url, + timeout=self.__timeout, + json={ + "user": user, + "passwd": passwd + }, + headers={ + "User-Agent": "KVMD/%s" % (__version__), + "X-KVMD-User": user, + }, + ) as response: response.raise_for_status() assert response.status == 200 return True -- cgit v1.2.3