diff --git a/modules/distribution/product/src/main/assembly/bin.xml b/modules/distribution/product/src/main/assembly/bin.xml
index 3b4ef81fb6..2fd7e0799c 100644
--- a/modules/distribution/product/src/main/assembly/bin.xml
+++ b/modules/distribution/product/src/main/assembly/bin.xml
@@ -750,15 +750,7 @@
**/tenant-conf.json
-
-
- ../../p2-profile/product/target/wso2carbon-core-${carbon.kernel.version}/repository/resources/workflowextensions
-
- wso2am-${pom.version}/repository/resources
-
- **/default-workflow-extensions.xml
-
-
+
diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/other/APIStateChangeWorkflowTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/other/APIStateChangeWorkflowTestCase.java
index c85b7c6319..30b8addc64 100644
--- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/other/APIStateChangeWorkflowTestCase.java
+++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/other/APIStateChangeWorkflowTestCase.java
@@ -16,16 +16,16 @@
*/
package org.wso2.am.integration.tests.other;
+import static org.junit.Assert.assertNotNull;
import static org.testng.Assert.assertEquals;
-import java.io.File;
import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URISyntaxException;
import java.net.URL;
-import java.util.ArrayList;
import java.util.HashMap;
-import java.util.List;
import java.util.Map;
import javax.xml.xpath.XPathExpressionException;
@@ -34,11 +34,13 @@
import org.json.JSONException;
import org.json.JSONObject;
import org.json.simple.parser.JSONParser;
+import org.json.simple.parser.ParseException;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.wso2.am.admin.clients.registry.ResourceAdminServiceClient;
+import org.wso2.am.integration.clients.admin.ApiException;
import org.wso2.am.integration.test.utils.APIManagerIntegrationTestException;
import org.wso2.am.integration.test.utils.base.APIMIntegrationConstants;
import org.wso2.am.integration.test.utils.bean.APILifeCycleState;
@@ -53,7 +55,6 @@
import org.wso2.carbon.automation.engine.annotations.SetEnvironment;
import org.wso2.carbon.automation.test.utils.http.client.HttpResponse;
import org.wso2.carbon.integration.common.utils.exceptions.AutomationUtilException;
-import org.wso2.carbon.integration.common.utils.mgt.ServerConfigurationManager;
import org.wso2.carbon.registry.resource.stub.ResourceAdminServiceExceptionException;
/**
@@ -66,21 +67,19 @@ public class APIStateChangeWorkflowTestCase extends APIManagerLifecycleBaseTest
private String publisherURLHttp;
private String storeURLHttp;
private String userName;
- private String originalWFExtentionsXML;
- private String newWFExtentionsXML;
- private ResourceAdminServiceClient resourceAdminServiceClient;
private APIIdentifier apiIdentifier;
- private final String APIM_CONFIG_XML = "api-manager.xml";
- private final String DEFAULT_WF_EXTENTIONS_XML_REG_CONFIG_LOCATION =
- "/_system/governance/apimgt/applicationdata/workflow-extensions.xml";
private String appName = "sample-application-workflow2";
private static JSONParser parser = new JSONParser();
- private ServerConfigurationManager serverConfigurationManager;
private String apiName = "APIStateWf";
private String apiVersion = "1.0.0";
private String wfreferenceId = null;
private String clientId;
- private String clientSecrect;
+ private String clientSecret;
+ private org.json.simple.JSONObject originalTenantConf;
+ private static final String UTF_8 = "UTF-8";
+ private static final String TENANT_CONFIG_PATH = "artifacts/AM/configFiles/tenantConf/tenant-conf.json";
+ private static final String WORKFLOW_CONFIG_PATH
+ = "artifacts/AM/configFiles/workflowapistatechange/tenant-workflow-conf.json";
/*
@DataProvider
@@ -97,7 +96,7 @@ public APIStateChangeWorkflowTestCase(TestUserMode userMode) {
@BeforeClass(groups = {"noRestart"}, alwaysRun = true)
public void setEnvironment() throws AutomationUtilException, XPathExpressionException, IOException,
- APIManagerIntegrationTestException, URISyntaxException, ResourceAdminServiceExceptionException {
+ APIManagerIntegrationTestException, URISyntaxException, ResourceAdminServiceExceptionException, ApiException, ParseException {
super.init();
String url = getGatewayURLHttp();
@@ -105,16 +104,21 @@ public void setEnvironment() throws AutomationUtilException, XPathExpressionExce
publisherURLHttp = getPublisherURLHttp();
storeURLHttp = getStoreURLHttp();
userName = user.getUserName();
- resourceAdminServiceClient = new ResourceAdminServiceClient(gatewayContextMgt.getContextUrls().getBackEndUrl(),
- createSession(gatewayContextMgt));
- // Gets the original workflow-extentions.xml file's content from the registry.
- originalWFExtentionsXML = resourceAdminServiceClient
- .getTextContent(DEFAULT_WF_EXTENTIONS_XML_REG_CONFIG_LOCATION);
- // Gets the new configuration of the workflow-extentions.xml
- newWFExtentionsXML = readFile(getAMResourceLocation() + File.separator + "configFiles" + File.separator
- + "workflowapistatechange" + File.separator + "workflow-extentions.xml");
- // Updates the content of the workflow-extentions.xml of the registry file, to have the new configurations.
- resourceAdminServiceClient.updateTextContent(DEFAULT_WF_EXTENTIONS_XML_REG_CONFIG_LOCATION, newWFExtentionsXML);
+
+ originalTenantConf = (org.json.simple.JSONObject) new JSONParser().parse(restAPIAdmin.getTenantConfig());
+ InputStream tenantConfigStream = getClass().getClassLoader().getResourceAsStream(TENANT_CONFIG_PATH);
+ assertNotNull("Tenant config stream can not be null", tenantConfigStream);
+
+ org.json.simple.JSONObject tenantJsonObject = (org.json.simple.JSONObject) new JSONParser().parse(
+ new InputStreamReader(tenantConfigStream, UTF_8));
+
+ InputStream wfStream = getClass().getClassLoader().getResourceAsStream(WORKFLOW_CONFIG_PATH);
+ assertNotNull("Workflow stream can not be null", wfStream);
+ org.json.simple.JSONObject wfJsonObj = (org.json.simple.JSONObject) new JSONParser().parse(
+ new InputStreamReader(wfStream, UTF_8));
+
+ tenantJsonObject.put("Workflows",wfJsonObj);
+ restAPIAdmin.updateTenantConfig(tenantJsonObject);
APIStoreRestClient apiStore;
@@ -182,7 +186,7 @@ public void testAPIStateChangeAndApproveWorkflow() throws Exception {
if ("clientId".equals(name)) {
clientId = variable.getString("value");
} else if ("clientSecret".equals(name)) {
- clientSecrect = variable.getString("value");
+ clientSecret = variable.getString("value");
} else if ("scope".equals(name)) {
scope = variable.getString("value");
} else if ("apiCurrentState".equals(name)) {
@@ -201,10 +205,10 @@ public void testAPIStateChangeAndApproveWorkflow() throws Exception {
}
Assert.assertNotNull(clientId, "clientId should not be null");
- Assert.assertNotNull(clientSecrect, "clientSecrect should not be null");
+ Assert.assertNotNull(clientSecret, "clientSecrect should not be null");
Assert.assertNotNull(scope, "scope should not be null");
- HttpResponse resp = completeWorkflowTask(clientId, clientSecrect, scope, apiCurrentState, apiLCAction,
+ HttpResponse resp = completeWorkflowTask(clientId, clientSecret, scope, apiCurrentState, apiLCAction,
apiNameReq, apiVersionReq, apiProvider, invoker, "APPROVED");
Assert.assertEquals(resp.getResponseCode(), 200, "Invalid status code:" + resp.getResponseCode());
@@ -266,7 +270,7 @@ public void testAPIStateChangeAndRejectWorkflow() throws Exception {
if ("clientId".equals(name)) {
clientId = variable.getString("value");
} else if ("clientSecret".equals(name)) {
- clientSecrect = variable.getString("value");
+ clientSecret = variable.getString("value");
} else if ("scope".equals(name)) {
scope = variable.getString("value");
} else if ("apiCurrentState".equals(name)) {
@@ -285,10 +289,10 @@ public void testAPIStateChangeAndRejectWorkflow() throws Exception {
}
Assert.assertNotNull(clientId, "clientId should not be null");
- Assert.assertNotNull(clientSecrect, "clientSecrect should not be null");
+ Assert.assertNotNull(clientSecret, "clientSecrect should not be null");
Assert.assertNotNull(scope, "scope should not be null");
- HttpResponse resp = completeWorkflowTask(clientId, clientSecrect, scope, apiCurrentState, apiLCAction,
+ HttpResponse resp = completeWorkflowTask(clientId, clientSecret, scope, apiCurrentState, apiLCAction,
apiNameReq, apiVersionReq, apiProvider, invoker, "REJECTED");
Assert.assertEquals(resp.getResponseCode(), 200, "Invalid status code:" + resp.getResponseCode());
@@ -312,7 +316,7 @@ public void testWorkflowCallbackRestAPI() throws Exception {
String workflowCallbackUrl;
// check for token with different scope other than apim:api_workfow
- String accessToken = generateAccessToken("default", clientId, clientSecrect);
+ String accessToken = generateAccessToken("default", clientId, clientSecret);
Map authenticationRequestHeaders = new HashMap();
authenticationRequestHeaders.put("Authorization", "Bearer " + accessToken);
authenticationRequestHeaders.put("Content-Type", "application/json");
@@ -325,7 +329,7 @@ public void testWorkflowCallbackRestAPI() throws Exception {
"Status code mismatch when request is done without valid token");
// get the correct scope
- accessToken = generateAccessToken("apim:api_workflow", clientId, clientSecrect);
+ accessToken = generateAccessToken("apim:api_workflow", clientId, clientSecret);
authenticationRequestHeaders = new HashMap();
authenticationRequestHeaders.put("Authorization", "Bearer " + accessToken);
authenticationRequestHeaders.put("Content-Type", "application/json");
@@ -356,10 +360,8 @@ public void testWorkflowCallbackRestAPI() throws Exception {
@AfterClass(alwaysRun = true)
public void cleanUpArtifacts() throws Exception {
+ restAPIAdmin.updateTenantConfig(originalTenantConf);
super.cleanUp();
- // restore the original workflow-extentions.xml content.
- resourceAdminServiceClient.updateTextContent(DEFAULT_WF_EXTENTIONS_XML_REG_CONFIG_LOCATION,
- originalWFExtentionsXML);
}
private HttpResponse completeWorkflowTask(String clientId, String clientSecrect, String scope,
diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/other/SubscriptionWFHTTPRedirectTest.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/other/SubscriptionWFHTTPRedirectTest.java
index 146f5c9166..f1a18dfd35 100644
--- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/other/SubscriptionWFHTTPRedirectTest.java
+++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/other/SubscriptionWFHTTPRedirectTest.java
@@ -2,17 +2,17 @@
import org.json.JSONObject;
import org.json.simple.parser.JSONParser;
+import org.json.simple.parser.ParseException;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
-import org.wso2.am.admin.clients.registry.ResourceAdminServiceClient;
+import org.wso2.am.integration.clients.admin.ApiException;
import org.wso2.am.integration.test.utils.APIManagerIntegrationTestException;
import org.wso2.am.integration.test.utils.base.APIMIntegrationConstants;
import org.wso2.am.integration.test.utils.bean.*;
import org.wso2.am.integration.test.utils.clients.APIPublisherRestClient;
import org.wso2.am.integration.test.utils.clients.APIStoreRestClient;
import org.wso2.am.integration.tests.api.lifecycle.APIManagerLifecycleBaseTest;
-import org.wso2.carbon.apimgt.api.WorkflowResponse;
import org.wso2.carbon.apimgt.api.model.APIIdentifier;
import org.wso2.carbon.automation.engine.annotations.ExecutionEnvironment;
import org.wso2.carbon.automation.engine.annotations.SetEnvironment;
@@ -25,9 +25,12 @@
import java.io.File;
import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
import java.net.URISyntaxException;
import java.net.URL;
+import static org.junit.Assert.assertNotNull;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
@@ -42,17 +45,18 @@ public class SubscriptionWFHTTPRedirectTest extends APIManagerLifecycleBaseTest
private String publisherURLHttp;
private String storeURLHttp;
private String userName;
- private String originalWFExtentionsXML;
- private String newWFExtentionsXML;
- private ResourceAdminServiceClient resourceAdminServiceClient;
private APIIdentifier apiIdentifier;
- private final String DEFAULT_WF_EXTENTIONS_XML_REG_CONFIG_LOCATION = "/_system/governance/apimgt/applicationdata/workflow-extensions.xml";
private String appName = "sample-application-workflow2";
private static JSONParser parser = new JSONParser();
+ private org.json.simple.JSONObject originalTenantConf;
+ private static final String UTF_8 = "UTF-8";
+ private static final String TENANT_CONFIG_PATH = "artifacts/AM/configFiles/tenantConf/tenant-conf.json";
+ private static final String WORKFLOW_CONFIG_PATH
+ = "artifacts/AM/configFiles/workflowHTTPRedirect/tenant-workflow-conf.json";
@BeforeClass(alwaysRun = true)
public void setEnvironment() throws AutomationUtilException, XPathExpressionException, IOException,
- APIManagerIntegrationTestException, URISyntaxException, ResourceAdminServiceExceptionException {
+ APIManagerIntegrationTestException, URISyntaxException, ResourceAdminServiceExceptionException, ParseException, ApiException {
super.init();
ServerConfigurationManager serverConfigurationManager;
@@ -67,14 +71,23 @@ public void setEnvironment() throws AutomationUtilException, XPathExpressionExce
publisherURLHttp = getPublisherURLHttp();
storeURLHttp = getStoreURLHttp();
userName = user.getUserName();
- resourceAdminServiceClient =
- new ResourceAdminServiceClient(gatewayContextMgt.getContextUrls().getBackEndUrl(),
- createSession(gatewayContextMgt));
- //Gets the original workflow-extentions.xml file's content from the registry.
- originalWFExtentionsXML = resourceAdminServiceClient.getTextContent(DEFAULT_WF_EXTENTIONS_XML_REG_CONFIG_LOCATION);
- //Gets the new configuration of the workflow-extentions.xml
- newWFExtentionsXML = readFile(getAMResourceLocation()
- + File.separator + "configFiles" + File.separator + "workflowHTTPRedirect" + File.separator + "workflow-extentions.xml");
+
+ originalTenantConf = (org.json.simple.JSONObject) new JSONParser().parse(restAPIAdmin.getTenantConfig());
+ InputStream tenantConfigStream = getClass().getClassLoader().getResourceAsStream(TENANT_CONFIG_PATH);
+ assertNotNull("Tenant config stream can not be null", tenantConfigStream);
+
+ org.json.simple.JSONObject tenantJsonObject = (org.json.simple.JSONObject) new JSONParser().parse(
+ new InputStreamReader(tenantConfigStream, UTF_8));
+
+ InputStream wfStream = getClass().getClassLoader().getResourceAsStream(WORKFLOW_CONFIG_PATH);
+ assertNotNull("Workflow stream can not be null", wfStream);
+ org.json.simple.JSONObject wfJsonObj = (org.json.simple.JSONObject) new JSONParser().parse(
+ new InputStreamReader(wfStream, UTF_8));
+
+ tenantJsonObject.put("Workflows",wfJsonObj);
+ //Updates the workflow configuration to have a custom SubscriptionCreation workflow.
+ restAPIAdmin.updateTenantConfig(tenantJsonObject);
+
}
@@ -82,8 +95,6 @@ public void setEnvironment() throws AutomationUtilException, XPathExpressionExce
public void testHTTPredirectInSubscriptionWorkflow() throws Exception {
APIStoreRestClient apiStore;
- //Updates the content of the workflow-extentions.xml of the registry file, to have the new configurations.
- resourceAdminServiceClient.updateTextContent(DEFAULT_WF_EXTENTIONS_XML_REG_CONFIG_LOCATION, newWFExtentionsXML);
String apiName = "HTTPRedirectTestAPI2";
//Just a dummy URL
String url = "http://localhost:9443/carbon";
@@ -136,9 +147,8 @@ public void testHTTPredirectInSubscriptionWorkflow() throws Exception {
@AfterClass(alwaysRun = true)
public void cleanUpArtifacts() throws Exception {
+ restAPIAdmin.updateTenantConfig(originalTenantConf);
super.cleanUp();
- //restore the original workflow-extentions.xml content.
- resourceAdminServiceClient.updateTextContent(DEFAULT_WF_EXTENTIONS_XML_REG_CONFIG_LOCATION, originalWFExtentionsXML);
}
}
diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/restapi/testcases/OnHoldSubscriptionWorkflowIdTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/restapi/testcases/OnHoldSubscriptionWorkflowIdTestCase.java
index 01678c68f7..13e6921e64 100644
--- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/restapi/testcases/OnHoldSubscriptionWorkflowIdTestCase.java
+++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/restapi/testcases/OnHoldSubscriptionWorkflowIdTestCase.java
@@ -20,8 +20,8 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.json.simple.parser.JSONParser;
import org.testng.annotations.*;
-import org.wso2.am.admin.clients.registry.ResourceAdminServiceClient;
import org.wso2.am.integration.test.utils.APIManagerIntegrationTestException;
import org.wso2.am.integration.test.utils.base.APIMIntegrationBaseTest;
import org.wso2.am.integration.tests.restapi.RESTAPITestConstants;
@@ -29,13 +29,10 @@
import org.wso2.carbon.automation.engine.annotations.ExecutionEnvironment;
import org.wso2.carbon.automation.engine.annotations.SetEnvironment;
import org.wso2.carbon.automation.engine.context.TestUserMode;
-import org.wso2.carbon.integration.common.utils.mgt.ServerConfigurationManager;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
+import java.io.*;
+import static org.junit.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;
/**
@@ -46,12 +43,12 @@
public class OnHoldSubscriptionWorkflowIdTestCase extends APIMIntegrationBaseTest {
private static final Log log = LogFactory.getLog(OnHoldSubscriptionWorkflowIdTestCase.class);
+ private org.json.simple.JSONObject originalTenantConf;
+ private static final String UTF_8 = "UTF-8";
+ private static final String TENANT_CONFIG_PATH = "artifacts/AM/configFiles/tenantConf/tenant-conf.json";
+ private static final String WORKFLOW_CONFIG_PATH
+ = "artifacts/AM/configFiles/APIM5898/tenant-workflow-conf.json";
- private final String DEFAULT_WF_EXTENTIONS_XML_REG_CONFIG_LOCATION =
- "/_system/governance/apimgt/applicationdata/workflow-extensions.xml";
- private ResourceAdminServiceClient resourceAdminServiceClient;
- private String originalWFExtentionsXML;
- private String newWFExtentionsXML;
@Factory(dataProvider = "userModeDataProvider")
public OnHoldSubscriptionWorkflowIdTestCase(TestUserMode userMode) {
@@ -69,17 +66,20 @@ public static Object[][] userModeDataProvider() {
public void setEnvironment() throws Exception {
super.init(userMode);
- resourceAdminServiceClient = new ResourceAdminServiceClient(gatewayContextMgt.getContextUrls().
- getBackEndUrl(), createSession(gatewayContextMgt));
-
- // Gets the original workflow-extentions.xml file's content from the registry.
- originalWFExtentionsXML = resourceAdminServiceClient
- .getTextContent(DEFAULT_WF_EXTENTIONS_XML_REG_CONFIG_LOCATION);
- // Gets the new configuration of the workflow-extentions.xml
- newWFExtentionsXML = readFile(getAMResourceLocation() + File.separator + "configFiles" + File.separator
- + "APIM5898" + File.separator + "workflow-extensions.xml");
- // Updates the content of the workflow-extentions.xml of the registry file, to have the new configurations.
- resourceAdminServiceClient.updateTextContent(DEFAULT_WF_EXTENTIONS_XML_REG_CONFIG_LOCATION, newWFExtentionsXML);
+ originalTenantConf = (org.json.simple.JSONObject) new JSONParser().parse(restAPIAdmin.getTenantConfig());
+ InputStream tenantConfigStream = getClass().getClassLoader().getResourceAsStream(TENANT_CONFIG_PATH);
+ assertNotNull("Tenant config stream can not be null", tenantConfigStream);
+
+ org.json.simple.JSONObject tenantJsonObject = (org.json.simple.JSONObject) new JSONParser().parse(
+ new InputStreamReader(tenantConfigStream, UTF_8));
+
+ InputStream wfStream = getClass().getClassLoader().getResourceAsStream(WORKFLOW_CONFIG_PATH);
+ assertNotNull("Workflow stream can not be null", wfStream);
+ org.json.simple.JSONObject wfJsonObj = (org.json.simple.JSONObject) new JSONParser().parse(
+ new InputStreamReader(wfStream, UTF_8));
+
+ tenantJsonObject.put("Workflows",wfJsonObj);
+ restAPIAdmin.updateTenantConfig(tenantJsonObject);
}
@Test(groups = {"wso2.am"}, description = "Returning workflow external ref. id from subscriptions rest api in "
@@ -98,10 +98,8 @@ public void testSubscription() {
@AfterClass(alwaysRun = true)
public void cleanUpArtifacts() throws Exception {
+ restAPIAdmin.updateTenantConfig(originalTenantConf);
super.cleanUp();
- // restore the original workflow-extentions.xml content.
- resourceAdminServiceClient.updateTextContent(DEFAULT_WF_EXTENTIONS_XML_REG_CONFIG_LOCATION,
- originalWFExtentionsXML);
}
diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/workflow/WorkflowApprovalExecutorTest.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/workflow/WorkflowApprovalExecutorTest.java
index 6e9b9b941b..2f76b6077f 100644
--- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/workflow/WorkflowApprovalExecutorTest.java
+++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/workflow/WorkflowApprovalExecutorTest.java
@@ -18,7 +18,6 @@
*/
package org.wso2.am.integration.tests.workflow;
-import java.io.File;
import com.google.gson.Gson;
import com.google.gson.internal.LinkedTreeMap;
import org.apache.commons.logging.Log;
@@ -26,10 +25,10 @@
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
+import org.json.simple.parser.JSONParser;
import org.junit.Assert;
import org.testng.annotations.*;
import org.testng.annotations.Test;
-import org.wso2.am.admin.clients.registry.ResourceAdminServiceClient;
import org.wso2.am.integration.clients.admin.ApiException;
import org.wso2.am.integration.clients.admin.api.dto.WorkflowDTO;
import org.wso2.am.integration.clients.admin.api.dto.WorkflowInfoDTO;
@@ -47,7 +46,6 @@
import org.wso2.am.integration.test.impl.ApiProductTestHelper;
import org.wso2.am.integration.test.impl.ApiTestHelper;
import org.wso2.am.integration.test.impl.RestAPIAdminImpl;
-import org.wso2.am.integration.test.impl.RestAPIStoreImpl;
import org.wso2.am.integration.test.utils.UserManagementUtils;
import org.wso2.am.integration.test.utils.base.APIMIntegrationConstants;
import org.wso2.am.integration.test.utils.bean.*;
@@ -55,10 +53,12 @@
import org.wso2.am.integration.tests.api.lifecycle.APIManagerLifecycleBaseTest;
import org.wso2.carbon.apimgt.api.WorkflowStatus;
-import org.wso2.carbon.apimgt.api.model.APIIdentifier;
import org.wso2.carbon.automation.engine.context.TestUserMode;
import org.wso2.carbon.automation.test.utils.http.client.HttpResponse;
import org.wso2.carbon.integration.common.admin.client.UserManagementClient;
+
+import java.io.InputStream;
+import java.io.InputStreamReader;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
@@ -72,38 +72,30 @@
public class WorkflowApprovalExecutorTest extends APIManagerLifecycleBaseTest {
private UserManagementClient userManagementClient = null;
- private String originalWFExtentionsXML;
- private String newWFExtentionsXML;
private String USER_SMITH = "smith";
private String ADMIN_ROLE = "admin";
private String USER_ADMIN = "jackson";
private String userName;
private final String INTERNAL_ROLE_SUBSCRIBER = "Internal/subscriber";
- private ResourceAdminServiceClient resourceAdminServiceClient;
private final String ALLOWED_ROLE = "admin";
- private static final String SUBSCRIBER_ROLE = "subscriber";
- private final String[] ADMIN_PERMISSIONS = { "/permission/admin/login", "/permission/admin/manage",
- "/permission/admin/configure", "/permission/admin/monitor" };
- private final String[] NEW_ROLE_LIST = { "Internal/publisher", "Internal/creator",
- "Internal/subscriber", "Internal/everyone", "admin" };
- private final String APIM_CONFIG_XML = "api-manager.xml";
- private final String DEFAULT_WF_EXTENTIONS_XML_REG_CONFIG_LOCATION =
- "/_system/governance/apimgt/applicationdata/workflow-extensions.xml";
private RestAPIAdminImpl restAPIAdminUser;
private static final Log log = LogFactory.getLog(WorkflowApprovalExecutorTest.class);
- private APIIdentifier apiIdentifier;
private AdminDashboardRestClient adminDashboardRestClient;
private String apiId;
private String applicationID;
private String subscriptionId;
private ApiProductTestHelper apiProductTestHelper;
private ApiTestHelper apiTestHelper;
- private RestAPIStoreImpl APIStoreClient;
private String apiName = "WorkflowTestAPI";
private String applicationName = "AppCreationWorkflowTestAPP";
private ArrayList apisToBeUsed;
private APIProductDTO apiProductDTO;
private String apiProductId;
+ private org.json.simple.JSONObject originalTenantConf;
+ private static final String UTF_8 = "UTF-8";
+ private static final String TENANT_CONFIG_PATH = "artifacts/AM/configFiles/tenantConf/tenant-conf.json";
+ private static final String WORKFLOW_CONFIG_PATH
+ = "artifacts/AM/configFiles/approveWorkflow/tenant-workflow-conf.json";
@Factory(dataProvider = "userModeDataProvider")
public WorkflowApprovalExecutorTest(TestUserMode userMode) {
@@ -128,16 +120,20 @@ public void setEnvironment() throws Exception {
userManagementClient.addUser(USER_SMITH, "john123", new String[]{INTERNAL_ROLE_SUBSCRIBER}, USER_SMITH);
userManagementClient.addUser(USER_ADMIN, "admin", new String[]{ALLOWED_ROLE}, ADMIN_ROLE);
- resourceAdminServiceClient = new ResourceAdminServiceClient(gatewayContextMgt.getContextUrls().getBackEndUrl(),
- createSession(gatewayContextMgt));
- // Gets the original workflow-extentions.xml file's content from the registry.
- originalWFExtentionsXML = resourceAdminServiceClient
- .getTextContent(DEFAULT_WF_EXTENTIONS_XML_REG_CONFIG_LOCATION);
- // Gets the new configuration of the workflow-extentions.xml
- newWFExtentionsXML = readFile(getAMResourceLocation() + File.separator + "configFiles" + File.separator
- + "approveWorkflow" + File.separator + "workflow-extensions.xml");
- // Updates the content of the workflow-extentions.xml of the registry file, to have the new configurations.
- resourceAdminServiceClient.updateTextContent(DEFAULT_WF_EXTENTIONS_XML_REG_CONFIG_LOCATION, newWFExtentionsXML);
+ originalTenantConf = (org.json.simple.JSONObject) new JSONParser().parse(restAPIAdmin.getTenantConfig());
+ InputStream tenantConfigStream = getClass().getClassLoader().getResourceAsStream(TENANT_CONFIG_PATH);
+ assertNotNull("Tenant config stream can not be null", tenantConfigStream);
+
+ org.json.simple.JSONObject tenantJsonObject = (org.json.simple.JSONObject) new JSONParser().parse(
+ new InputStreamReader(tenantConfigStream, UTF_8));
+
+ InputStream wfStream = getClass().getClassLoader().getResourceAsStream(WORKFLOW_CONFIG_PATH);
+ assertNotNull("Workflow stream can not be null", wfStream);
+ org.json.simple.JSONObject wfJsonObj = (org.json.simple.JSONObject) new JSONParser().parse(
+ new InputStreamReader(wfStream, UTF_8));
+
+ tenantJsonObject.put("Workflows",wfJsonObj);
+ restAPIAdmin.updateTenantConfig(tenantJsonObject);
apiProductTestHelper = new ApiProductTestHelper(restAPIPublisher, restAPIStore);
apiTestHelper = new ApiTestHelper(restAPIPublisher, restAPIStore, getAMResourceLocation(),
@@ -1105,7 +1101,7 @@ public void destroy() throws Exception {
userManagementClient.deleteUser(USER_SMITH);
userManagementClient.deleteUser(USER_ADMIN);
userManagementClient.deleteUser("JaneDoe");
- resourceAdminServiceClient.updateTextContent(DEFAULT_WF_EXTENTIONS_XML_REG_CONFIG_LOCATION, originalWFExtentionsXML);
+ restAPIAdmin.updateTenantConfig(originalTenantConf);
super.cleanUp();
}
}
diff --git a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/AM/configFiles/APIM5898/tenant-workflow-conf.json b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/AM/configFiles/APIM5898/tenant-workflow-conf.json
new file mode 100644
index 0000000000..93a41415fd
--- /dev/null
+++ b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/AM/configFiles/APIM5898/tenant-workflow-conf.json
@@ -0,0 +1,5 @@
+{
+ "SubscriptionCreation": {
+ "Class": "org.wso2.sample.apimgt.workflow.SampleSubscriptionWorkflow"
+ }
+}
diff --git a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/AM/configFiles/APIM5898/workflow-extensions.xml b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/AM/configFiles/APIM5898/workflow-extensions.xml
deleted file mode 100644
index 94b4204689..0000000000
--- a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/AM/configFiles/APIM5898/workflow-extensions.xml
+++ /dev/null
@@ -1,75 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/AM/configFiles/approveWorkflow/tenant-workflow-conf.json b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/AM/configFiles/approveWorkflow/tenant-workflow-conf.json
new file mode 100644
index 0000000000..8f4f81521d
--- /dev/null
+++ b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/AM/configFiles/approveWorkflow/tenant-workflow-conf.json
@@ -0,0 +1,19 @@
+{
+ "ApplicationCreation": {},
+ "ProductionApplicationRegistration": {},
+ "SandboxApplicationRegistration": {},
+ "SubscriptionCreation": {},
+ "UserSignUp": {},
+ "SubscriptionDeletion": {},
+ "ApplicationDeletion": {},
+ "APIStateChange": {
+ "Properties": {
+ "StateList": "Created:Publish,Published:Block"
+ }
+ },
+ "APIProductStateChange": {
+ "Properties": {
+ "StateList": "Created:Publish,Published:Block"
+ }
+ }
+ }
diff --git a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/AM/configFiles/approveWorkflow/workflow-extensions.xml b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/AM/configFiles/approveWorkflow/workflow-extensions.xml
deleted file mode 100644
index d164df1782..0000000000
--- a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/AM/configFiles/approveWorkflow/workflow-extensions.xml
+++ /dev/null
@@ -1,55 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Created:Publish,Published:Block
-
-
-
-
- Created:Publish,Published:Block
-
-
-
diff --git a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/AM/configFiles/workflowHTTPRedirect/tenant-workflow-conf.json b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/AM/configFiles/workflowHTTPRedirect/tenant-workflow-conf.json
new file mode 100644
index 0000000000..ce417c5a68
--- /dev/null
+++ b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/AM/configFiles/workflowHTTPRedirect/tenant-workflow-conf.json
@@ -0,0 +1,5 @@
+{
+ "SubscriptionCreation": {
+ "Class": "org.wso2.sample.workflow.SubscriptionCreationSampleWorkflowExecutor"
+ }
+}
diff --git a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/AM/configFiles/workflowHTTPRedirect/workflow-extentions.xml b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/AM/configFiles/workflowHTTPRedirect/workflow-extentions.xml
deleted file mode 100755
index 7069df3b94..0000000000
--- a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/AM/configFiles/workflowHTTPRedirect/workflow-extentions.xml
+++ /dev/null
@@ -1,52 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/AM/configFiles/workflowapistatechange/tenant-workflow-conf.json b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/AM/configFiles/workflowapistatechange/tenant-workflow-conf.json
new file mode 100644
index 0000000000..ad51cd368b
--- /dev/null
+++ b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/AM/configFiles/workflowapistatechange/tenant-workflow-conf.json
@@ -0,0 +1,9 @@
+{
+ "APIStateChange": {
+ "Class": "org.wso2.carbon.apimgt.impl.workflow.APIStateChangeWSWorkflowExecutor",
+ "Properties": {
+ "ProcessDefinitionKey": "APIStateChangeApprovalProcess",
+ "StateList": "Created:Publish,Published:Block"
+ }
+ }
+}
diff --git a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/AM/configFiles/workflowapistatechange/workflow-extentions.xml b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/AM/configFiles/workflowapistatechange/workflow-extentions.xml
deleted file mode 100644
index eea1238883..0000000000
--- a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/AM/configFiles/workflowapistatechange/workflow-extentions.xml
+++ /dev/null
@@ -1,70 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- APIStateChangeApprovalProcess
- Created:Publish,Published:Block
-
-
-
-
-