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

Implement integration test for getting Custom Policies of API Revisions #13464

Closed
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
Expand Up @@ -634,8 +634,45 @@ public void testAddAPISpecificOperationPolicyYAML() throws Exception {
policyMap.put("customAPISpecificLogPolicyYAML", newPolicyId);
}

@Test(groups = {"wso2.am"}, description = "Delete API specific operation policy created using YAML Policy Definition",
@Test(groups = {"wso2.am"}, description = "Get API specific operation policy for API revision",
dependsOnMethods = "testAddAPISpecificOperationPolicyYAML")
public void testGetAPISpecificOperationPolicyForAPIRevision() throws Exception {

HttpResponse getAPIResponse = restAPIPublisher.getAPI(apiId);
APIDTO apidto = new Gson().fromJson(getAPIResponse.getData(), APIDTO.class);

String policyName = "customAPISpecificLogPolicyYAML";
Assert.assertNotNull(policyMap.get(policyName), "Unable to find a common policy with name " + policyName);

List<OperationPolicyDTO> opList = getPolicyList(policyName, policyMap, null);

APIOperationPoliciesDTO apiOperationPoliciesDTO = new APIOperationPoliciesDTO();
apiOperationPoliciesDTO.setRequest(opList);

// Add the operation policy to the API
apidto.getOperations().get(0).setOperationPolicies(apiOperationPoliciesDTO);
restAPIPublisher.updateAPI(apidto);

// Create a new Revision and Deploy to Gateway
String revisionID = createAPIRevisionAndDeployUsingRest(apiId, restAPIPublisher);
waitForAPIDeployment();

// Remove the operation policy from the API
apidto.getOperations().get(0).setOperationPolicies(new APIOperationPoliciesDTO());
restAPIPublisher.updateAPI(apidto);

// Get & Validate the operation policy from the API Revision
HttpResponse getAPIRevisionResponse = restAPIPublisher.getAPI(revisionID);
APIDTO apiRevisiondto = new Gson().fromJson(getAPIRevisionResponse.getData(), APIDTO.class);
String policyId = apiRevisiondto.getOperations().get(0).getOperationPolicies().getRequest().get(0).getPolicyId();
OperationPolicyDataDTO operationPolicyDataDTO = restAPIPublisher.getAPISpecificOperationPolicy(policyId, revisionID);
assertNotNull(operationPolicyDataDTO);
assertEquals(operationPolicyDataDTO.getName(), policyName);
assertEquals(operationPolicyDataDTO.getId(), policyId);
}

@Test(groups = {"wso2.am"}, description = "Delete API specific operation policy created using YAML Policy Definition",
dependsOnMethods = "testGetAPISpecificOperationPolicyForAPIRevision")
public void testDeleteAPISpecificOperationPolicyYAML() throws Exception {

int responseCode = deleteOperationPolicy(policyMap.get("customAPISpecificLogPolicyYAML"), apiId);
Expand Down
Loading