python-scim / scim2-models

SCIM resources serialization and validation with Pydantic
https://scim2-models.readthedocs.io
Apache License 2.0
11 stars 3 forks source link

Implement `ListResponse` attributes inclusion and exclusion #59

Open azmeuk opened 4 months ago

azmeuk commented 4 months ago

It would be nice if ListResponse (and other subclasses of Message?) could correctly handle the attributes and excluded_attributes parameters, in the behalf of the resources they embed.

def test_attributes_inclusion():
    response = ListResponse.of(User)(
        resources=[
            User(id="user-id", user_name="user-name", display_name="display-name")
        ]
    )
    payload = response.model_dump(
        scim_ctx=Context.RESOURCE_QUERY_RESPONSE, attributes=["userName"]
    )
    assert payload == {
        "schemas": ["urn:ietf:params:scim:api:messages:2.0:ListResponse"],
        "Resources": [
            {
                "schemas": ["urn:ietf:params:scim:schemas:core:2.0:User"],
                "id": "user-id",
                "userName": "user-name",
            }
        ],
    }