Java Code Examples for org.wso2.carbon.automation.engine.context.TestUserMode#TENANT_ADMIN

The following examples show how to use org.wso2.carbon.automation.engine.context.TestUserMode#TENANT_ADMIN . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: InMemoryDSSampleTestCase.java    From product-ei with Apache License 2.0 7 votes vote down vote up
@BeforeClass(alwaysRun = true)
public void initialize() throws Exception {
    super.init(userMode);
    String resourceFileLocation;
    resourceFileLocation = getResourceLocation();
    //DataSource already exist by default for super user.
    if (userMode == TestUserMode.TENANT_ADMIN || userMode == TestUserMode.TENANT_USER) {
        addDataSources();
    }
    deployService(serviceName,
                  new DataHandler(new URL("file:///" + resourceFileLocation +
                                          File.separator + "samples" + File.separator +
                                          "dbs" + File.separator + "inmemory" + File.separator +
                                          "InMemoryDSSample.dbs")));
    log.info(serviceName + " uploaded");
    serviceUrl = getServiceUrlHttp(serviceName);
}
 
Example 2
Source File: ESPublisherTenantAddEditAssetTestCase.java    From product-es with Apache License 2.0 6 votes vote down vote up
@BeforeClass(alwaysRun = true)
public void setUp() throws Exception {
    super.init(userMode);
    currentUserName = userInfo.getUserName();
    currentUserPwd = userInfo.getPassword();
    driver = new ESWebDriver(BrowserManager.getWebDriver());
    baseUrl = getStorePublisherUrl();
    AutomationContext automationContext = new AutomationContext(PRODUCT_GROUP_NAME, TestUserMode.TENANT_ADMIN);
    adminUserName = automationContext.getContextTenant().getTenantAdmin().getUserName();
    adminUserPwd = automationContext.getContextTenant().getTenantAdmin().getPassword();
    backendURL = automationContext.getContextUrls().getBackEndUrl();
    resourceAdminServiceClient = new ResourceAdminServiceClient(backendURL, adminUserName, adminUserPwd);
    this.providerName = currentUserName.split("@")[0];
    this.resourcePath = GADGET_REGISTRY_BASE_PATH + providerName + "/" + assetName + "/" + ASSET_VERSION;
    ESUtil.login(driver, baseUrl, PUBLISHER_APP, currentUserName, currentUserPwd);
}
 
Example 3
Source File: EagerLoadingTestCase.java    From product-ei with Apache License 2.0 6 votes vote down vote up
@BeforeClass(alwaysRun = true)
protected void startServerWithEagerLoading() throws Exception {
    super.init(TestUserMode.SUPER_TENANT_USER);
    serverManager = new ServerConfigurationManager(context);
    AutomationContext autoContext = new AutomationContext();
    // upload a faulty sequence which refer registry resource doesn't exists
    FileUtils.copyFileToDirectory(new File(FrameworkPathUtil.getSystemResourceLocation() +
                                           "/artifacts/ESB/eager/loading/ESBJAVA3602-FaultySeq.xml"),
                                  getSynapseDeploymentDir());

    File carbonXml = new File(FrameworkPathUtil.getSystemResourceLocation() +
                              "/artifacts/ESB/eager/loading/ESBJAVA3602Carbon.xml");
    serverManager.applyConfiguration(carbonXml, getCarbonXmlFile());
    super.init(TestUserMode.TENANT_ADMIN);
    logViewerClient = new LogViewerClient(contextUrls.getBackEndUrl(), getSessionCookie());

}
 
Example 4
Source File: HttpInboundTransportTenantTestCase.java    From product-ei with Apache License 2.0 5 votes vote down vote up
@BeforeClass(alwaysRun = true)
public void setEnvironment() throws Exception {
    super.init(TestUserMode.TENANT_ADMIN);

    addSequence(getArtifactConfig("TestIn.xml"));
    addSequence(getArtifactConfig("reciveSeq.xml"));
    addSequence(getArtifactConfig("TestOut.xml"));
    addInboundEndpoint(getArtifactConfig("synapse.xml"));
    addApi(getArtifactConfig("Test.xml"));
    addInboundEndpoint(getArtifactConfig("apidispatch.xml"));
}
 
Example 5
Source File: UserManagement.java    From product-iots with Apache License 2.0 5 votes vote down vote up
@Test(description = "Test whether the API that is used to get the users returns all the user details.",
        dependsOnMethods = {"testUserCount"})
