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, no-member,
too-many-arguments, too-many-arguments,
too-many-public-methods, too-many-public-methods,
too-many-instance-attributes too-many-instance-attributes,
too-many-locals
enable=c-extension-no-member enable=c-extension-no-member

View file

@ -201,6 +201,7 @@ class AternosConnect:
old_cookies = self.session.cookies old_cookies = self.session.cookies
self.session = CloudScraper() self.session = CloudScraper()
self.session.cookies.update(old_cookies) self.session.cookies.update(old_cookies)
del old_cookies
params = params or {} params = params or {}
data = data or {} data = data or {}
@ -221,12 +222,22 @@ class AternosConnect:
reqcookies['ATERNOS_SESSION'] = self.atsession reqcookies['ATERNOS_SESSION'] = self.atsession
del self.session.cookies['ATERNOS_SESSION'] 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('Requesting(%s)%s', method, url)
logging.debug('headers=%s', headers) logging.debug('headers=%s', headers)
logging.debug('params=%s', params) logging.debug('params=%s', params)
logging.debug('data=%s', data) logging.debug('data=%s', data)
logging.debug('req-cookies=%s', reqcookies) logging.debug('req-cookies=%s', reqcookies_dbg)
logging.debug('session-cookies=%s', self.session.cookies) logging.debug('session-cookies=%s', session_cookies_dbg)
if method == 'POST': if method == 'POST':
sendreq = partial( sendreq = partial(

View file

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