Removed sensitive data from logging; 1 more test

This commit is contained in:
DarkCat09 2022-09-30 14:55:24 +04:00
parent 9ea8795bdb
commit 6b6e944d55
3 changed files with 36 additions and 9 deletions

View file

@ -42,7 +42,8 @@ disable=raw-checker-failed,
no-member,
too-many-arguments,
too-many-public-methods,
too-many-instance-attributes
too-many-instance-attributes,
too-many-locals
enable=c-extension-no-member

View file

@ -201,6 +201,7 @@ class AternosConnect:
old_cookies = self.session.cookies
self.session = CloudScraper()
self.session.cookies.update(old_cookies)
del old_cookies
params = params or {}
data = data or {}
@ -221,12 +222,22 @@ class AternosConnect:
reqcookies['ATERNOS_SESSION'] = self.atsession
del self.session.cookies['ATERNOS_SESSION']
reqcookies_dbg = {
k: str(v or '')[:3]
for k, v in reqcookies.items()
}
session_cookies_dbg = {
k: str(v or '')[:3]
for k, v in self.session.cookies.items()
}
logging.debug('Requesting(%s)%s', method, url)
logging.debug('headers=%s', headers)
logging.debug('params=%s', params)
logging.debug('data=%s', data)
logging.debug('req-cookies=%s', reqcookies)
logging.debug('session-cookies=%s', self.session.cookies)
logging.debug('req-cookies=%s', reqcookies_dbg)
logging.debug('session-cookies=%s', session_cookies_dbg)
if method == 'POST':
sendreq = partial(

View file

@ -1,4 +1,5 @@
import unittest
from typing import Optional
from python_aternos import Client
@ -9,6 +10,10 @@ AUTH_MD5 = '0efdb2cd6b36d5e54d0e3c161e567a4e'
class TestLogin(unittest.TestCase):
def setUp(self) -> None:
self.at: Optional[Client] = None
def test_md5(self) -> None:
self.assertEqual(
@ -18,22 +23,32 @@ class TestLogin(unittest.TestCase):
def test_auth(self) -> None:
at = Client.from_hashed(AUTH_USER, AUTH_MD5)
self.assertIsNotNone(at)
self.at = Client.from_hashed(AUTH_USER, AUTH_MD5)
self.assertIsNotNone(self.at)
def test_servers(self) -> None:
at = Client.from_hashed(
AUTH_USER, AUTH_MD5
)
if self.at is None:
self.at = Client.from_hashed(
AUTH_USER, AUTH_MD5
)
srvs = len(
at.list_servers(
self.at.list_servers(
cache=False
)
)
self.assertTrue(srvs > 0)
def test_logout(self) -> None:
if self.at is None:
self.at = Client.from_hashed(
AUTH_USER, AUTH_MD5
)
self.at.logout()
if __name__ == '__main__':
unittest.main()