| 1 |
from django.test import TestCase |
| 2 |
|
| 3 |
from allauth.socialaccount.providers.feishu.provider import FeishuProvider |
| 4 |
from tests.apps.socialaccount.base import OAuth2TestsMixin |
| 5 |
from tests.mocking import MockedResponse |
| 6 |
|
| 7 |
|
| 8 |
class FeishuTests(OAuth2TestsMixin, TestCase): |
| 9 |
provider_id = FeishuProvider.id |
| 10 |
|
| 11 |
def get_mocked_response(self): |
| 12 |
return [ |
| 13 |
MockedResponse( |
| 14 |
0, |
| 15 |
""" |
| 16 |
{"data": {"access_token": "testac"}} |
| 17 |
""", |
| 18 |
), |
| 19 |
MockedResponse( |
| 20 |
0, |
| 21 |
""" |
| 22 |
{ |
| 23 |
"code": 0, |
| 24 |
"data": { |
| 25 |
"access_token": "u-6U1SbDiM6XIH2DcTCPyeub", |
| 26 |
"avatar_url": "www.feishu.cn/avatar/icon", |
| 27 |
"avatar_thumb": "www.feishu.cn/avatar/icon_thumb", |
| 28 |
"avatar_middle": "www.feishu.cn/avatar/icon_middle", |
| 29 |
"avatar_big": "www.feishu.cn/avatar/icon_big", |
| 30 |
"expires_in": 7140, |
| 31 |
"name": "zhangsan", |
| 32 |
"en_name": "Three Zhang", |
| 33 |
"open_id": "ou-caecc734c2e3328a62489fe0648c4b98779515d3", |
| 34 |
"tenant_key": "736588c92lxf175d", |
| 35 |
"refresh_expires_in": 2591940, |
| 36 |
"refresh_token": "ur-t9HHgRCjMqGqIU9v05Zhos", |
| 37 |
"token_type": "Bearer" |
| 38 |
} |
| 39 |
} |
| 40 |
""", |
| 41 |
), |
| 42 |
] |
| 43 |
|
| 44 |
def get_expected_to_str(self): |
| 45 |
return "zhangsan" |
| 46 |
|
| 47 |
def get_login_response_json(self, with_refresh_token=True): |
| 48 |
return """{"app_access_token":"testac"}""" |