|
1 | 1 | from itertools import product |
2 | | -import os.path |
3 | | -import unittest |
| 2 | +from pathlib import Path |
4 | 3 |
|
5 | 4 | from defusedxml import ElementTree as ET |
6 | 5 | import pytest |
|
11 | 10 |
|
12 | 11 | from . import _utils |
13 | 12 |
|
14 | | -from . import _utils |
15 | | - |
16 | 13 | TEST_ASSET_DIR = Path(__file__).parent / "assets" |
17 | 14 |
|
18 | 15 | GET_XML = TEST_ASSET_DIR / "site_get.xml" |
@@ -273,16 +270,40 @@ def test_encrypt(server: TSC.Server) -> None: |
273 | 270 | server.sites.encrypt_extracts("0626857c-1def-4503-a7d8-7907c3ff9d9f") |
274 | 271 |
|
275 | 272 |
|
276 | | - assert configs[0].auth_setting == "OIDC" |
277 | | - assert configs[0].enabled |
278 | | - assert configs[0].idp_configuration_id == "00000000-0000-0000-0000-000000000000" |
279 | | - assert configs[0].idp_configuration_name == "Initial Salesforce" |
280 | | - assert configs[0].known_provider_alias == "Salesforce" |
281 | | - assert configs[1].auth_setting == "SAML" |
282 | | - assert configs[1].enabled |
283 | | - assert configs[1].idp_configuration_id == "11111111-1111-1111-1111-111111111111" |
284 | | - assert configs[1].idp_configuration_name == "Initial SAML" |
285 | | - assert configs[1].known_provider_alias is None |
| 273 | +def test_recrypt(server: TSC.Server) -> None: |
| 274 | + with requests_mock.mock() as m: |
| 275 | + m.post(server.sites.baseurl + "/0626857c-1def-4503-a7d8-7907c3ff9d9f/reencrypt-extracts", status_code=200) |
| 276 | + server.sites.re_encrypt_extracts("0626857c-1def-4503-a7d8-7907c3ff9d9f") |
| 277 | + |
| 278 | + |
| 279 | +def test_decrypt(server: TSC.Server) -> None: |
| 280 | + with requests_mock.mock() as m: |
| 281 | + m.post(server.sites.baseurl + "/0626857c-1def-4503-a7d8-7907c3ff9d9f/decrypt-extracts", status_code=200) |
| 282 | + server.sites.decrypt_extracts("0626857c-1def-4503-a7d8-7907c3ff9d9f") |
| 283 | + |
| 284 | + |
| 285 | +def test_list_auth_configurations(server: TSC.Server) -> None: |
| 286 | + server.version = "3.24" |
| 287 | + response_xml = SITE_AUTH_CONFIG_XML.read_text() |
| 288 | + |
| 289 | + assert server.sites.baseurl == server.sites.baseurl |
| 290 | + |
| 291 | + with requests_mock.mock() as m: |
| 292 | + m.get(f"{server.sites.baseurl}/{server.site_id}/site-auth-configurations", status_code=200, text=response_xml) |
| 293 | + configs = server.sites.list_auth_configurations() |
| 294 | + |
| 295 | + assert len(configs) == 2, "Expected 2 auth configurations" |
| 296 | + |
| 297 | + assert configs[0].auth_setting == "OIDC" |
| 298 | + assert configs[0].enabled |
| 299 | + assert configs[0].idp_configuration_id == "00000000-0000-0000-0000-000000000000" |
| 300 | + assert configs[0].idp_configuration_name == "Initial Salesforce" |
| 301 | + assert configs[0].known_provider_alias == "Salesforce" |
| 302 | + assert configs[1].auth_setting == "SAML" |
| 303 | + assert configs[1].enabled |
| 304 | + assert configs[1].idp_configuration_id == "11111111-1111-1111-1111-111111111111" |
| 305 | + assert configs[1].idp_configuration_name == "Initial SAML" |
| 306 | + assert configs[1].known_provider_alias is None |
286 | 307 |
|
287 | 308 |
|
288 | 309 | @pytest.mark.parametrize("capture", [True, False, None]) |
|
0 commit comments