Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix UserProfile Custom Attributes casing #341

Merged
merged 5 commits into from
Feb 24, 2023

Conversation

justinabrokwah-okta
Copy link
Contributor

@justinabrokwah-okta justinabrokwah-okta commented Feb 15, 2023

Paginated results was re-formatting results before creating an object out of them to return through the method - in the case of user profile and custom attributes, custom attributes with a variable name starting with a capital letter, it would make the first letter lowercase instead

This PR removes that reformatting call thus resolving the issue

Used following code snippet to test and verify custom attributes are printed correctly:

# verify pagination issue is fixed
limit_params = {"limit": 1}
    users, resp, err = await okta_client.list_users(query_params=limit_params)
    for user in users:
        # print(user.id, user.profile.first_name, user.profile.last_name)
        print(user.profile)
    while resp.has_next():
        users, err = await resp.next()
        for user in users:
            # print(user.id, user.profile.first_name, user.profile.last_name)
            print(user.profile)

# verify issue is resolved in schema
user_schema, resp, err = await okta_client.get_user_schema('default')
    print(user_schema)

Comment on lines 139 to 138
result.append(
self._type(
APIClient.form_response_body(item)
)
)
result.append(self._type(item))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing the call to re-format the response body in the next() method which returns the paginated response

Also done like this in resource clients:
https://github.com/okta/okta-sdk-python/blob/master/okta/resource_clients/user_client.py#L112-L114

- To properly pick up $schema and _links in models that return them
- Prevent overriding custom fields if in response
@@ -67,7 +67,7 @@ async def get_application_user_schema(

try:
result = UserSchema(
self.form_response_body(response.get_body())
response.get_body()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not formatting the response body before creating the response in order to not change any custom attributes which may come through in here

@@ -494,3 +495,8 @@ function isUrnGrantType(grantType) {
function prefixUrnGrantType(grantType) {
return URN_PREFIX + URN_SUFFIXES[grantType];
}

const RESPONSE_MODELS_WITH_CUSTOM_ATTRIBUTES = ['User', 'Group', 'UserSchema', 'GroupSchema'];
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Applying logic to these models which have been reported to have issues with custom attributes

Copy link

@arvindkrishnakumar-okta arvindkrishnakumar-okta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@justinabrokwah-okta justinabrokwah-okta merged commit 9709e42 into master Feb 24, 2023
@bryanapellanes-okta bryanapellanes-okta deleted the jabro-okta-525328-custom-attribute-casing branch December 12, 2023 15:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants