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

Adding AddHeader v2 policy with regular expression fix #13310

Merged
merged 1 commit into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
@@ -1,23 +1,23 @@
{
"category": "Mediation",
"name": "addHeader",
"version": "v1",
"version": "v2",
"displayName": "Add Header",
"description": "This policy allows you to add a new header to the request",
"policyAttributes": [
{
"name": "headerName",
"displayName": "Header Name",
"description": "Name of the header to be added",
"validationRegex": "^([a-zA-Z_][a-zA-Z\\d_\\-\\ ]*)$",
"validationRegex": "^.+$",
"type": "String",
"required": true
},
{
"name": "headerValue",
"displayName": "Header Value",
"description": "Value of the header",
"validationRegex": "^([a-zA-Z\\d_][a-zA-Z\\d_\\-\\ ]*)$",
"validationRegex": "^.+$",
"type": "String",
"required": true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -469,9 +469,12 @@ public void testAPIInvocationAfterAddingNewOperationPolicy() throws Exception {
attributeMap.put("headerName", "TestHeader");
attributeMap.put("headerValue", "TestValue");

List<OperationPolicyDTO> opList = getPolicyList(policyName, policyMap, attributeMap);
opList.get(0).setPolicyVersion("v2");

APIOperationPoliciesDTO apiOperationPoliciesDTO = new APIOperationPoliciesDTO();
apiOperationPoliciesDTO.setRequest(getPolicyList(policyName, policyMap, attributeMap));
apiOperationPoliciesDTO.setResponse(getPolicyList(policyName, policyMap, attributeMap));
apiOperationPoliciesDTO.setRequest(opList);
apiOperationPoliciesDTO.setResponse(opList);

apidto.getOperations().get(0).setOperationPolicies(apiOperationPoliciesDTO);
restAPIPublisher.updateAPI(apidto);
Expand Down Expand Up @@ -596,9 +599,11 @@ public void testAPIInvocationAfterAddingNewMultipleOperationPolicies() throws Ex
requestPolicyList.add(getPolicyList(policyList[i], policyMap, null).get(0));
responsePolicyList.add(getPolicyList(policyList[i], policyMap, null).get(0));
}
List<OperationPolicyDTO> opList = getPolicyList(policyName, policyMap, attributeMap);
opList.get(0).setPolicyVersion("v2");

requestPolicyList.add(getPolicyList(policyName, policyMap, attributeMap).get(0));
responsePolicyList.add(getPolicyList(policyName, policyMap, attributeMap).get(0));
requestPolicyList.add(opList.get(0));
responsePolicyList.add(opList.get(0));
apiOperationPoliciesDTO.setRequest(requestPolicyList);
apiOperationPoliciesDTO.setResponse(responsePolicyList);
apidto.getOperations().get(0).setOperationPolicies(apiOperationPoliciesDTO);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,17 @@ public void testGatewayRestAPI() throws Exception {
faultAttributeMap.put("headerName", "FaultTestHeader");
faultAttributeMap.put("headerValue", "FaultTestValue");

List<OperationPolicyDTO> requestOpList = getPolicyList(policyName, commonPolicyMap, requestAttributeMap);
requestOpList.get(0).setPolicyVersion("v2");
List<OperationPolicyDTO> responseOpList = getPolicyList(policyName, commonPolicyMap, responseAttributeMap);
responseOpList.get(0).setPolicyVersion("v2");
List<OperationPolicyDTO> faultOpList = getPolicyList(policyName, commonPolicyMap, faultAttributeMap);
faultOpList.get(0).setPolicyVersion("v2");

APIOperationPoliciesDTO apiOperationPoliciesDTO = new APIOperationPoliciesDTO();
apiOperationPoliciesDTO.setRequest(getPolicyList(policyName, commonPolicyMap, requestAttributeMap));
apiOperationPoliciesDTO.setResponse(getPolicyList(policyName, commonPolicyMap, responseAttributeMap));
apiOperationPoliciesDTO.setFault(getPolicyList(policyName, commonPolicyMap, faultAttributeMap));
apiOperationPoliciesDTO.setRequest(requestOpList);
apiOperationPoliciesDTO.setResponse(responseOpList);
apiOperationPoliciesDTO.setFault(faultOpList);

APIDTO api = restAPIPublisher.getAPIByID(apiId);
api.getOperations().get(0).setOperationPolicies(apiOperationPoliciesDTO);
Expand Down
Loading