public void deleteUsers() throws Exception {
   String tenantAdminSession;
   AutomationContext automationContext =
       new AutomationContext(productGroupName, instanceName, TestUserMode.SUPER_TENANT_ADMIN);
   UserManagementClient userManagementClient;
   for (String tenants : tenantsList) {
     String superTenantReplacement = AutomationXpathConstants.TENANTS;
     if (tenants.equals(FrameworkConstants.SUPER_TENANT_DOMAIN_NAME)) {
       superTenantReplacement = AutomationXpathConstants.SUPER_TENANT;
     }
     backendURL = automationContext.getContextUrls().getBackEndUrl();
     tenantAdminSession =
         login(
             automationContext.getConfigurationValue(
                 String.format(
                     AutomationXpathConstants.ADMIN_USER_USERNAME,
                     superTenantReplacement,
                     tenants)),
             tenants,
             automationContext.getConfigurationValue(
                 String.format(
                     AutomationXpathConstants.ADMIN_USER_PASSWORD,
                     superTenantReplacement,
                     tenants)),
             backendURL,
             UrlGenerationUtil.getManagerHost(automationContext.getInstance()));
     userManagementClient = new UserManagementClient(backendURL, tenantAdminSession);
     List<String> userList = getUserList(tenants);
     for (String user : userList) {
       boolean isUserAddedAlready =
           userManagementClient
               .getUserList()
               .contains(
                   automationContext.getConfigurationValue(
                       String.format(
                           AutomationXpathConstants.TENANT_USER_USERNAME,
                           superTenantReplacement,
                           tenants,
                           user)));
       if (isUserAddedAlready) {
         if (!user.equals(FrameworkConstants.ADMIN_ROLE)) {
           userManagementClient.deleteUser(
               automationContext.getConfigurationValue(
                   String.format(
                       AutomationXpathConstants.TENANT_USER_USERNAME,
                       superTenantReplacement,
                       tenants,
                       user)));
           log.info(user + " user deleted successfully");
         }
       }
     }
   }
 }
コード例 #2
0
 public PPaaSIntegrationTest() throws Exception {
   ppaasAutomationCtx =
       new AutomationContext("PPAAS", "ppaas-001", TestUserMode.SUPER_TENANT_ADMIN);
   adminUsername =
       ppaasAutomationCtx.getConfigurationValue(
           "/automation/userManagement/superTenant/tenant/admin/user/userName");
   adminPassword =
       ppaasAutomationCtx.getConfigurationValue(
           "/automation/userManagement/superTenant/tenant/admin/user/password");
   restClient =
       new RestClient(
           ppaasAutomationCtx.getContextUrls().getWebAppURL(),
           ppaasAutomationCtx.getContextUrls().getWebAppURLHttps(),
           adminUsername,
           adminPassword);
   String mockIaaSEndpoint = ppaasAutomationCtx.getContextUrls().getWebAppURL() + "/mock-iaas/api";
   mockIaasApiClient = new IntegrationMockClient(mockIaaSEndpoint);
   log.info("Mock IaaS endpoint URL: " + mockIaaSEndpoint);
 }
 public void populateUsers() throws Exception {
   String tenantAdminSession;
   UserManagementClient userManagementClient;
   AutomationContext automationContext =
       new AutomationContext(productGroupName, instanceName, TestUserMode.SUPER_TENANT_ADMIN);
   backendURL = automationContext.getContextUrls().getBackEndUrl();
   sessionCookie = automationContext.login();
   tenantStub = new TenantManagementServiceClient(backendURL, sessionCookie);
   // tenants is the domain of the tenants elements
   for (String tenants : tenantsList) {
     if (!tenants.equals(FrameworkConstants.SUPER_TENANT_DOMAIN_NAME)) {
       tenantStub.addTenant(
           tenants,
           automationContext.getConfigurationValue(
               String.format(
                   AutomationXpathConstants.ADMIN_USER_PASSWORD,
                   AutomationXpathConstants.TENANTS,
                   tenants)),
           automationContext.getConfigurationValue(
               String.format(
                   AutomationXpathConstants.ADMIN_USER_USERNAME,
                   AutomationXpathConstants.TENANTS,
                   tenants)),
           FrameworkConstants.TENANT_USAGE_PLAN_DEMO);
     }
     log.info("Start populating users for " + tenants);
     String superTenantReplacement = AutomationXpathConstants.TENANTS;
     if (tenants.equals(FrameworkConstants.SUPER_TENANT_DOMAIN_NAME)) {
       superTenantReplacement = AutomationXpathConstants.SUPER_TENANT;
     }
     tenantAdminSession =
         login(
             automationContext.getConfigurationValue(
                 String.format(
                     AutomationXpathConstants.ADMIN_USER_USERNAME,
                     superTenantReplacement,
                     tenants)),
             tenants,
             automationContext.getConfigurationValue(
                 String.format(
                     AutomationXpathConstants.ADMIN_USER_PASSWORD,
                     superTenantReplacement,
                     tenants)),
             backendURL,
             UrlGenerationUtil.getManagerHost(automationContext.getInstance()));
     // here we populate the user list of the current tenant
     List<String> userList = getUserList(tenants);
     userManagementClient = new UserManagementClient(backendURL, tenantAdminSession);
     for (String tenantUsername : userList) {
       System.out.println(userManagementClient.getUserList().size());
       boolean isUserAddedAlready =
           userManagementClient
               .getUserList()
               .contains(
                   automationContext.getConfigurationValue(
                       String.format(
                           AutomationXpathConstants.TENANT_USER_USERNAME,
                           superTenantReplacement,
                           tenants,
                           tenantUsername)));
       if (!isUserAddedAlready) {
         userManagementClient.addUser(
             automationContext.getConfigurationValue(
                 String.format(
                     AutomationXpathConstants.TENANT_USER_USERNAME,
                     superTenantReplacement,
                     tenants,
                     tenantUsername)),
             automationContext.getConfigurationValue(
                 String.format(
                     AutomationXpathConstants.TENANT_USER_PASSWORD,
                     superTenantReplacement,
                     tenants,
                     tenantUsername)),
             new String[] {FrameworkConstants.ADMIN_ROLE},
             null);
         log.info("Populated " + tenantUsername);
       } else {
         if (!tenantUsername.equals(ExtensionCommonConstants.ADMIN_USER)) {
           log.info(tenantUsername + " is already in " + tenants);
         }
       }
     }
   }
 }