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 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
|
import unittest
from unittest import mock
from ...management.self_service_profiles import SelfServiceProfiles
class TestSelfServiceProfiles(unittest.TestCase):
def test_init_with_optionals(self):
t = SelfServiceProfiles(
domain="domain", token="jwttoken", telemetry=False, timeout=(10, 2)
)
self.assertEqual(t.client.options.timeout, (10, 2))
telemetry_header = t.client.base_headers.get("Auth0-Client", None)
self.assertEqual(telemetry_header, None)
@mock.patch("auth0.management.self_service_profiles.RestClient")
def test_all(self, mock_rc):
mock_instance = mock_rc.return_value
s = SelfServiceProfiles(domain="domain", token="jwttoken")
s.all()
mock_instance.get.assert_called_with(
"https://domain/api/v2/self-service-profiles",
params={"page": 0, "per_page": 25, "include_totals": "true"},
)
s.all(page=1, per_page=50, include_totals=False)
mock_instance.get.assert_called_with(
"https://domain/api/v2/self-service-profiles",
params={"page": 1, "per_page": 50, "include_totals": "false"},
)
@mock.patch("auth0.management.self_service_profiles.RestClient")
def test_create(self, mock_rc):
mock_instance = mock_rc.return_value
s = SelfServiceProfiles(domain="domain", token="jwttoken")
s.create({"name": "test"})
mock_instance.post.assert_called_with(
"https://domain/api/v2/self-service-profiles", data={"name": "test"}
)
@mock.patch("auth0.management.self_service_profiles.RestClient")
def test_get(self, mock_rc):
mock_instance = mock_rc.return_value
s = SelfServiceProfiles(domain="domain", token="jwttoken")
s.get("an-id")
mock_instance.get.assert_called_with(
"https://domain/api/v2/self-service-profiles/an-id"
)
@mock.patch("auth0.management.self_service_profiles.RestClient")
def test_delete(self, mock_rc):
mock_instance = mock_rc.return_value
s = SelfServiceProfiles(domain="domain", token="jwttoken")
s.delete("an-id")
mock_instance.delete.assert_called_with(
"https://domain/api/v2/self-service-profiles/an-id"
)
@mock.patch("auth0.management.self_service_profiles.RestClient")
def test_update(self, mock_rc):
mock_instance = mock_rc.return_value
s = SelfServiceProfiles(domain="domain", token="jwttoken")
s.update("an-id", {"a": "b", "c": "d"})
mock_instance.patch.assert_called_with(
"https://domain/api/v2/self-service-profiles/an-id",
data={"a": "b", "c": "d"},
)
@mock.patch("auth0.management.self_service_profiles.RestClient")
def test_get_custom_text(self, mock_rc):
mock_instance = mock_rc.return_value
s = SelfServiceProfiles(domain="domain", token="jwttoken")
s.get_custom_text("an-id", "en", "page")
mock_instance.get.assert_called_with(
"https://domain/api/v2/self-service-profiles/an-id/custom-text/en/page"
)
@mock.patch("auth0.management.self_service_profiles.RestClient")
def test_update_custom_text(self, mock_rc):
mock_instance = mock_rc.return_value
s = SelfServiceProfiles(domain="domain", token="jwttoken")
s.update_custom_text("an-id", "en", "page", {"a": "b", "c": "d"})
mock_instance.put.assert_called_with(
"https://domain/api/v2/self-service-profiles/an-id/custom-text/en/page",
data={"a": "b", "c": "d"},
)
@mock.patch("auth0.management.self_service_profiles.RestClient")
def test_create_sso_ticket(self, mock_rc):
mock_instance = mock_rc.return_value
s = SelfServiceProfiles(domain="domain", token="jwttoken")
s.create_sso_ticket("an-id", {"a": "b", "c": "d"})
mock_instance.post.assert_called_with(
"https://domain/api/v2/self-service-profiles/an-id/sso-ticket",
data={"a": "b", "c": "d"},
)
@mock.patch("auth0.management.self_service_profiles.RestClient")
def test_revoke_sso_ticket(self, mock_rc):
mock_instance = mock_rc.return_value
s = SelfServiceProfiles(domain="domain", token="jwttoken")
s.revoke_sso_ticket("an-id", "ticket-id")
mock_instance.post.assert_called_with(
"https://domain/api/v2/self-service-profiles/an-id/sso-ticket/ticket-id/revoke"
)
|