Skip to content

Commit

Permalink
fix(jans-config-api): Fix to not update Metadata for PUT and PATCH ag…
Browse files Browse the repository at this point in the history
…ama endpoint (#2046)

* bug(jans-config-api): fixed swagger format issue

* fix(jans-config-api): fixed due to couchbase clustter change

* feat(jans-config-api): new endpoint to get UmaResource based on associatedClient

* fix(jans-config-api): swagger spec fix for client attributes

* fix(jans-config-api): reverted the local test properties

* test(jans-config-api): commented test case

* feat(jans-config-api): scim config endpoint enhancment

* feat(jans-config-api): swagger and DTO change for new fields for scim config endpoint

* feat(jans-config-api): swagger and DTO change for new fields for scim config endpoint

* fix(jans-config-api): rectified endpoint url in swagger spec for uma resource

* feat(jans-config-api): agama endpoint fixes

* fix(jans-config-api): agama endpoint enhancements

* fix(jans-config-api): fixed swagger spec for Uma Resource delete

* fix(jans-config-api): agama endpoint enhancements

* fix(jans-config-api): agama endpoint enhancements

* fix(jans-config-api): agama endpoint enhancements

* fix(jans-config-api): agama endpoint enhancements

* fix(jans-config-api): agama endpoint enhancements

* feat(jans-config-api): agama patch endpoint

* feat(jans-config-api): agama patch endpoint

* feat(jans-config-api): agama patch endpoint

* feat(jans-config-api): Scope object changes for creator details

* feat(jans-config-api): Scope object changes for creator details

* fix(jans-config-api): updated agama endpoint for exception handling and not updating metadata

* test(jans-config-api): updates user mgmt test case for POST
  • Loading branch information
pujavs committed Aug 9, 2022
1 parent 20f243d commit 8d7a369
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 223 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ Scenario: Create new user, patch and delete
And print result
And assert result != null
And assert result.customAttributes.length != null
Then def inum = funGetCustomAttributes(result.customAttributes,'inum')
#Then def inum = funGetCustomAttributes(result.customAttributes,'inum')
Then def inum = result.inum
And print inum
And assert inum != null
And print result.userId
Expand Down
Original file line number Diff line number Diff line change
@@ -1,41 +1,14 @@
{
"userId": "config_test_user_01",
"userId": "testUser4",
"customAttributes": [
{
"name": "birthdate",
"multiValued": false,
"values": [
"19830106010101.253Z"
"20001231041508.553Z"
],
"value": "19830106010101.253Z",
"displayValue": "19830106010101.253Z"
},
{
"name": "c",
"multiValued": false,
"values": [
"US"
],
"value": "US",
"displayValue": "US"
},
{
"name": "cn",
"multiValued": false,
"values": [
"Config Test User 01"
],
"value": "Config Test User 01",
"displayValue": "Config Test User 01"
},
{
"name": "displayName",
"multiValued": false,
"values": [
"Config Test User"
],
"value": "Config Test User 01",
"displayValue": "Config Test User 01"
"value": "20001231041508.553Z",
"displayValue": "20001231041508.553Z"
},
{
"name": "emailVerified",
Expand All @@ -47,212 +20,59 @@
"displayValue": "TRUE"
},
{
"name": "gender",
"multiValued": false,
"values": [
"Male"
],
"value": "Male",
"displayValue": "Male"
},
{
"name": "givenName",
"multiValued": false,
"values": [
"Test"
],
"value": "Test",
"displayValue": "Test"
},
{
"name": "jansPrefUsrName",
"name": "jansAdminUIRole",
"multiValued": false,
"values": [
"config_user_1"
"api-admin"
],
"value": "config_user_01",
"displayValue": "config_user_01"
},
{
"name": "jansStatus",
"multiValued": false,
"values": [
"active"
],
"value": "active",
"displayValue": "active"
},
{
"name": "l",
"multiValued": false,
"values": [
"Austin"
],
"value": "Austin",
"displayValue": "Austin"
},
{
"name": "locale",
"multiValued": false,
"values": [
"en-US"
],
"value": "en-US",
"displayValue": "en-US"
},
{
"name": "mail",
"multiValued": false,
"values": [
"config_user_01@test.org"
],
"value": "config_user_01@test.org",
"displayValue": "config_user_01@test.org"
"value": "api-admin",
"displayValue": "api-admin"
},
{
"name": "memberOf",
"multiValued": true,
"values": [
"inum=7890,ou=groups,o=jans",
"inum=7891,ou=groups,o=jans"
],
"value": "inum=7890,ou=groups,o=jans",
"displayValue": "inum=7890,ou=groups,o=jans, inum=7891,ou=groups,o=jans"
},
{
"name": "middleName",
"multiValued": false,
"values": [
"config_user_01"
"inum=60B7,ou=groups,o=jans"
],
"value": "config_user_01",
"displayValue": "config_user_01"
"value": "inum=60B7,ou=groups,o=jans",
"displayValue": "inum=60B7,ou=groups,o=jans"
},
{
"name": "mobile",
"name": "middleName",
"multiValued": false,
"values": [
"(512) 516-2414"
"Test USer 4"
],
"value": "(512) 516-2414",
"displayValue": "(512) 516-2414"
"value": "Test USer 4",
"displayValue": "Test USer 4"
},
{
"name": "nickname",
"multiValued": false,
"values": [
"user1"
"Test USer 4"
],
"value": "user01",
"displayValue": "user01"
},
{
"name": "o",
"multiValued": false,
"values": [
"Test"
],
"value": "Test",
"displayValue": "Test"
},
{
"name": "phoneNumberVerified",
"multiValued": false,
"values": [
"TRUE"
],
"value": "TRUE",
"displayValue": "TRUE"
},
{
"name": "picture",
"multiValued": false,
"values": [
"http://www.jans.org/wp-content/uploads/2012/04/mike3.png"
],
"value": "http://www.jans.org/wp-content/uploads/2012/04/mike3.png",
"displayValue": "http://www.jans.org/wp-content/uploads/2012/04/mike3.png"
},
{
"name": "preferredLanguage",
"multiValued": false,
"values": [
"en_US"
],
"value": "en_US",
"displayValue": "en_US"
},
{
"name": "profile",
"multiValued": false,
"values": [
"http://www.mywebsite.com/profile"
],
"value": "http://www.mywebsite.com/profile",
"displayValue": "http://www.mywebsite.com/profile"
"value": "Test USer 4",
"displayValue": "Test USer 4"
},
{
"name": "sn",
"multiValued": false,
"values": [
"User1"
],
"value": "User1",
"displayValue": "User1"
},
{
"name": "st",
"multiValued": false,
"values": [
"Texas"
],
"value": "Texas",
"displayValue": "Texas"
},
{
"name": "street",
"multiValued": false,
"values": [
"622 East 6th Street"
],
"value": "622 East 6th Street",
"displayValue": "622 East 6th Street"
},
{
"name": "telephoneNumber",
"multiValued": false,
"values": [
"(512) 516-2414"
],
"value": "(512) 516-2414",
"displayValue": "(512) 516-2414"
},
{
"name": "website",
"multiValued": false,
"values": [
"http://www.jans.io"
],
"value": "http://www.jans.io",
"displayValue": "http://www.jans.io"
},
{
"name": "zoneinfo",
"multiValued": false,
"values": [
"America/Chicago"
],
"value": "America/Chicago",
"displayValue": "America/Chicago"
},
{
"name": "userPassword",
"multiValued": false,
"values": [
"pwd123"
"User4"
],
"value": "pwd123",
"displayValue": "pwd123"
"value": "User4",
"displayValue": "User4"
}
]
}
],
"customObjectClasses": [
"top",
"jansCustomPerson"
],
"inum": "5dc28c49-efcc-4eef-9e54-834b910fb3d8",
"mail": "test4@jans.server2",
"displayName": "Default Test User",
"jansStatus": "active",
"userPassword": "pwd123",
"givenName": "Test4"
}
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public Response createFlow(@Valid Flow flow)
}

