| 1 |
from http import HTTPStatus |
| 2 |
|
| 3 |
from django.test import TestCase |
| 4 |
|
| 5 |
from allauth.socialaccount.providers.yandex.provider import YandexProvider |
| 6 |
from tests.apps.socialaccount.base import OAuth2TestsMixin |
| 7 |
from tests.mocking import MockedResponse |
| 8 |
|
| 9 |
|
| 10 |
class YandexTests(OAuth2TestsMixin, TestCase): |
| 11 |
provider_id = YandexProvider.id |
| 12 |
|
| 13 |
yandex_data = """ |
| 14 |
{ |
| 15 |
"login": "vasya", |
| 16 |
"old_social_login": "uid-mmzxrnry", |
| 17 |
"default_email": "[email protected]", |
| 18 |
"id": "1000034426", |
| 19 |
"client_id": "4760187d81bc4b7799476b42b5103713", |
| 20 |
"emails": [ |
| 21 |
"[email protected]", |
| 22 |
"[email protected]" |
| 23 |
], |
| 24 |
"openid_identities": [ |
| 25 |
"http://openid.yandex.ru/vasya/", |
| 26 |
"http://vasya.ya.ru/" |
| 27 |
] |
| 28 |
}""" |
| 29 |
|
| 30 |
def get_mocked_response(self, data=None): |
| 31 |
if data is None: |
| 32 |
data = self.yandex_data |
| 33 |
return MockedResponse(HTTPStatus.OK, data) |
| 34 |
|
| 35 |
def get_expected_to_str(self): |
| 36 |
return "[email protected]" |
| 37 |
|
| 38 |
def get_login_response_json(self, with_refresh_token=True): |
| 39 |
return """ |
| 40 |
{ |
| 41 |
"access_token":"testac", |
| 42 |
"refresh_token":"1:GN686QVt0mmakDd9:A4pYuW9LGk0_UnlrMIWklk", |
| 43 |
"token_type":"bearer", |
| 44 |
"expires_in":124234123534 |
| 45 |
}""" |