http-misc 1.0.3__tar.gz → 1.0.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {http_misc-1.0.3 → http_misc-1.0.4}/PKG-INFO +1 -1
- {http_misc-1.0.3 → http_misc-1.0.4}/http_misc/cache.py +10 -5
- {http_misc-1.0.3 → http_misc-1.0.4}/http_misc.egg-info/PKG-INFO +1 -1
- {http_misc-1.0.3 → http_misc-1.0.4}/setup.py +1 -1
- {http_misc-1.0.3 → http_misc-1.0.4}/tests/test_transformers.py +1 -1
- {http_misc-1.0.3 → http_misc-1.0.4}/README.md +0 -0
- {http_misc-1.0.3 → http_misc-1.0.4}/http_misc/__init__.py +0 -0
- {http_misc-1.0.3 → http_misc-1.0.4}/http_misc/errors.py +0 -0
- {http_misc-1.0.3 → http_misc-1.0.4}/http_misc/http_utils.py +0 -0
- {http_misc-1.0.3 → http_misc-1.0.4}/http_misc/logger.py +0 -0
- {http_misc-1.0.3 → http_misc-1.0.4}/http_misc/retry_policy.py +0 -0
- {http_misc-1.0.3 → http_misc-1.0.4}/http_misc/services.py +0 -0
- {http_misc-1.0.3 → http_misc-1.0.4}/http_misc/transformers.py +0 -0
- {http_misc-1.0.3 → http_misc-1.0.4}/http_misc.egg-info/SOURCES.txt +0 -0
- {http_misc-1.0.3 → http_misc-1.0.4}/http_misc.egg-info/dependency_links.txt +0 -0
- {http_misc-1.0.3 → http_misc-1.0.4}/http_misc.egg-info/requires.txt +0 -0
- {http_misc-1.0.3 → http_misc-1.0.4}/http_misc.egg-info/top_level.txt +0 -0
- {http_misc-1.0.3 → http_misc-1.0.4}/setup.cfg +0 -0
- {http_misc-1.0.3 → http_misc-1.0.4}/tests/test_retry_policy.py +0 -0
- {http_misc-1.0.3 → http_misc-1.0.4}/tests/test_services.py +0 -0
|
@@ -4,7 +4,7 @@ from abc import abstractmethod, ABC
|
|
|
4
4
|
|
|
5
5
|
class TokenCache(ABC):
|
|
6
6
|
@abstractmethod
|
|
7
|
-
def set_token(self, cache_key: str, access_token: str, expires_in: datetime):
|
|
7
|
+
def set_token(self, cache_key: str, access_token: str, expires_in: datetime.datetime):
|
|
8
8
|
pass
|
|
9
9
|
|
|
10
10
|
@abstractmethod
|
|
@@ -17,9 +17,16 @@ class TokenCache(ABC):
|
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
class MemoryTokenCache(TokenCache):
|
|
20
|
-
""" Класс, реализующий хранение access_token в
|
|
20
|
+
""" Класс, реализующий хранение access_token в памяти.
|
|
21
|
+
Обратите внимание, что если ключом является client_id, то memory_cache не может быть одним на все запросы,
|
|
22
|
+
тк у разных запросов могут быть разные разрешения scopes
|
|
23
|
+
"""
|
|
21
24
|
|
|
22
|
-
|
|
25
|
+
# memory_cache = {}
|
|
26
|
+
def __init__(self):
|
|
27
|
+
self.memory_cache = {}
|
|
28
|
+
|
|
29
|
+
def set_token(self, cache_key: str, access_token: str, expires_in: datetime.datetime):
|
|
23
30
|
""" Установка токенов """
|
|
24
31
|
cache_value = {'access_token': access_token, 'expires_in': expires_in}
|
|
25
32
|
|
|
@@ -34,5 +41,3 @@ class MemoryTokenCache(TokenCache):
|
|
|
34
41
|
def remove(self, cache_key: str):
|
|
35
42
|
if cache_key in self.memory_cache:
|
|
36
43
|
self.memory_cache.pop(cache_key)
|
|
37
|
-
|
|
38
|
-
memory_cache = {}
|
|
@@ -23,7 +23,7 @@ async def test_set_system_oauth_token(mocker):
|
|
|
23
23
|
client_id='6x7ujMdws6tDLbpePzQZvkYd0yFADYNJ11putMRw',
|
|
24
24
|
client_secret='RgCUfgtFHxqZ2amnqS4eTFL6cRsdfc3YYN0lTBrAIarLrt0Icewv6QzC1nFZXusEjqpG0aFmC14f8Jme4z3Q4TpxI9UQM5aU5LQkvuKpOoZ3oF2wDlyC7J41zPGTYuhO',
|
|
25
25
|
scope='read write',
|
|
26
|
-
token_url='http://
|
|
26
|
+
token_url='http://localhost/api/v1/oauth/token/',
|
|
27
27
|
token_cache=cache.MemoryTokenCache())
|
|
28
28
|
|
|
29
29
|
request = {
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|