diff --git a/modules/integration/tests-ui/src/test/java/org/wso2/appmanager/ui/integration/test/config/TestSecureVaultForJsonConfigFiles.java b/modules/integration/tests-ui/src/test/java/org/wso2/appmanager/ui/integration/test/config/TestSecureVaultForJsonConfigFiles.java new file mode 100644 index 000000000..36a3957d0 --- /dev/null +++ b/modules/integration/tests-ui/src/test/java/org/wso2/appmanager/ui/integration/test/config/TestSecureVaultForJsonConfigFiles.java @@ -0,0 +1,126 @@ +package org.wso2.appmanager.ui.integration.test.config; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; +import org.wso2.appmanager.ui.integration.test.pages.LoginPage; +import org.wso2.appmanager.ui.integration.test.pages.PublisherWebAppsListPage; +import org.wso2.appmanager.ui.integration.test.pages.StoreHomePage; +import org.wso2.appmanager.ui.integration.test.utils.AppManagerIntegrationTest; +import org.wso2.carbon.automation.engine.frameworkutils.FrameworkPathUtil; +import org.wso2.carbon.utils.FileManipulator; +import org.wso2.carbon.utils.ServerConstants; + +import java.io.File; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +public class TestSecureVaultForJsonConfigFiles extends AppManagerIntegrationTest { + + private static final Log log = LogFactory.getLog(TestSecureVaultForJsonConfigFiles.class); + private Map configs; + private StoreHomePage homePage; + private PublisherWebAppsListPage webAppsListPage; + + @BeforeClass(alwaysRun = true) + public void startUp() throws Exception { + populateConfigs(); + for (Map.Entry entry : configs.entrySet()) { + String app = entry.getKey(); + String file = entry.getValue(); + String configDestinationPath = computeDestinationPathForConfig(app, file); + String configSourcePath = computeConfigResourcePath(app, file); + String configBackupPath = computeConfigBackupPath(app, file); + backupConfigFile(configDestinationPath, configBackupPath); + copyConfigFile(configSourcePath, configDestinationPath); + } + super.init(); + } + + + private void populateConfigs() { + configs = new HashMap(); + configs.put("publisher", "publisher.json"); + configs.put("store", "store.json"); + configs.put("social", "social.json"); + } + + private void copyConfigFile(String sourcePath, String destPath) { + File sourceFile = new File(sourcePath); + File destFile = new File(destPath); + try { + FileManipulator.copyFile(sourceFile, destFile); + } catch (IOException e) { + log.error("Error while copying the file to destination", e); + } + } + + private void backupConfigFile(String source, String backup) { + copyConfigFile(source, backup); + } + + private String computeDestinationPathForConfig(String webApp, String fileName) { + String serverRoot = System.getProperty(ServerConstants.CARBON_HOME); + String deploymentPath = serverRoot + File.separator + "repository" + File.separator + + "deployment" + File.separator + "server" + File.separator + "jaggeryapps" + File.separator + webApp + + File.separator; + String configDir = "config"; + if ("social".equals(webApp)) { + configDir = "configs"; + } + + deploymentPath = deploymentPath + configDir; + File depFile = new File(deploymentPath); + if (!depFile.exists() && !depFile.mkdir()) { + log.error("Error while creating the cpnfig folder : " + deploymentPath); + } + return deploymentPath + File.separator + fileName; + } + + private String computeConfigResourcePath(String webApp, String fileName) { + + String sourcePath = FrameworkPathUtil.getSystemResourceLocation() + "artifacts" + File.separator + webApp + + File.separator + fileName; + return sourcePath; + } + + private String computeConfigBackupPath(String webApp, String fileName) { + + String path = FrameworkPathUtil.getTargetDirectory() + File.separator + "backup" + File.separator + webApp + + File.separator + fileName; + return path; + } + + @Test(groups = TEST_GROUP, description = "Test Store login After changing configs") + public void testStoreLogin() throws Exception { + //login to store + homePage = (StoreHomePage) login(driver, LoginPage.LoginTo.STORE); + //new WebDriverWait(driver, 90).until(ExpectedConditions.titleIs("WSO2 App Manager")); + + } + + @Test(groups = TEST_GROUP, description = "Test Publisher login After changing configs") + public void testPublisherLogin() throws Exception { + //login to publisher + webAppsListPage = (PublisherWebAppsListPage) login(driver, LoginPage.LoginTo.PUBLISHER); + //new WebDriverWait(driver, 90).until(ExpectedConditions.titleIs("webapp | WSO2 App Manager")); + + } + + @AfterClass(alwaysRun = true) + public void closeDown() throws Exception { + for (Map.Entry entry : configs.entrySet()) + { + String app = entry.getKey(); + String file = entry.getValue(); + String configDestinationPath = computeDestinationPathForConfig(app, file); + String configBackupPath = computeConfigBackupPath(app, file); + backupConfigFile(configBackupPath, configDestinationPath); + } + closeDriver(driver); + } + +} diff --git a/modules/integration/tests-ui/src/test/resources/artifacts/publisher/publisher.json b/modules/integration/tests-ui/src/test/resources/artifacts/publisher/publisher.json new file mode 100755 index 000000000..2f47261b6 --- /dev/null +++ b/modules/integration/tests-ui/src/test/resources/artifacts/publisher/publisher.json @@ -0,0 +1,88 @@ +{ + "server": { + "https": "%https.host%/admin", + "http": "%http.host%" + }, + "user": { + "username": "admin", + "password": "admin" + }, + "tenantConfigs": "/_system/config/publisher/configs/publisher.json", + "app": { + "RXT_MANAGER": "rxt_manager", + "ROUTE_MANAGER": "route_manager", + "MODEL_MANAGER": "model_manager" + }, + "lifeCycleBehaviour": { + + "SampleLifeCycle2": { + + "onAttach": { + "action": "Promote" + } + }, + "MobileAppLifeCycle":{ + "onAttach":{ + "action":"Create" + } + }, + "WebAppLifeCycle": { + "onAttach": { + "action": "Create" + } + } + }, + + "paths": { + "ASSET_EXT_PATH": "/assets", + "ASSET_DEFAULT_PATH": "/assets/default", + "ASSETS_EXT_PATH": "/assets", + "ASSETS_DEFAULT_PATH": "/assets/default", + "RXT_EXTENSION_PATH": "/config/ext/" + }, + + "urls": { + "ASSET": "/asset", + "ASSETS": "/assets" + }, + + "router": { + "RENDERER": "/modules/router.caramel-renderer.js" + }, + "ssoConfiguration": { + "enabled": true, + "issuer": "publisher", + "identityProviderURL": "%https.host%/samlsso", + "keyStorePassword": "", + "identityAlias": "", + "responseSigningEnabled": "true", + "publisherAcs": "%https.host%/publisher/sso", + "keyStoreName": "", + "validateAssertionValidityPeriod": true, + "validateAudienceRestriction": true, + "assertionSigningEnabled": true + }, + "constants" :{ + "assetCreatedDateLength" : 20 + }, + "paginationConfig" :{ + "PAGE_SIZE" : 20 + }, + "excludedRolesList":["admin","Internal/subscriber","Internal/publisher", "Internal/everyone", "system/wso2.anonymous.role"], + "permissions": { + "webapp_create": "/permission/admin/manage/webapp/create", + "webapp_update": "/permission/admin/manage/webapp/update", + "webapp_publish": "/permission/admin/manage/webapp/publish", + "webapp_delete": "/permission/admin/manage/webapp/delete", + "document_add": "/permission/admin/manage/document/add", + "document_edit": "/permission/admin/manage/document/edit", + "document_delete": "/permission/admin/manage/document/delete", + "view_statistics": "/permission/admin/manage/appm/view_stats", + "mobileapp_create": "/permission/admin/manage/mobileapp/create", + "mobileapp_update": "/permission/admin/manage/mobileapp/update", + "mobileapp_publish": "/permission/admin/manage/mobileapp/publish", + "mobileapp_delete": "/permission/admin/manage/mobileapp/delete" + }, + "publisherActions":["Publish","Approve","Reject","Unpublish","Deprecate","Retire","Recycle","Re-Publish","Submit for Review"], + "hiddenRoles":["admin","Internal/subscriber","Internal/publisher","Internal/creator"] +} diff --git a/modules/integration/tests-ui/src/test/resources/artifacts/social/social.json b/modules/integration/tests-ui/src/test/resources/artifacts/social/social.json new file mode 100644 index 000000000..910705dae --- /dev/null +++ b/modules/integration/tests-ui/src/test/resources/artifacts/social/social.json @@ -0,0 +1,33 @@ +{ + "server": { + "https": "%https.host%", + "http": "%http.host%" + }, + "ssoConfiguration": { + "enabled": true, + "issuer": "social", + "identityProviderURL": "%https.host%/samlsso", + "keyStorePassword": "", + "identityAlias": "", + "responseSigningEnabled": "true", + "storeAcs" : "%https.host%/store/acs.jag", + "keyStoreName": "", + "validateAssertionValidityPeriod": true, + "validateAudienceRestriction": true, + "assertionSigningEnabled": true + }, + "userSpace": { + "store": "/_system/governance/users/store" + }, + "permissions": { + "login": { + "/permission/admin/login": ["ui.execute"] + } + }, + "dataPublisherConnectionInfo":{ + "port":"7611", + "host":"localhost", + "username":"admin", + "password":"admin" + } +} diff --git a/modules/integration/tests-ui/src/test/resources/artifacts/store/store.json b/modules/integration/tests-ui/src/test/resources/artifacts/store/store.json new file mode 100644 index 000000000..9bfccb59a --- /dev/null +++ b/modules/integration/tests-ui/src/test/resources/artifacts/store/store.json @@ -0,0 +1,49 @@ +{ + "assetsUrlPrefix": "/assets", + "extensionsUrlPrefix": "/extensions", + "subscriptionsUrlPrefix": "/subscriptions", + "tenantConfigs": "/_system/config/store/configs/store.json", + "socialCommentsEnable": true, + "cached": false, + "server": { + "https": "%https.host%/admin", + "http": "%http.host%" + }, + + "lifeCycleBehaviour":{ + "visibleIn":["Published"] + }, + + "ssoConfiguration": { + "enabled": true, + "issuer": "store", + "identityProviderURL": "%https.host%/samlsso", + "keyStorePassword": "", + "identityAlias": "", + "responseSigningEnabled": "true", + "storeAcs" : "%https.host%/store/acs", + "keyStoreName": "", + "validateAssertionValidityPeriod": true, + "validateAudienceRestriction": true, + "assertionSigningEnabled": true + }, + + "pagination": { + "PAGE_SIZE" : 18 + }, + + "recentAppCount": { + "topAssetPage" : 15, + "assetPage": 5, + "assetsPage": 5, + "myAppsPage": 2, + "fromProvider": 5 + }, + "permissions": { + "webapp_subscribe": "/permission/admin/manage/webapp/subscribe", + "mobileapp_install": "/permission/admin/manage/mobileapp/subscribe" + }, + "pages": { + "favouritePage": "/assets/favourite" + } +} diff --git a/modules/integration/tests-ui/src/test/resources/testng.xml b/modules/integration/tests-ui/src/test/resources/testng.xml index a56dc75f5..3d1c3a96e 100755 --- a/modules/integration/tests-ui/src/test/resources/testng.xml +++ b/modules/integration/tests-ui/src/test/resources/testng.xml @@ -51,6 +51,7 @@ --> +