File: test_social.py

package info (click to toggle)
auth0-python 4.13.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,280 kB
  • sloc: python: 8,933; makefile: 15; sh: 2
file content (46 lines) | stat: -rw-r--r-- 1,301 bytes parent folder | download
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",
            },
        )