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

PCS-2420: decode incoming requests independent of case of attribute n… #379

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

NilSper
Copy link

@NilSper NilSper commented Oct 17, 2022

Purpose

  • According to RFC7643 attribute names should be case insensitive. But charon only accepts name following its camel case scheme (e.g. userName instead of any other variant)

Goals

  • Requests should pass independent of the case of attribute names (e.g. USERNAME or Username should work too)

Approach

  • This PR converts attribute name of charon schema and request to lower case before it checks for matches. This is only done if the original checks failed as many users follow the camel case scheme of charon.

Release note

  • Charon becomes case insensitive for attribute names in requests according to SCIM guidelines.

Automation tests

  • Unit tests
    -> adjusted testGetUserNameErrorInGettingTheUsernameFromTheAnonymousRequest to only fail for wrong spelling of the attribute name and not for different case use.

@CLAassistant
Copy link

CLAassistant commented Oct 17, 2022

CLA assistant check
All committers have signed the CLA.

String attributeSchemaName = attributeSchema.getName().toLowerCase();
for (Iterator it = decodedJsonObj.keys(); it.hasNext(); ) {
String key = (String) it.next();
if (key.toLowerCase().equals(attributeSchemaName)) {
Copy link

@ionutned ionutned Oct 17, 2022

Choose a reason for hiding this comment

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

we could use key.equalsIgnoreCase()

Copy link
Author

Choose a reason for hiding this comment

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

Thanks for the hint. Changed it accordingly: 58677aa

@@ -1247,7 +1247,7 @@ public void testGetUserName(Object objectUser, String scimObjectString)
public Object[][] dataToTestGetUsernameErrorInGettingTheUsernameFromTheAnonymousRequest() {

String scimObjectString = "{\n" +
"UserName: John,\n" +
"UsrName: John,\n" +

Choose a reason for hiding this comment

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

This small change might be hard to notice by people looking at this test.

Copy link
Author

Choose a reason for hiding this comment

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

Thanks. 58677aa

@NilSper
Copy link
Author

NilSper commented Mar 17, 2023

@AnuradhaSK @VivekVinushanth what do I need to do to get a review from one of the owners?

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
Copy link
Contributor

Choose a reason for hiding this comment

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

Avoid * imports.
Import just only the required classes

Copy link
Author

Choose a reason for hiding this comment

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

Thanks. I changed that: f276f89

Copy link
Author

Choose a reason for hiding this comment

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

@AnuradhaSK am I ready to merge?

Copy link
Author

Choose a reason for hiding this comment

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

@AnuradhaSK am I still missing something?

@NilSper NilSper requested a review from AnuradhaSK March 20, 2023 10:17
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.

4 participants