1
1
import asyncio
2
2
import json
3
3
from contextlib import contextmanager
4
+ from unittest import IsolatedAsyncioTestCase
5
+ from unittest .mock import patch
4
6
5
7
from aiohttp import web
6
8
from aiohttp .test_utils import (
7
9
TestClient as _TestClient , TestServer as _TestServer ,
8
10
)
9
- from asynctest import TestCase , patch
10
11
11
12
from .config_exception import ConfigException
12
13
from .openid import OpenIDRequestor
@@ -32,9 +33,7 @@ def respond_json(data):
32
33
@contextmanager
33
34
def working_client ():
34
35
loop = asyncio .get_event_loop ()
35
-
36
36
app = web .Application ()
37
-
38
37
app .router .add_get ('/.well-known/openid-configuration' , respond_json ({'token_endpoint' : '/token' }))
39
38
app .router .add_post ('/token' , respond_json ({'id-token' : 'id-token-data' , 'refresh-token' : 'refresh-token-data' }))
40
39
@@ -49,7 +48,6 @@ def working_client():
49
48
def fail_well_known_client ():
50
49
loop = asyncio .get_event_loop ()
51
50
app = web .Application ()
52
-
53
51
app .router .add_get ('/.well-known/openid-configuration' , make_responder (web .Response (status = 500 )))
54
52
55
53
with patch ('kubernetes_asyncio.config.openid.aiohttp.ClientSession' ) as _client_session :
@@ -62,7 +60,6 @@ def fail_well_known_client():
62
60
def fail_token_request_client ():
63
61
loop = asyncio .get_event_loop ()
64
62
app = web .Application ()
65
-
66
63
app .router .add_get ('/.well-known/openid-configuration' , respond_json ({'token_endpoint' : '/token' }))
67
64
app .router .add_post ('/token' , make_responder (web .Response (status = 500 )))
68
65
@@ -73,7 +70,7 @@ def fail_token_request_client():
73
70
yield client
74
71
75
72
76
- class OpenIDRequestorTest (TestCase ):
73
+ class OpenIDRequestorTest (IsolatedAsyncioTestCase ):
77
74
78
75
def setUp (self ):
79
76
self .requestor = OpenIDRequestor (
0 commit comments