Merge pull request #272 from menakaj/master
Integration Tests : Fixed Android Enrollment flow.merge-requests/1/head
commit
83f4b392a8
@ -1,92 +0,0 @@
|
||||
package org.wso2.iot.integration.util;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.junit.BeforeClass;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Test;
|
||||
import org.wso2.carbon.automation.engine.context.TestUserMode;
|
||||
import org.wso2.carbon.integration.common.admin.client.LogViewerClient;
|
||||
import org.wso2.carbon.integration.common.utils.exceptions.AutomationUtilException;
|
||||
import org.wso2.carbon.integration.common.utils.mgt.ServerConfigurationManager;
|
||||
import org.wso2.carbon.logging.view.stub.LogViewerLogViewerException;
|
||||
import org.wso2.carbon.logging.view.stub.types.carbon.LogEvent;
|
||||
import org.wso2.iot.integration.common.TestBase;
|
||||
|
||||
import javax.xml.xpath.XPathExpressionException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.rmi.RemoteException;
|
||||
import java.util.concurrent.*;
|
||||
|
||||
public class RestartTest extends TestBase {
|
||||
|
||||
private Log log = LogFactory.getLog(RestartTest.class);
|
||||
private LogViewerClient logViewerClient;
|
||||
|
||||
@BeforeClass
|
||||
public void initTest() throws Exception {
|
||||
super.init(TestUserMode.SUPER_TENANT_ADMIN);
|
||||
logViewerClient = new LogViewerClient(getBackendHTTPSURL(), getSessionCookie());
|
||||
}
|
||||
|
||||
@Test(description = "Test restarting the server")
|
||||
public void serverRestartTest() {
|
||||
ServerConfigurationManager serverManager;
|
||||
try {
|
||||
serverManager = new ServerConfigurationManager(automationContext);
|
||||
log.info("Restart Triggered -------------------------------------------------------------------");
|
||||
serverManager.restartGracefully();
|
||||
logViewerClient.getAllRemoteSystemLogs();
|
||||
waitForRestart();
|
||||
} catch (AutomationUtilException | XPathExpressionException | MalformedURLException e) {
|
||||
log.error("Restart failed due to : " + e.getLocalizedMessage());
|
||||
} catch (RemoteException | LogViewerLogViewerException e) {
|
||||
log.error("Cannot get server log due to : " + e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Wait until the server restarts.
|
||||
* This method looks for "Mgt console URL:" to be appeared in the terminal.
|
||||
* If it does not appear within the given timeout an Exception will be thrown.
|
||||
*/
|
||||
private void waitForRestart() {
|
||||
ExecutorService service = Executors.newSingleThreadExecutor();
|
||||
try {
|
||||
Runnable r = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
LogEvent[] logEvents = logViewerClient.getAllRemoteSystemLogs();
|
||||
for (LogEvent event : logEvents) {
|
||||
log.info(event.getMessage() + " @ " + event.getLogTime());
|
||||
if (event.getMessage().contains("Mgt Console URL : " )){
|
||||
log.info("Server restarted successfully");
|
||||
Assert.assertTrue(true);
|
||||
}
|
||||
}
|
||||
} catch (RemoteException | LogViewerLogViewerException e) {
|
||||
log.error("Error reading logs. \n" + e.getMessage());
|
||||
Assert.assertTrue(false);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Future<?> f = service.submit(r);
|
||||
|
||||
f.get(30, TimeUnit.MINUTES);
|
||||
} catch (final InterruptedException e) {
|
||||
log.error("Interrupted "+e.getMessage());
|
||||
Assert.assertTrue(false);
|
||||
} catch (final TimeoutException e) {
|
||||
log.error("Timeout " + e.getMessage());
|
||||
Assert.assertTrue(false);
|
||||
} catch (final ExecutionException e) {
|
||||
log.error("Execution failed " + e.getMessage());
|
||||
Assert.assertTrue(false);
|
||||
} finally {
|
||||
service.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,4 +1,19 @@
|
||||
{
|
||||
"POST": {
|
||||
"responseCode": "OK",
|
||||
"responseMessage": "Android device, which carries the id \u0027d24f870f390352a41\u0027 has successfully been enrolled"
|
||||
"responseMessage": "Android device, which carries the id \u0027d24f870f390352a41234\u0027 has successfully been enrolled"
|
||||
},
|
||||
"GET": {
|
||||
"responseCode": "OK",
|
||||
"responseMessage": "Android device that carries the id \u0027d24f870f390352a41234\u0027 is enrolled"
|
||||
},
|
||||
"PUT": {
|
||||
"responseCode": "Accepted",
|
||||
"responseMessage": "Enrollment of Android device that carries the id \u0027d24f870f390352a41234\u0027 has successfully updated"
|
||||
},
|
||||
"DELETE" : {
|
||||
"responseCode":"OK",
|
||||
"responseMessage":"Android device that carries id \u0027d24f870f390352a41234\u0027 has successfully dis-enrolled"
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
{
|
||||
"default perm:admin-groups:count perm:admin-groups:view perm:admin-users:view perm:admin:certificates:add perm:admin:certificates:delete perm:admin:certificates:details perm:admin:certificates:verify perm:admin:certificates:view perm:admin:devices:view perm:android:blacklist-applications perm:android:change-lock-code perm:android:clear-password perm:android:configure-vpn perm:android:configure-wifi perm:android:control-camera perm:android:disenroll perm:android:encrypt-storage perm:android:enroll perm:android:enterprise-wipe perm:android:info perm:android:install-application perm:android:location perm:android:lock-devices perm:android:logcat perm:android:manage-configuration perm:android:mute perm:android:reboot perm:android:ring perm:android:send-notification perm:android:set-password-policy perm:android:set-webclip perm:android:uninstall-application perm:android:unlock-devices perm:android:update-application perm:android:upgrade-firmware perm:android:view-configuration perm:android:wipe perm:applications:install perm:applications:uninstall perm:dashboard:by-groups perm:dashboard:count-overview perm:dashboard:details perm:dashboard:device-counts perm:dashboard:feature-non-compliant perm:dashboard:filtered-count perm:dashboard:non-compliant perm:dashboard:non-compliant-count perm:dashboard:vulnerabilities perm:device-types:features perm:device-types:types perm:devices:applications perm:devices:compliance-data perm:devices:delete perm:devices:details perm:devices:effective-policy perm:devices:features perm:devices:operations perm:devices:search perm:devices:update perm:devices:view perm:get-activity perm:groups:add perm:groups:assign perm:groups:count perm:groups:device perm:groups:devices perm:groups:devices-add perm:groups:devices-count perm:groups:devices-remove perm:groups:groups perm:groups:groups-view perm:groups:remove perm:groups:roles perm:groups:share perm:groups:update perm:manage-configuration perm:notifications:mark-checked perm:notifications:view perm:policies:activate perm:policies:changes perm:policies:deactivate perm:policies:get-details perm:policies:get-policy-details perm:policies:manage perm:policies:priorities perm:policies:remove perm:policies:update perm:roles:add perm:roles:add-users perm:roles:create-combined-role perm:roles:delete perm:roles:details perm:roles:permissions perm:roles:update perm:roles:view perm:users:add perm:users:count perm:users:credentials perm:users:delete perm:users:details perm:users:is-exist perm:users:roles perm:users:search perm:users:send-invitation perm:users:update perm:users:user-details perm:view-configuration"
|
||||
}
|
Loading…
Reference in new issue