### Install scim2-tester via pip Source: https://github.com/python-scim/scim2-tester/blob/main/README.md The installation command for the scim2-tester library. This command fetches the package from the Python Package Index (PyPI). ```shell pip install scim2-tester ``` -------------------------------- ### Run SCIM tests via CLI Source: https://github.com/python-scim/scim2-tester/blob/main/doc/tutorial.rst Demonstrates how to install the CLI tool and execute the test suite against a target SCIM server. ```console pip install scim2-cli export SCIM_CLI_URL="https://auth.example" scim test ``` -------------------------------- ### Install SCIM2 Tester Source: https://context7.com/python-scim/scim2-tester/llms.txt Installs the SCIM2 Tester library using pip. Includes an optional extra for httpx support. ```bash pip install scim2-tester ``` ```bash pip install scim2-tester[httpx] ``` -------------------------------- ### Integrate SCIM Tester into Unit Test Suite with Werkzeug Source: https://context7.com/python-scim/scim2-tester/llms.txt Integrate scim2-tester into your unit test suite using the Werkzeug test client. This method allows for direct testing of your SCIM server without making actual HTTP requests, making tests faster and more reliable. The example demonstrates setting up a test client and running compliance checks. ```python import pytest from scim2_client.engines.werkzeug import TestSCIMClient from scim2_tester import check_server, Status from werkzeug.test import Client from myapp import create_app def test_scim_compliance(): """Test SCIM server compliance.""" app = create_app(test_config=True) testclient = Client(app) scim_client = TestSCIMClient(app=testclient, scim_prefix="/scim/v2") # Run all checks with exception raising for test failures results = check_server(scim_client, raise_exceptions=True) # Verify all results are successful or skipped for result in results: assert result.status in (Status.SUCCESS, Status.SKIPPED), \ f"Check failed: {result.title} - {result.reason}" ``` -------------------------------- ### Get Standard SCIM Resource Types with get_standard_resource_types Source: https://context7.com/python-scim/scim2-tester/llms.txt The `get_standard_resource_types()` function returns a list of standard SCIM resource types, typically 'User' and 'Group'. This function is useful for setting up parametrized tests to specifically target and validate these common resource types. ```python from scim2_tester import get_standard_resource_types, Status # Get standard resource types resource_types = get_standard_resource_types() print(resource_types) # Output: ['User', 'Group'] # Test each resource type individually for rt in get_standard_resource_types(): results = check_server(client, resource_types=[rt]) success_count = sum(1 for r in results if r.status == Status.SUCCESS) print(f"{rt}: {success_count} successful checks") ``` -------------------------------- ### Integrate scim2-tester in Python Source: https://github.com/python-scim/scim2-tester/blob/main/doc/tutorial.rst Shows how to initialize a SyncSCIMClient and run the server check programmatically. ```python from httpx import Client from scim2_client.engines.httpx import SyncSCIMClient from scim2_tester import check_server httpx_client = Client( base_url="https://auth.example/scim/v2", headers={"Authorization": "Bearer foobar"}, ) scim_client = SyncSCIMClient(httpx_client) results = check_server(scim_client) for result in results: print(result.status.name, result.title) ``` -------------------------------- ### Run SCIM Compliance Tests with check_server Source: https://context7.com/python-scim/scim2-tester/llms.txt Demonstrates the primary function `check_server` for running SCIM compliance tests. It initializes a SCIM client and processes the structured results. ```python from httpx import Client from scim2_client.engines.httpx import SyncSCIMClient from scim2_tester import check_server, Status # Initialize SCIM client with authentication httpx_client = Client( base_url="https://auth.example/scim/v2", headers={"Authorization": "Bearer your-access-token"}, ) scim_client = SyncSCIMClient(httpx_client) # Run all compliance tests results = check_server(scim_client) # Process results for result in results: print(f"{result.status.name}: {result.title}") if result.status == Status.ERROR: print(f" Reason: {result.reason}") print(f" Resource Type: {result.resource_type}") # Output: # SUCCESS: service_provider_config_endpoint # SUCCESS: query_all_resource_types # SUCCESS: object_creation # SUCCESS: object_query # ... ``` -------------------------------- ### Test SCIM Discovery Endpoints with Python Source: https://context7.com/python-scim/scim2-tester/llms.txt This snippet demonstrates how to test SCIM discovery endpoints like ServiceProviderConfig, ResourceTypes, and Schemas. It iterates through the results, printing the status and relevant data for each endpoint. Dependencies include the scim2_tester library and an initialized client. ```python results = check_server(client, include_tags={"discovery"}) for result in results: if "service_provider_config" in result.title: print(f"ServiceProviderConfig: {result.status.name}") if result.data: print(f" PATCH supported: {result.data.patch.supported}") print(f" Bulk supported: {result.data.bulk.supported}") elif "resource_types" in result.title: print(f"ResourceTypes: {result.status.name}") if result.data: for rt in result.data: print(f" - {rt.name}: {rt.endpoint}") elif "schemas" in result.title: print(f"Schemas: {result.status.name}") ``` -------------------------------- ### Integrate with Werkzeug unit tests Source: https://github.com/python-scim/scim2-tester/blob/main/doc/tutorial.rst Demonstrates testing a local application without HTTP requests using the TestSCIMClient engine. ```console uv add --group dev scim2-models[werkzeug] ``` ```python from scim2_client.engines.werkzeug import TestSCIMClient from scim2_tester import check_server from werkzeug.test import Client from myapp import create_app def test_scim_tester(): app = create_app(...) testclient = Client(app) client = TestSCIMClient(app=testclient, scim_prefix="/scim/v2") check_server(client, raise_exceptions=True) ``` -------------------------------- ### SCIM2 Tester - Main Compliance Testing Function Source: https://context7.com/python-scim/scim2-tester/llms.txt The `check_server` function is the primary entry point for running SCIM compliance tests against a server. It performs discovery, CRUD operations, and PATCH operations on all available resource types, returning structured results for each check. ```APIDOC ## check_server - Main Compliance Testing Function ### Description The primary entry point for running SCIM compliance tests against a server. It performs discovery, CRUD operations, and PATCH operations on all available resource types, returning structured results for each check. ### Method ```python from httpx import Client from scim2_client.engines.httpx import SyncSCIMClient from scim2_tester import check_server, Status # Initialize SCIM client with authentication httpx_client = Client( base_url="https://auth.example/scim/v2", headers={"Authorization": "Bearer your-access-token"}, ) scim_client = SyncSCIMClient(httpx_client) # Run all compliance tests results = check_server(scim_client) # Process results for result in results: print(f"{result.status.name}: {result.title}") if result.status == Status.ERROR: print(f" Reason: {result.reason}") print(f" Resource Type: {result.resource_type}") # Output: # SUCCESS: service_provider_config_endpoint # SUCCESS: query_all_resource_types # SUCCESS: object_creation # SUCCESS: object_query # ... ``` ``` -------------------------------- ### Parametrized Testing with pytest using Available Tags and Resource Types Source: https://context7.com/python-scim/scim2-tester/llms.txt Utilize pytest's parametrization features with scim2-tester to conduct comprehensive testing. This involves using `get_all_available_tags()` and `get_standard_resource_types()` to dynamically generate test cases for various tag and resource type combinations, ensuring thorough validation of your SCIM server. ```python import pytest from scim2_tester import check_server, Status from scim2_tester import get_all_available_tags, get_standard_resource_types @pytest.fixture def scim_client(): # Setup your SCIM client here from httpx import Client from scim2_client.engines.httpx import SyncSCIMClient httpx_client = Client( base_url="https://auth.example/scim/v2", headers={"Authorization": "Bearer test-token"}, ) return SyncSCIMClient(httpx_client) @pytest.mark.parametrize("tag", get_all_available_tags()) @pytest.mark.parametrize("resource_type", [None] + get_standard_resource_types()) def test_individual_filters(scim_client, tag, resource_type): """Test each tag and resource type combination.""" results = check_server( scim_client, raise_exceptions=True, include_tags={tag}, resource_types=[resource_type] if resource_type else None ) for result in results: assert result.status in (Status.SUCCESS, Status.SKIPPED), \ f"Failed: {result.title} - {result.reason}" ``` -------------------------------- ### Validate SCIM Discovery Endpoints Source: https://context7.com/python-scim/scim2-tester/llms.txt This snippet demonstrates the initiation of tests for the mandatory SCIM discovery endpoints: ServiceProviderConfig, ResourceTypes, and Schemas. These tests are crucial for verifying the foundational discoverability and configuration of a SCIM 2.0 service. ```python from scim2_tester import check_server, Status ``` -------------------------------- ### Test SCIM PATCH Operations with Python Source: https://context7.com/python-scim/scim2-tester/llms.txt This Python code snippet tests SCIM PATCH operations, specifically add, remove, and replace. It utilizes the scim2_tester library to execute these tests and then aggregates and reports the compliance status (success, errors, skipped) for each type of PATCH operation. An initialized client and the scim2_tester library are necessary. ```python from scim2_tester import check_server, Status # Test all PATCH operations results = check_server( client, include_tags={"patch:add", "patch:remove", "patch:replace"} ) # Group results by PATCH operation type patch_results = {"add": [], "remove": [], "replace": []} for result in results: for op in patch_results.keys(): if f"patch:{op}" in result.tags: patch_results[op].append(result) break # Report PATCH operation compliance for op, op_results in patch_results.items(): success = sum(1 for r in op_results if r.status == Status.SUCCESS) errors = sum(1 for r in op_results if r.status == Status.ERROR) skipped = sum(1 for r in op_results if r.status == Status.SKIPPED) print(f"PATCH {op}: {success} success, {errors} errors, {skipped} skipped") # Show error details for r in op_results: if r.status == Status.ERROR: print(f" ERROR: {r.data.get('urn', 'unknown')} - {r.reason}") ``` -------------------------------- ### CLI Usage for SCIM2 Tester with scim2-cli Source: https://context7.com/python-scim/scim2-tester/llms.txt Interact with the scim2-tester functionality directly from the command line using the `scim2-cli` tool. This provides a convenient way to run compliance tests, filter tests by tags, exclude specific tests, and target particular resource types without writing Python code. ```bash # Install scim2-cli pip install scim2-cli # Set environment variables export SCIM_CLI_URL="https://auth.example/scim/v2" export SCIM_CLI_HEADERS='{"Authorization": "Bearer your-token"}' # Run all compliance tests scim test # Run specific test categories scim test --include-tags discovery scim test --include-tags crud --exclude-tags crud:delete # Test specific resource types scim test --resource-types User scim test --resource-types User,Group ``` -------------------------------- ### Filter tests by tags and resource types Source: https://github.com/python-scim/scim2-tester/blob/main/doc/tutorial.rst Explains how to use include_tags, exclude_tags, and resource_types to narrow down the scope of executed tests. ```python # Run only discovery tests results = check_server(client, include_tags={"discovery"}) # Run all CRUD operations except delete results = check_server( client, include_tags={"crud"}, exclude_tags={"crud:delete"} ) # Test only User resources results = check_server(client, resource_types=["User"]) # Test only User creation and reading results = check_server( client, include_tags={"crud:create", "crud:read"}, resource_types=["User"] ) ``` -------------------------------- ### Filter SCIM Tests by Resource Type Source: https://context7.com/python-scim/scim2-tester/llms.txt Demonstrates filtering SCIM compliance tests by specific resource types using the `resource_types` parameter in `check_server`. ```python from scim2_tester import check_server # Test only User resources results = check_server(client, resource_types=["User"]) # Test both User and Group resources results = check_server(client, resource_types=["User", "Group"]) # Combine with tag filtering: Test only User creation and reading results = check_server( client, include_tags={"crud:create", "crud:read"}, resource_types=["User"] ) ``` -------------------------------- ### Process SCIM CheckResult Objects Source: https://context7.com/python-scim/scim2-tester/llms.txt Illustrates how to iterate through `CheckResult` objects returned by `check_server` and interpret their status, title, reason, and other metadata. ```python from scim2_tester import check_server, Status results = check_server(client) for result in results: # Status indicates compliance level if result.status == Status.SUCCESS: print(f"PASS: {result.title}") elif result.status == Status.ERROR: print(f"FAIL: {result.title}") print(f" Reason: {result.reason}") print(f" Data: {result.data}") elif result.status == Status.SKIPPED: print(f"SKIP: {result.title} - {result.reason}") # Access additional metadata print(f" Tags: {result.tags}") print(f" Resource Type: {result.resource_type}") # Status enum values: # - SUCCESS: Server conforms to RFC requirements (MUST/MUST NOT) # - COMPLIANT: Server follows RFC recommendations (SHOULD/SHOULD NOT) # - ACCEPTABLE: RFC-compliant using optional features (MAY) ``` -------------------------------- ### Test SCIM CRUD Operations with Python Source: https://context7.com/python-scim/scim2-tester/llms.txt This code snippet validates Create, Read, Update, and Delete (CRUD) operations for SCIM resources. It uses the scim2_tester library to run tests tagged with 'crud' and then analyzes the results, reporting the success rate for each operation. It requires an initialized client and the scim2_tester library. ```python from scim2_tester import check_server, Status # Test all CRUD operations results = check_server(client, include_tags={"crud"}) # Analyze CRUD results by operation type crud_operations = { "create": [], "read": [], "update": [], "delete": [] } for result in results: for op in crud_operations.keys(): if f"crud:{op}" in result.tags or op in result.title.lower(): crud_operations[op].append(result) break for op, op_results in crud_operations.items(): success = sum(1 for r in op_results if r.status == Status.SUCCESS) total = len(op_results) print(f"{op.upper()}: {success}/{total} passed") ``` -------------------------------- ### Enable Exception Raising for Immediate Test Failure Source: https://context7.com/python-scim/scim2-tester/llms.txt Configure scim2-tester to raise exceptions upon encountering ERROR or CRITICAL results. This is particularly useful for CI/CD pipelines and automated test frameworks where immediate failure notification is crucial. The exceptions provide detailed context about the test failures. ```python from scim2_tester import check_server, SCIMTesterError # Raise exceptions on ERROR or CRITICAL results try: results = check_server(client, raise_exceptions=True) except SCIMTesterError as exc: print(f"Test failed: {exc.message}") # Exception includes context about the failure raise ``` -------------------------------- ### Filter SCIM Tests with Tags Source: https://context7.com/python-scim/scim2-tester/llms.txt Shows how to use `include_tags` and `exclude_tags` with `check_server` to selectively run tests based on hierarchical tags. ```python from scim2_tester import check_server # Run only discovery tests (ServiceProviderConfig, ResourceTypes, Schemas) results = check_server(client, include_tags={"discovery"}) # Run only CRUD tests results = check_server(client, include_tags={"crud"}) # Run all CRUD operations except delete results = check_server( client, include_tags={"crud"}, exclude_tags={"crud:delete"} ) # Run only resource creation and reading tests results = check_server(client, include_tags={"crud:create", "crud:read"}) # Run only PATCH add operations results = check_server(client, include_tags={"patch:add"}) # Available tags: # - discovery: All discovery endpoint tests # - service-provider-config: ServiceProviderConfig endpoint # - resource-types: ResourceTypes endpoint # - schemas: Schemas endpoint # - crud: All CRUD operations # - crud:create: Resource creation # - crud:read: Resource retrieval # - crud:update: Resource replacement (PUT) # - crud:delete: Resource deletion # - patch:add: PATCH add operations # - patch:remove: PATCH remove operations # - patch:replace: PATCH replace operations # - misc: Miscellaneous tests (random URL access) ``` -------------------------------- ### Test Individual Filters with Pytest Source: https://github.com/python-scim/scim2-tester/blob/main/doc/tutorial.rst This Python code snippet uses pytest to automatically test SCIM server filters. It discovers all available tags and standard resource types, then iterates through each combination to check server responses. The test ensures that each check_server call returns either a SKIPPED or SUCCESS status, indicating proper filter handling. ```python import pytest from scim2_tester import Status, check_server from scim2_tester.discovery import get_all_available_tags, get_standard_resource_types @pytest.mark.parametrize("tag", get_all_available_tags()) @pytest.mark.parametrize("resource_type", [None] + get_standard_resource_types()) def test_individual_filters(scim_client, tag, resource_type): for result in check_server( scim_client, raise_exceptions=True, include_tags={tag}, resource_types=resource_type ): assert result.status in (Status.SKIPPED, Status.SUCCESS) ``` -------------------------------- ### Discover Available Test Tags with get_all_available_tags Source: https://context7.com/python-scim/scim2-tester/llms.txt The `get_all_available_tags()` function retrieves all registered test tags used by the checker decorators. This is valuable for dynamically generating test suites, filtering tests, and documenting the available testing categories within the scim2-tester framework. ```python from scim2_tester import get_all_available_tags # Get all available tags for filtering tags = get_all_available_tags() print(tags) # Output: ['crud:create', 'crud:delete', 'crud:read', 'crud:update', # 'discovery', 'misc', 'patch:add', 'patch:remove', # 'patch:replace', 'resource-types', 'schemas', # 'service-provider-config'] # Use tags for dynamic test generation for tag in get_all_available_tags(): results = check_server(client, include_tags={tag}) print(f"Tag '{tag}': {len(results)} checks") ``` -------------------------------- ### SCIM2 Tester - Tag-Based Filtering Source: https://context7.com/python-scim/scim2-tester/llms.txt Filter which tests to run using hierarchical tags. Use `include_tags` to run only specific tests and `exclude_tags` to skip certain tests. Tags are hierarchical, so `crud` matches `crud:create`, `crud:read`, etc. ```APIDOC ## Tag-Based Filtering ### Description Filter which tests to run using hierarchical tags. Use `include_tags` to run only specific tests and `exclude_tags` to skip certain tests. Tags are hierarchical, so `crud` matches `crud:create`, `crud:read`, etc. ### Examples Run only discovery tests (ServiceProviderConfig, ResourceTypes, Schemas): ```python from scim2_tester import check_server results = check_server(client, include_tags={"discovery"}) ``` Run only CRUD tests: ```python results = check_server(client, include_tags={"crud"}) ``` Run all CRUD operations except delete: ```python results = check_server( client, include_tags={"crud"}, exclude_tags={"crud:delete"} ) ``` Run only resource creation and reading tests: ```python results = check_server(client, include_tags={"crud:create", "crud:read"}) ``` Run only PATCH add operations: ```python results = check_server(client, include_tags={"patch:add"}) ``` ### Available Tags - `discovery`: All discovery endpoint tests - `service-provider-config`: ServiceProviderConfig endpoint - `resource-types`: ResourceTypes endpoint - `schemas`: Schemas endpoint - `crud`: All CRUD operations - `crud:create`: Resource creation - `crud:read`: Resource retrieval - `crud:update`: Resource replacement (PUT) - `crud:delete`: Resource deletion - `patch:add`: PATCH add operations - `patch:remove`: PATCH remove operations - `patch:replace`: PATCH replace operations - `misc`: Miscellaneous tests (random URL access) ``` -------------------------------- ### SCIM2 Tester - CheckResult Structure Source: https://context7.com/python-scim/scim2-tester/llms.txt Each test returns a `CheckResult` object containing the test status, title, description, reason for the result, and optional debugging data. ```APIDOC ## CheckResult - Structured Test Results ### Description Each test returns a `CheckResult` object containing the test status, title, description, reason for the result, and optional debugging data. ### Example Usage ```python from scim2_tester import check_server, Status results = check_server(client) for result in results: # Status indicates compliance level if result.status == Status.SUCCESS: print(f"PASS: {result.title}") elif result.status == Status.ERROR: print(f"FAIL: {result.title}") print(f" Reason: {result.reason}") print(f" Data: {result.data}") elif result.status == Status.SKIPPED: print(f"SKIP: {result.title} - {result.reason}") # Access additional metadata print(f" Tags: {result.tags}") print(f" Resource Type: {result.resource_type}") ``` ### Status Enum Values - `SUCCESS`: Server conforms to RFC requirements (MUST/MUST NOT) - `COMPLIANT`: Server follows RFC recommendations (SHOULD/SHOULD NOT) - `ACCEPTABLE`: RFC-compliant using optional features (MAY) ``` -------------------------------- ### SCIM2 Tester - Resource Type Filtering Source: https://context7.com/python-scim/scim2-tester/llms.txt Filter tests by specific SCIM resource types using the `resource_types` parameter. This is useful for testing specific resources without running the full test suite. ```APIDOC ## Resource Type Filtering ### Description Filter tests by specific SCIM resource types using the `resource_types` parameter. This is useful for testing specific resources without running the full test suite. ### Examples Test only User resources: ```python from scim2_tester import check_server results = check_server(client, resource_types=["User"]) ``` Test both User and Group resources: ```python results = check_server(client, resource_types=["User", "Group"]) ``` Combine with tag filtering: Test only User creation and reading: ```python results = check_server( client, include_tags={"crud:create", "crud:read"}, resource_types=["User"] ) ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.