public void testGetUsers() throws Exception {
    int expectedCount = this.userMode == TestUserMode.TENANT_ADMIN ? 4 : 15;
    String url = Constants.UserManagement.USER_ENDPOINT + "/?offset=0&limit=100";
    HttpResponse response = client.get(url);
    Assert.assertEquals(HttpStatus.SC_OK, response.getResponseCode());
    JsonObject jsonElement = new JsonParser().parse(response.getData()).getAsJsonObject();
    Assert.assertEquals("All the users list is not returned", expectedCount,
            jsonElement.get("users").getAsJsonArray().size());
}
 
Example 6
Source File: UserManagement.java    From product-iots with Apache License 2.0 5 votes vote down vote up
@Test(description = "Test whether correct user count is returned.", dependsOnMethods = {"testIsUserExist"})
public void testUserCount() throws Exception {
    int expectedCount = this.userMode == TestUserMode.TENANT_ADMIN ? 4 : 15;
    String url = Constants.UserManagement.USER_ENDPOINT + "/count";
    HttpResponse response = client.get(url);
    Assert.assertEquals(HttpStatus.SC_OK, response.getResponseCode());
    JsonObject jsonElement = new JsonParser().parse(response.getData()).getAsJsonObject();
    Assert.assertEquals("Actual user count does not match with the returned user count", expectedCount,
            jsonElement.get("count").getAsInt());
}
 
Example 7
Source File: MobileDeviceManagement.java    From product-iots with Apache License 2.0 5 votes vote down vote up
@Test(description = "Test getting devices")
public void testGetUserDevices() throws Exception {
    int expectedCount = this.userMode == TestUserMode.TENANT_ADMIN ? 3 : 13;
    HttpResponse response = client.get(Constants.MobileDeviceManagement.GET_ALL_DEVICES_ENDPOINT
            + Constants.MobileDeviceManagement.USER_DEVICE_ENDPOINT);
    Assert.assertEquals(HttpStatus.SC_OK, response.getResponseCode());
    JsonObject devices = new JsonParser().parse(response.getData()).getAsJsonObject();
    Assert.assertEquals("Expected device count is not received", expectedCount, devices.get("count").getAsInt());
}
 
Example 8
Source File: TestBase.java    From product-iots with Apache License 2.0 5 votes vote down vote up
@DataProvider
public static Object[][] userModeProvider() {
    return new TestUserMode[][]{
            new TestUserMode[]{TestUserMode.SUPER_TENANT_ADMIN},
            new TestUserMode[]{TestUserMode.TENANT_ADMIN}
    };
}
 
Example 9
Source File: ESBJAVA3611EndpointTestCase.java    From product-ei with Apache License 2.0 5 votes vote down vote up
@BeforeClass(alwaysRun = true)
protected void uploadCarFileTest() throws Exception {
    super.init(TestUserMode.TENANT_ADMIN);
    uploadCapp(carFileName
               , new DataHandler(new FileDataSource(new File(getESBResourceLocation() +
                                                            File.separator + "car" + File.separator +
                                                            carFileName))));
    log.info(carFileName + " uploaded successfully");
}
 
Example 10
Source File: ESBJAVA5069AccessSwaggerTenantTestCase.java    From product-ei with Apache License 2.0 5 votes vote down vote up
@BeforeClass(alwaysRun = true)
public void setEnvironment() throws Exception {
    super.init(TestUserMode.TENANT_ADMIN);
    String artifactPath = "artifacts" + File.separator + "ESB" + File.separator + "api" + File.separator
            + "Tenant.xml";
    loadESBConfigurationFromClasspath(artifactPath);
}
 
Example 11
Source File: ESStoreTenantUserTUHomePageTestCase.java    From product-es with Apache License 2.0 5 votes vote down vote up
public void login() throws Exception {
    super.init(TestUserMode.TENANT_ADMIN);
    currentUserName = userInfo.getUserName();
    currentUserPwd = userInfo.getPassword();
    buildTenantDetails(TestUserMode.TENANT_ADMIN);
    ESUtil.login(driver, baseUrl, STORE_APP, currentUserName, currentUserPwd);
}
 
Example 12
Source File: DSSIntegrationTest.java    From product-ei with Apache License 2.0 5 votes vote down vote up
private void validateServiceUrl(String serviceUrl, Tenant tenant) {
    //if user mode is null can not validate the service url
    if (userMode != null) {
        if ((userMode == TestUserMode.TENANT_ADMIN || userMode == TestUserMode.TENANT_USER)) {
            Assert.assertTrue(serviceUrl.contains("/t/" + tenant.getDomain() + "/"), "invalid service url for tenant. " + serviceUrl);
        } else {
            Assert.assertFalse(serviceUrl.contains("/t/"), "Invalid service url for user. " + serviceUrl);
        }
    }
}
 
