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