Skip to content

Commit

Permalink
Merge pull request #12210 from YasasRangika/gateway-policy-feature
Browse files Browse the repository at this point in the history
Gateway policy feature changes with Integration tests
  • Loading branch information
YasasRangika authored Jan 10, 2024
2 parents 3a583aa + 52ea95c commit 1b7e710
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6979,7 +6979,7 @@ public boolean isPolicyMappingDeploymentExists(String gatewayPolicyMappingId, St
@Override
public boolean hasExistingDeployments(String tenantDomain, String gatewayLabel) throws APIManagementException {
return !StringUtils.isBlank(
apiMgtDAO.getGatewayPolicyMappingByGatewayLabel(tenantDomain, gatewayLabel));
apiMgtDAO.getGatewayPolicyMappingByGatewayLabel(gatewayLabel, tenantDomain));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,13 @@ public Response engageGlobalPolicy(String gatewayPolicyMappingId,
// checks whether the gateway policy mapping exists in the particular gateway
for (GatewayPolicyDeploymentDTO gatewayPolicyDeploymentDTO : gatewayPolicyDeploymentDTOList) {
String gwName = gatewayPolicyDeploymentDTO.getGatewayLabel();
if (apiProvider.hasExistingDeployments(organization, gwName)) {
boolean isDeployment = gatewayPolicyDeploymentDTO.isGatewayDeployment();
if (isDeployment && apiProvider.hasExistingDeployments(organization, gwName)) {
RestApiUtil.handleBadRequest("Gateway policy mapping is already deployed in the gateway: " + gwName,
log);
} else if (!isDeployment && !apiProvider.hasExistingDeployments(organization, gwName)) {
RestApiUtil.handleBadRequest("Gateway policy mapping is not deployed in the gateway: " + gwName,
log);
}
}
List<OperationPolicyData> operationPolicyDataList = apiProvider.getGatewayPolicyDataListByPolicyId(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8375,6 +8375,8 @@ paths:
$ref: '#/components/responses/Forbidden'
404:
$ref: '#/components/responses/NotFound'
412:
$ref: '#/components/responses/PreconditionFailed'
500:
$ref: '#/components/responses/InternalServerError'
security:
Expand Down Expand Up @@ -8463,7 +8465,9 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/GatewayPolicyDeployment'
type: array
items:
$ref: '#/components/schemas/GatewayPolicyDeployment'
400:
$ref: '#/components/responses/BadRequest'
404:
Expand Down

0 comments on commit 1b7e710

Please sign in to comment.