Example 13
Source File: VirtualFireAlarmTestCase.java    From product-iots with Apache License 2.0 5 votes vote down vote up
@Test(description = "This test case tests the virtual fire alarm enrollment")
public void testEnrollment() throws Exception {
    // Time for deploying the carbon apps
    Thread.sleep(30000);
    RestClient client = new RestClient(backendHTTPSURL, Constants.APPLICATION_ZIP, accessTokenString);
    // Enroll an advanced agent and check whether that enrollment succeeds without issues.
    HttpResponse response = client.get(Constants.VirtualFireAlarmConstants.ENROLLMENT_ENDPOINT
            + "?deviceName=advanced&sketchType=virtual_firealarm_advanced");
    Assert.assertEquals("Advance fire alarm advance agent enrollment failed", HttpStatus.SC_OK,
            response.getResponseCode());

    // Enroll an simple agent and check whether that enrollment succeeds without issues.
    response = client.get(Constants.VirtualFireAlarmConstants.ENROLLMENT_ENDPOINT
            + "?deviceName=simple&sketchType=virtual_firealarm");
    Assert.assertEquals("Advance fire alarm advance agent enrollment failed", HttpStatus.SC_OK,
            response.getResponseCode());

    response = client.get(Constants.MobileDeviceManagement.GET_DEVICE_COUNT_ENDPOINT + "?type=virtual_firealarm");
    JsonArray jsonArray = new JsonParser().parse(response.getData()).getAsJsonObject().getAsJsonArray("devices");
    Assert.assertEquals("Virtual fire alarm enrollment failed ", 2, jsonArray.size());

    if (userMode != TestUserMode.TENANT_ADMIN) {
        deviceId1 = jsonArray.get(0).getAsJsonObject().getAsJsonPrimitive("deviceIdentifier").getAsString();
        deviceId2 = jsonArray.get(1).getAsJsonObject().getAsJsonPrimitive("deviceIdentifier").getAsString();
    } else {
        tenantDeviceId1 = jsonArray.get(0).getAsJsonObject().getAsJsonPrimitive("deviceIdentifier").getAsString();
        tenantDeviceId2 = jsonArray.get(1).getAsJsonObject().getAsJsonPrimitive("deviceIdentifier").getAsString();
    }
}
 
Example 14
Source File: InMemoryDSSampleTestCase.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
@BeforeClass(alwaysRun = true)
public void initialize() throws Exception {
    super.init();
    String resourceFileLocation;
    resourceFileLocation = getResourceLocation();
    //DataSource already exist by default for super user.
    if (userMode == TestUserMode.TENANT_ADMIN || userMode == TestUserMode.TENANT_USER) {
        addDataSources();
    }
    deployService(serviceName, new DataHandler(
            new URL("file:///" + resourceFileLocation + File.separator + "samples" + File.separator + "dbs"
                    + File.separator + "inmemory" + File.separator + "InMemoryDSSample.dbs")));
    log.info(serviceName + " uploaded");
    serviceUrl = getServiceUrlHttp(serviceName);
}
 
Example 15
Source File: VirtualFireAlarmTestCase.java    From product-iots with Apache License 2.0 5 votes vote down vote up
@BeforeClass(alwaysRun = true)
public void initTest() throws Exception {
    super.init(userMode);
    restClient = new RestClient(backendHTTPSURL, Constants.APPLICATION_JSON, accessTokenString);
    if (userMode == TestUserMode.TENANT_ADMIN) {
        HttpResponse response = restClient
                .post(Constants.VirtualFireAlarmConstants.ANALYTICS_ARTIFACTS_DEPLOYMENT_ENDPOINT, "");
        Assert.assertEquals(HttpStatus.SC_CREATED, response.getResponseCode());
    }
}
 
Example 16
Source File: DSSIntegrationTest.java    From micro-integrator with Apache License 2.0 4 votes vote down vote up
protected boolean isTenant() throws Exception {
    if (userMode == null) {
        throw new Exception("UserMode Not Initialized. Can not identify user type");
    }
    return (userMode == TestUserMode.TENANT_ADMIN || userMode == TestUserMode.TENANT_USER);
}
 
