Debian Codegraph @

tests/authentication/test_passwordless.py

raw symbols SCIP
1 import unittest
2 from unittest import mock
3
4 from auth0.authentication.passwordless import Passwordless
5
6
7 class TestPasswordless(unittest.TestCase):
8 @mock.patch("auth0.authentication.rest.RestClient.post")
9 def test_send_email(self, mock_post):
10 p = Passwordless("my.domain.com", "cid")
11
12 p.email(email="[email protected]", send="snd")
13
14 args, kwargs = mock_post.call_args
15
16 self.assertEqual(args[0], "https://my.domain.com/passwordless/start")
17 self.assertEqual(
18 kwargs["data"],
19 {
20 "client_id": "cid",
21 "email": "[email protected]",
22 "send": "snd",
23 "connection": "email",
24 },
25 )
26
27 @mock.patch("auth0.authentication.rest.RestClient.post")
28 def test_send_email_with_auth_params(self, mock_post):
29 p = Passwordless("my.domain.com", "cid")
30
31 p.email(email="[email protected]", send="snd", auth_params={"a": "b"})
32
33 args, kwargs = mock_post.call_args
34
35 self.assertEqual(args[0], "https://my.domain.com/passwordless/start")
36 self.assertEqual(
37 kwargs["data"],
38 {
39 "client_id": "cid",
40 "email": "[email protected]",
41 "send": "snd",
42 "authParams": {"a": "b"},
43 "connection": "email",
44 },
45 )
46
47 @mock.patch("auth0.authentication.rest.RestClient.post")
48 def test_send_email_with_client_secret(self, mock_post):
49 p = Passwordless("my.domain.com", "cid", client_secret="csecret")
50
51 p.email(email="[email protected]", send="snd")
52
53 args, kwargs = mock_post.call_args
54
55 self.assertEqual(args[0], "https://my.domain.com/passwordless/start")
56 self.assertEqual(
57 kwargs["data"],
58 {
59 "client_id": "cid",
60 "client_secret": "csecret",
61 "email": "[email protected]",
62 "send": "snd",
63 "connection": "email",
64 },
65 )
66
67 @mock.patch("auth0.authentication.rest.RestClient.post")
68 def test_send_sms(self, mock_post):
69 p = Passwordless("my.domain.com", "cid")
70
71 p.sms(phone_number="123456")
72
73 args, kwargs = mock_post.call_args
74
75 self.assertEqual(args[0], "https://my.domain.com/passwordless/start")
76 self.assertEqual(
77 kwargs["data"],
78 {
79 "client_id": "cid",
80 "phone_number": "123456",
81 "connection": "sms",
82 },
83 )
84
85 @mock.patch("auth0.authentication.rest.RestClient.post")
86 def test_send_sms_with_client_secret(self, mock_post):
87 p = Passwordless("my.domain.com", "cid", client_secret="csecret")
88
89 p.sms(phone_number="123456")
90
91 args, kwargs = mock_post.call_args
92
93 self.assertEqual(args[0], "https://my.domain.com/passwordless/start")
94 self.assertEqual(
95 kwargs["data"],
96 {
97 "client_id": "cid",
98 "client_secret": "csecret",
99 "phone_number": "123456",
100 "connection": "sms",
101 },
102 )