1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
import unittest
from unittest import mock
from ...authentication.social import Social
class TestSocial(unittest.TestCase):
@mock.patch("auth0.authentication.social.Social.post")
def test_login(self, mock_post):
s = Social("a.b.c", "cid")
s.login(access_token="atk", connection="conn")
args, kwargs = mock_post.call_args
self.assertEqual("https://a.b.c/oauth/access_token", args[0])
self.assertEqual(
kwargs["data"],
{
"client_id": "cid",
"access_token": "atk",
"connection": "conn",
"scope": "openid",
},
)
@mock.patch("auth0.authentication.social.Social.post")
def test_login_with_scope(self, mock_post):
s = Social("a.b.c", "cid")
s.login(
access_token="atk",
connection="conn",
scope="openid profile",
)
args, kwargs = mock_post.call_args
self.assertEqual("https://a.b.c/oauth/access_token", args[0])
self.assertEqual(
kwargs["data"],
{
"client_id": "cid",
"access_token": "atk",
"connection": "conn",
"scope": "openid profile",
},
)
|