Example 17
Source File: HttpInboundDispatchTestCase.java    From product-ei with Apache License 2.0 4 votes vote down vote up
@Test(groups = "wso2.esb", description = "Inbound HTTP Tenant Dispatch " +
        "(Shared Port between super tenant and regular tenant)" )
public void inboundHttpTenantDispatchTests() throws Exception {
    super.init(TestUserMode.TENANT_ADMIN);

    List<OMElement> seqList = new ArrayList<>();
    seqList.add(getArtifactConfig("tenant/sequences", "main.xml"));
    seqList.add(getArtifactConfig("tenant/sequences", "fault.xml"));
    seqList.add(getArtifactConfig("tenant/sequences", "tenant.xml"));
    addSequence(seqList.get(0));
    addSequence(seqList.get(1));
    addSequence(seqList.get(2));

    List<OMElement> apiList = new ArrayList<>();
    apiList.add(getArtifactConfig("tenant/api", "tenantAPI.xml"));
    addApi(apiList.get(0));

    List<OMElement> proxyList = new ArrayList<>();
    proxyList.add(getArtifactConfig("tenant/proxy-services", "TestProxy.xml"));
    addProxyService(proxyList.get(0));

    List<OMElement> inboundList = new ArrayList<>();
    inboundList.add(getArtifactConfig("tenant/inbound-endpoints", "ie1.xml"));
    addInboundEndpoint(inboundList.get(0));

    Awaitility.await()
              .pollInterval(50, TimeUnit.MILLISECONDS)
              .atMost(300, TimeUnit.SECONDS)
              .until(isServiceDeployed(seqList, inboundList, proxyList));
    logViewerClient.clearLogs();

    axis2Client.sendSimpleStockQuoteRequest("http://localhost:9090/t/wso2.com/tenantAPI", null, "WSO2");
    Assert.assertTrue(stringExistsInLog("TENANT_API"), "Dispatch to http://localhost:9090/t/wso2.com/tenantAPI");

    axis2Client.sendSimpleStockQuoteRequest("http://localhost:9090/t/wso2.com/", null, "WSO2");
    Assert.assertTrue(stringExistsInLog("SUB_TENANT"), "Dispatch to http://localhost:9090/t/wso2.com/");

    axis2Client.sendSimpleStockQuoteRequest("http://localhost:9090/services/t/wso2.com/TestProxy", null, "WSO2");
    Assert.assertTrue(stringExistsInLog("TENANT_PROXY_HIT"),
            "Dispatch to http://localhost:9090/services/t/wso2.com/TestProxy");

    /**
     * Test non existent tenant - should hit carbon super (or dispatch to any API with tenant like context on carbon super).
     */
    axis2Client.sendSimpleStockQuoteRequest("http://localhost:9090/t/idontexist", null, "WSO2");
    //matches with inbound regex but no api or proxy should be dispatched to super tenant main sequence
    Assert.assertTrue(stringExistsInLog("SUPER_MAIN"), "Dispatch to http://localhost:9090/t/idontexist");

    axis2Client.sendSimpleStockQuoteRequest("http://localhost:9090/t/idoexistassupertenantapi", null, "WSO2");
    Assert.assertTrue(stringExistsInLog("SUPER_TENANT_API_WITH_TENANT_CONTEXT"),
            "Dispatch to http://localhost:9090/t/idoexistassupertenantapi");
}
 
Example 18
Source File: ESPublisherTenantAddEditAssetTestCase.java    From product-es with Apache License 2.0 4 votes vote down vote up
@DataProvider(name = "userMode")
private static Object[][] userModeProvider() {
    return new Object[][]{{TestUserMode.TENANT_ADMIN, "Add Edit asset - TenantAdmin"},
            {TestUserMode.TENANT_USER, "Add Edit asset - TenantUser"}};
}
 
Example 19
Source File: ESPublisherTenantNotificationTestCase.java    From product-es with Apache License 2.0 4 votes vote down vote up
@DataProvider(name = "userMode")
private static Object[][] userModeProvider() {
    return new Object[][]{{TestUserMode.TENANT_ADMIN, "Notification asset - TenantAdmin"},
            {TestUserMode.TENANT_USER, "Notification asset - TenantUser"}};
}
 
Example 20
Source File: JSONPayloadProperFormatTenantModeTestCase.java    From product-ei with Apache License 2.0 4 votes vote down vote up
@BeforeClass(alwaysRun = true)
public void deployService() throws Exception {
    super.init(TestUserMode.TENANT_ADMIN);
}