// validate flow data
updateFlowDetails(flow, null);
updateFlowDetails(flow, null, true);
validateAgamaFlowData(flow, true);
agamaFlowService.addAgamaFlow(flow);

Expand Down Expand Up @@ -135,7 +135,7 @@ public Response createFlowFromFile(@PathParam(ApiConstants.QNAME) @NotNull Strin
flow.setQname(decodedFlowName);
flow.setSource(source);
flow.setEnabled(true);
updateFlowDetails(flow, null);
updateFlowDetails(flow, null, true);

// validate flow data
validateAgamaFlowData(flow, true);
Expand All @@ -161,7 +161,7 @@ public Response updateFlow(@PathParam(ApiConstants.QNAME) @NotNull String flowNa

// set flow data
flow.setQname(decodedFlowName);
updateFlowDetails(flow, existingFlow);
updateFlowDetails(flow, existingFlow, false);
logger.debug("Flow revision after update - flow.getRevision():{}", flow.getRevision());

// validate flow data
Expand Down Expand Up @@ -192,7 +192,7 @@ public Response updateFlowFromFile(@PathParam(ApiConstants.QNAME) @NotNull Strin
if (existingFlow != null) {
existingFlow.setSource(source);

updateFlowDetails(existingFlow, existingFlow);
updateFlowDetails(existingFlow, existingFlow,false);

// validate flow data
validateAgamaFlowData(existingFlow, false);
Expand Down Expand Up @@ -225,8 +225,7 @@ public Response patchFlow(@PathParam(ApiConstants.QNAME) @NotNull String flowNam

existingFlow = Jackson.applyJsonPatch(jsonPatch, existingFlow);
logger.debug(" After patch flow:{}", existingFlow);
updateFlowDetails(existingFlow, existingFlow);


// validate flow data
validateAgamaFlowData(existingFlow, false);
logger.debug("Updating flow after validation");
Expand Down Expand Up @@ -300,6 +299,7 @@ private void validateSyntax(Flow flow) {
Transpiler.runSyntaxCheck(flow.getQname(), flow.getSource());
} catch (SyntaxException se) {
logger.error("Transpiler syntax check error", se);
se.setStackTrace(new StackTraceElement[0]);
try {
logger.debug("Throwing BadRequestException 400 :{} ", Jackson.asPrettyJson(se));
thorwBadRequestException(se);
Expand All @@ -309,6 +309,7 @@ private void validateSyntax(Flow flow) {
}
} catch (TranspilerException te) {
logger.error("Agama Flow transpiler exception", te);
te.setStackTrace(new StackTraceElement[0]);
thorwBadRequestException(te);
}
}
Expand All @@ -323,11 +324,13 @@ private String getURLDecodedValue(String pathParam) {
return pathParam;
}

private Flow updateFlowDetails(Flow flow, Flow existingFlow) {
logger.debug("Update Flow details - flow:{}, existingFlow:{}", flow, existingFlow);
private Flow updateFlowDetails(Flow flow, Flow existingFlow, boolean updateMetadata) {
logger.debug("Update Flow details - flow:{}, existingFlow:{}, updateMetadata:{}", flow, existingFlow, updateMetadata);

updateRevision(flow, existingFlow);
updateMetadata(flow);
if(updateMetadata) {
updateMetadata(flow);
}
return flow;
}

Expand Down

0 comments on commit 8d7a369

Please sign in to comment.