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
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,7 @@
import org.wso2.charon3.core.utils.codeutils.SearchRequest;

import java.io.IOException;
import java.util.ArrayList;
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?


import static org.wso2.charon3.core.schema.SCIMDefinitions.DataType.BINARY;
import static org.wso2.charon3.core.schema.SCIMDefinitions.DataType.BOOLEAN;
Expand Down Expand Up @@ -306,6 +303,15 @@ public <T extends AbstractSCIMObject> T decodeResource(String scimResourceString
//user may define the attribute by its fully qualified uri
attributeValObj = decodedJsonObj.opt(attributeSchema.getURI());
}
if (attributeValObj == null) {
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

attributeValObj = decodedJsonObj.get(key);
}
}
}
SCIMDefinitions.DataType attributeSchemaDataType = attributeSchema.getType();

if (attributeSchemaDataType.equals(STRING) || attributeSchemaDataType.equals(BINARY) ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

"}";
return new Object[][]{
{scimObjectString}
Expand Down