Search in sources :

Example 1 with ViPRClientHelper

use of com.emc.storageos.usermanagement.util.ViPRClientHelper in project coprhd-controller by CoprHD.

the class TenantModificationTest method providerTenantAdminCreateTenant.

@Test
public void providerTenantAdminCreateTenant() throws Exception {
    ViPRClientHelper viPRClientHelper1 = new ViPRClientHelper(tenantAdminClient);
    try {
        viPRClientHelper1.createTenant("testTenant", "secqe.com", "attr", "value");
        Assert.fail("Provider tenant's TenantAdmin should has no permision to create subtenant");
    } catch (ServiceErrorException see) {
        Assert.assertEquals(see.getCode(), 3000);
        Assert.assertTrue(see.getMessage().contains("Insufficient permissions"));
    }
}
Also used : ViPRClientHelper(com.emc.storageos.usermanagement.util.ViPRClientHelper) ServiceErrorException(com.emc.vipr.client.exceptions.ServiceErrorException) Test(org.junit.Test)

Example 2 with ViPRClientHelper

use of com.emc.storageos.usermanagement.util.ViPRClientHelper in project coprhd-controller by CoprHD.

the class TenantMode method setupTenantModeBaseClass.

@BeforeClass
public static synchronized void setupTenantModeBaseClass() throws Exception {
    rootTenantID = superUserClient.getUserTenantId();
    viPRClientHelper = new ViPRClientHelper(superUserClient);
    // keep root tenant's user mapping, will restore it in teardown method
    viPRClientHelper.addRoleAssignment(rootTenantID, superUser, RoleOrAcl.TenantAdmin.toString());
    oldRootTenantUserMappingList = viPRClientHelper.removeTenantUserMapping(rootTenantID);
}
Also used : ViPRClientHelper(com.emc.storageos.usermanagement.util.ViPRClientHelper) BeforeClass(org.junit.BeforeClass)

Example 3 with ViPRClientHelper

use of com.emc.storageos.usermanagement.util.ViPRClientHelper in project coprhd-controller by CoprHD.

the class TenantModificationTest method securityAdminCreateTenant.

@Test
public void securityAdminCreateTenant() throws Exception {
    ViPRClientHelper viPRClientHelper1 = new ViPRClientHelper(secAdminClient);
    try {
        viPRClientHelper1.createTenant("testTenant", "not-exist.com", "attr", "value");
        Assert.fail("should fail, as input domain not exist");
    } catch (ServiceErrorException see) {
        // verify the exception is not insufficent permission.
        Assert.assertNotEquals(see.getCode(), 3000);
        Assert.assertTrue(see.getMessage().contains("Parameter was provided but invalid"));
    }
}
Also used : ViPRClientHelper(com.emc.storageos.usermanagement.util.ViPRClientHelper) ServiceErrorException(com.emc.vipr.client.exceptions.ServiceErrorException) Test(org.junit.Test)

Example 4 with ViPRClientHelper

use of com.emc.storageos.usermanagement.util.ViPRClientHelper in project coprhd-controller by CoprHD.

the class ADMode method setupADModeBaseClass.

@BeforeClass
public static synchronized void setupADModeBaseClass() throws Exception {
    // get super user from parameter, better be AD user
    superUser = System.getProperty("SUPER_USER");
    superUserPassword = System.getProperty("SUPER_USER_PASSWORD");
    if (superUser == null || superUserPassword == null) {
        Properties properties = new Properties();
        properties.load(ClassLoader.class.getResourceAsStream("/test-env.conf"));
        superUser = properties.getProperty("SUPER_USER");
        superUserPassword = properties.getProperty("SUPER_USER_PASSWORD");
    }
    logger.info("security admin: " + superUser + "/" + superUserPassword);
    superUserClient = new ViPRCoreClient(controllerNodeEndpoint, true).withLogin(superUser, superUserPassword);
    ViPRClientHelper helper = new ViPRClientHelper(superUserClient);
    InputStream adFileInputStream = ClassLoader.class.getResourceAsStream(adFile);
    AuthnCreateParam input = XmlUtil.unmarshal(adFileInputStream, AuthnCreateParam.class);
    // for future cleanup, if not exit before the test.
    bAuthnProviderExisted = helper.isAuthnProviderExisted(input);
    // createAuthnProvider will skip creating one, if it already existed
    authnProviderRestRep = helper.createAuthnProvider(input);
    // construct ldapClient, which will be used for creating users on AD server.
    String serverUrl = (String) input.getServerUrls().toArray()[0];
    String domain = (String) input.getDomains().toArray()[0];
    adClient = new ADClient(serverUrl, input.getManagerDn(), input.getManagerPassword(), domain);
}
Also used : ADClient(com.emc.storageos.usermanagement.util.ad.ADClient) ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) InputStream(java.io.InputStream) AuthnCreateParam(com.emc.storageos.model.auth.AuthnCreateParam) Properties(java.util.Properties) ViPRClientHelper(com.emc.storageos.usermanagement.util.ViPRClientHelper) BeforeClass(org.junit.BeforeClass)

