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

More issues like in #39 #45

Closed ccoors closed 5 months ago

ccoors commented 5 months ago

Hi,

I'm not sure the issue from #39 was fixed completely. This does not work - but I think it should?

user = User.model_validate({
    "username": "abc"
})
assert user.user_name == "abc"

Also, case sensitivity is not handled when passing attributes or excluded_attributes to model_dump - but it should be, according to RFC 7644, Section 3.10:

All facets (URN, attribute, and sub-attribute name) of the fully encoded attribute name are case insensitive.

So I would have expected this to work:

User[EnterpriseUser].model_validate({
    "userName": "abc",
    "displayName": "Barbara Jensen",
    "name": {
        "formatted": "Barbara Jensen",
    },
    "active": True,
    "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User": {
        "employeeNumber": "1234"
    }
}).model_dump(scim_ctx=Context.RESOURCE_QUERY_RESPONSE, attributes=[
    "displayname",
    "urn:IETF:params:scim:schemas:core:2.0:User:userName",
    "urn:IETF:params:scim:schemas:core:2.0:User:name.FORMATTED",
    "acTIVe",
    "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User:Employeenumber"
])

Maybe converting all the attributes to snake_case in the models isn't the best approach and they should be converted to all-lowercase instead?

azmeuk commented 5 months ago

Indeed I suppose all those case should be handled. Thank you for providing concrete test cases. I will look at it.

azmeuk commented 5 months ago

I just pushed a bunch of fixes on main about attributes case sensitivity. Please let me know if it looks good to you.

ccoors commented 5 months ago

Yes, that's looking good for now, thx!