Skip to content
This repository has been archived by the owner on Apr 7, 2021. It is now read-only.

Add tests for fixing APPM-1617 #356

Merged
merged 1 commit into from
Oct 19, 2016
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
@@ -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<String, String> configs;
private StoreHomePage homePage;
private PublisherWebAppsListPage webAppsListPage;

@BeforeClass(alwaysRun = true)
public void startUp() throws Exception {
populateConfigs();
for (Map.Entry<String, String> 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<String, String>();
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<String, String> 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);
}

}
Original file line number Diff line number Diff line change
@@ -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"]
}
Original file line number Diff line number Diff line change
@@ -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"
}
}
Original file line number Diff line number Diff line change
@@ -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"
}
}
1 change: 1 addition & 0 deletions modules/integration/tests-ui/src/test/resources/testng.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
<class name="org.wso2.appmanager.ui.integration.test.cases.publisher.webapp.delete.DeleteWebAppInDeprecatedStatusTestCase" />
<class name="org.wso2.appmanager.ui.integration.test.cases.publisher.webapp.delete.DeleteWebAppInRetiredStateTestCase" />
<class name="org.wso2.appmanager.ui.integration.test.cases.publisher.webapp.delete.DeleteWebAppInUnpublishedStateTestCase" />-->
<!--<class name="org.wso2.appmanager.ui.integration.test.config.TestSecureVaultForJsonConfigFiles" />-->

</classes>

Expand Down