Example 5 with ViPRClientHelper

use of com.emc.storageos.usermanagement.util.ViPRClientHelper in project coprhd-controller by CoprHD.

the class GeoMode method setupGeoTenantModeBase.

@BeforeClass
public static void setupGeoTenantModeBase() throws Exception {
    VirtualDataCenters vdcs = superUserClient.vdcs();
    List<NamedRelatedResourceRep> list = vdcs.list();
    for (NamedRelatedResourceRep vdc : list) {
        VirtualDataCenterRestRep restRep = superUserClient.vdcs().get(vdc.getId());
        vdcList.add(restRep);
    }
    if (vdcList.size() < 2) {
        String errorMsg = "env check fail, only one VDC, Geo test need at least 2 vdcs";
        logger.error(errorMsg);
        throw new Exception(errorMsg);
    }
    logger.info("grant " + superUser + " security admin in both VDCs");
    ViPRCoreClient vdc1RootClient = new ViPRCoreClient(getVdcEndpointByIndex(0), true).withLogin("root", rootPassword);
    ViPRClientHelper vdc1Helper = new ViPRClientHelper(vdc1RootClient);
    vdc1Helper.addRoleAssignment(null, superUser, RoleOrAcl.SecurityAdmin.toString());
    vdc1Helper.addRoleAssignment(null, superUser, RoleOrAcl.SystemAdmin.toString());
    vdc1Helper.addRoleAssignment(null, superUser, RoleOrAcl.SystemMonitor.toString());
    vdc1RootClient.auth().logout();
    ViPRCoreClient vdc2RootClient = new ViPRCoreClient(getVdcEndpointByIndex(1), true).withLogin("root", rootPassword);
    ViPRClientHelper vdc2Helper = new ViPRClientHelper(vdc2RootClient);
    vdc2Helper.addRoleAssignment(null, superUser, RoleOrAcl.SecurityAdmin.toString());
    vdc2Helper.addRoleAssignment(null, superUser, RoleOrAcl.SystemAdmin.toString());
    vdc2Helper.addRoleAssignment(null, superUser, RoleOrAcl.SystemMonitor.toString());
    vdc2RootClient.auth().logout();
}
Also used : VirtualDataCenters(com.emc.vipr.client.core.VirtualDataCenters) ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) VirtualDataCenterRestRep(com.emc.storageos.model.vdc.VirtualDataCenterRestRep) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) ViPRClientHelper(com.emc.storageos.usermanagement.util.ViPRClientHelper) BeforeClass(org.junit.BeforeClass)

Aggregations

ViPRClientHelper (com.emc.storageos.usermanagement.util.ViPRClientHelper)5 BeforeClass (org.junit.BeforeClass)3 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)2 ServiceErrorException (com.emc.vipr.client.exceptions.ServiceErrorException)2 Test (org.junit.Test)2 NamedRelatedResourceRep (com.emc.storageos.model.NamedRelatedResourceRep)1 AuthnCreateParam (com.emc.storageos.model.auth.AuthnCreateParam)1 VirtualDataCenterRestRep (com.emc.storageos.model.vdc.VirtualDataCenterRestRep)1 ADClient (com.emc.storageos.usermanagement.util.ad.ADClient)1 VirtualDataCenters (com.emc.vipr.client.core.VirtualDataCenters)1 InputStream (java.io.InputStream)1 Properties (java.util.Properties)1