Skip to content

Commit 45b708e

Browse files
author
Nick Zetzl
committed
added tests
Signed-off-by: Nick Zetzl <[email protected]>
1 parent 0b01ca6 commit 45b708e

File tree

2 files changed

+97
-10
lines changed

2 files changed

+97
-10
lines changed

auth0/management/self_service_profiles.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def __init__(
4848

4949
def _url(self, profile_id: str | None = None) -> str:
5050
url = f"{self.protocol}://{self.domain}/api/v2/self-service-profiles"
51-
if id is not None:
51+
if profile_id is not None:
5252
return f"{url}/{profile_id}"
5353
return url
5454

auth0/test/management/test_self_service_profiles.py

Lines changed: 96 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,105 @@ def test_list(self, mock_rc):
2020
s = SelfServiceProfiles(domain="domain", token="jwttoken")
2121
s.list()
2222

23-
args, kwargs = mock_instance.get.call_args
24-
25-
self.assertEqual(args[0], "https://domain/api/v2/self-service-profiles")
26-
self.assertEqual(
27-
kwargs["params"], {"page": 0, "per_page": 25, "include_totals": "true"}
23+
mock_instance.get.assert_called_with(
24+
"https://domain/api/v2/self-service-profiles",
25+
params={"page": 0, "per_page": 25, "include_totals": "true"},
2826
)
2927

3028
s.list(page=1, per_page=50, include_totals=False)
3129

32-
args, kwargs = mock_instance.get.call_args
30+
mock_instance.get.assert_called_with(
31+
"https://domain/api/v2/self-service-profiles",
32+
params={"page": 1, "per_page": 50, "include_totals": "false"},
33+
)
34+
35+
@mock.patch("auth0.management.self_service_profiles.RestClient")
36+
def test_create(self, mock_rc):
37+
mock_instance = mock_rc.return_value
38+
39+
s = SelfServiceProfiles(domain="domain", token="jwttoken")
40+
s.create({"name": "test"})
41+
42+
mock_instance.post.assert_called_with(
43+
"https://domain/api/v2/self-service-profiles", data={"name": "test"}
44+
)
45+
46+
@mock.patch("auth0.management.self_service_profiles.RestClient")
47+
def test_get(self, mock_rc):
48+
mock_instance = mock_rc.return_value
49+
50+
s = SelfServiceProfiles(domain="domain", token="jwttoken")
51+
s.get("an-id")
52+
53+
mock_instance.get.assert_called_with(
54+
"https://domain/api/v2/self-service-profiles/an-id"
55+
)
56+
57+
@mock.patch("auth0.management.self_service_profiles.RestClient")
58+
def test_delete(self, mock_rc):
59+
mock_instance = mock_rc.return_value
60+
61+
s = SelfServiceProfiles(domain="domain", token="jwttoken")
62+
s.delete("an-id")
63+
64+
mock_instance.delete.assert_called_with(
65+
"https://domain/api/v2/self-service-profiles/an-id"
66+
)
67+
68+
@mock.patch("auth0.management.self_service_profiles.RestClient")
69+
def test_update(self, mock_rc):
70+
mock_instance = mock_rc.return_value
71+
72+
s = SelfServiceProfiles(domain="domain", token="jwttoken")
73+
s.update("an-id", {"a": "b", "c": "d"})
74+
75+
mock_instance.patch.assert_called_with(
76+
"https://domain/api/v2/self-service-profiles/an-id",
77+
data={"a": "b", "c": "d"},
78+
)
79+
80+
@mock.patch("auth0.management.self_service_profiles.RestClient")
81+
def test_get_custom_text(self, mock_rc):
82+
mock_instance = mock_rc.return_value
83+
84+
s = SelfServiceProfiles(domain="domain", token="jwttoken")
85+
s.get_custom_text("an-id", "en", "page")
86+
87+
mock_instance.get.assert_called_with(
88+
"https://domain/api/v2/self-service-profiles/an-id/custom-text/en/page"
89+
)
90+
91+
@mock.patch("auth0.management.self_service_profiles.RestClient")
92+
def test_update_custom_text(self, mock_rc):
93+
mock_instance = mock_rc.return_value
94+
95+
s = SelfServiceProfiles(domain="domain", token="jwttoken")
96+
s.update_custom_text("an-id", "en", "page", {"a": "b", "c": "d"})
97+
98+
mock_instance.put.assert_called_with(
99+
"https://domain/api/v2/self-service-profiles/an-id/custom-text/en/page",
100+
data={"a": "b", "c": "d"},
101+
)
102+
103+
@mock.patch("auth0.management.self_service_profiles.RestClient")
104+
def test_create_sso_ticket(self, mock_rc):
105+
mock_instance = mock_rc.return_value
106+
107+
s = SelfServiceProfiles(domain="domain", token="jwttoken")
108+
s.create_sso_ticket("an-id", {"a": "b", "c": "d"})
109+
110+
mock_instance.post.assert_called_with(
111+
"https://domain/api/v2/self-service-profiles/an-id/sso-ticket",
112+
data={"a": "b", "c": "d"},
113+
)
114+
115+
@mock.patch("auth0.management.self_service_profiles.RestClient")
116+
def test_revoke_sso_ticket(self, mock_rc):
117+
mock_instance = mock_rc.return_value
118+
119+
s = SelfServiceProfiles(domain="domain", token="jwttoken")
120+
s.revoke_sso_ticket("an-id", "ticket-id")
33121

34-
self.assertEqual(args[0], "https://domain/api/v2/self-service-profiles")
35-
self.assertEqual(
36-
kwargs["params"], {"page": 1, "per_page": 50, "include_totals": "false"}
122+
mock_instance.post.assert_called_with(
123+
"https://domain/api/v2/self-service-profiles/an-id/sso-ticket/ticket-id/revoke"
37124
)

0 commit comments

Comments
 (0)