Search in sources :

Example 11 with AuthnCreateParam

use of com.emc.storageos.model.auth.AuthnCreateParam in project coprhd-controller by CoprHD.

the class ApiTest method adConfigListTests.

private void adConfigListTests() {
    AuthnProviderList resp = rSys.path("/vdc/admin/authnproviders").get(AuthnProviderList.class);
    int sz = resp.getProviders().size();
    // Add one more, then one with no name field. The new total should be sz + 2.
    AuthnCreateParam param = new AuthnCreateParam();
    param.setLabel("ad apitest config one");
    param.setDescription("ad configuration created by ApiTest.java");
    param.setDisable(false);
    param.getDomains().add("sanity3.local");
    param.setGroupAttribute("CN");
    param.setGroupWhitelistValues(new HashSet<String>());
    param.getGroupWhitelistValues().add("*Admins*");
    param.getGroupWhitelistValues().add("*Test*");
    param.getGroupWhitelistValues().add("*Users*");
    param.setManagerDn("CN=Administrator,CN=Users,DC=sanity,DC=local");
    param.setManagerPassword(AD_PASS_WORD);
    param.setSearchBase("CN=Users,DC=sanity,DC=local");
    param.setSearchFilter("userPrincipalName=%u");
    param.setServerUrls(new HashSet<String>());
    param.getServerUrls().add("ldap:\\" + AD_SERVER1_IP);
    param.getServerUrls().add("ldap:\\" + AD_SERVER1_HOST);
    param.setMode("ad");
    ClientResponse resp2 = rSys.path("/vdc/admin/authnproviders").post(ClientResponse.class, param);
    Assert.assertEquals(200, resp2.getStatus());
    param.setLabel("ad apitest config two");
    param.getDomains().remove("sanity3.local");
    param.getDomains().add("another.com");
    AuthnProviderRestRep authnResp = rSys.path("/vdc/admin/authnproviders").post(AuthnProviderRestRep.class, param);
    Assert.assertNotNull(authnResp);
    resp = rSys.path("/vdc/admin/authnproviders").get(AuthnProviderList.class);
    int sz2 = resp.getProviders().size();
    Assert.assertEquals(sz2, sz + 2);
    // update test
    AuthnUpdateParam updateParam = new AuthnUpdateParam();
    updateParam.setLabel("ad apitest config two");
    updateParam.getDomainChanges().setRemove(new HashSet<String>());
    updateParam.getDomainChanges().getRemove().add("another.com");
    updateParam.getGroupWhitelistValueChanges().setRemove(new HashSet<String>());
    updateParam.getGroupWhitelistValueChanges().getRemove().add("*Admins*");
    updateParam.getGroupWhitelistValueChanges().getRemove().add("*Test*");
    updateParam.getGroupWhitelistValueChanges().getRemove().add("*Users*");
    updateParam.getServerUrlChanges().setRemove(new HashSet<String>());
    updateParam.getServerUrlChanges().getRemove().add("ldap:\\" + AD_SERVER1_HOST);
    AuthnProviderRestRep authnResp2 = rSys.path("/vdc/admin/authnproviders/" + authnResp.getId().toString() + "/").put(AuthnProviderRestRep.class, updateParam);
    Assert.assertNotNull(authnResp2);
    Assert.assertEquals(0, authnResp2.getDomains().size());
    Assert.assertEquals(0, authnResp2.getGroupWhitelistValues().size());
    Assert.assertEquals(1, authnResp2.getServerUrls().size());
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) AuthnUpdateParam(com.emc.storageos.model.auth.AuthnUpdateParam) AuthnCreateParam(com.emc.storageos.model.auth.AuthnCreateParam) AuthnProviderList(com.emc.storageos.model.auth.AuthnProviderList) AuthnProviderRestRep(com.emc.storageos.model.auth.AuthnProviderRestRep)

Example 12 with AuthnCreateParam

use of com.emc.storageos.model.auth.AuthnCreateParam 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 13 with AuthnCreateParam

use of com.emc.storageos.model.auth.AuthnCreateParam in project coprhd-controller by CoprHD.

the class TrustStoreTest method addLDAPSAuthProvider.

/**
 * @return
 */
private ClientResponse addLDAPSAuthProvider() {
    AuthnCreateParam param = new AuthnCreateParam();
    param.setLabel("ldaps apitest config");
    param.setDescription("ldaps configuration created by ApiTest.java");
    param.setDisable(false);
    param.getDomains().add("secureldap.com");
    param.setManagerDn("CN=Manager,DC=root,DC=com");
    param.setManagerPassword("secret");
    param.setSearchBase("OU=People,DC=root,DC=com");
    param.setSearchFilter("mail=%u");
    param.setServerUrls(new HashSet<String>());
    param.getServerUrls().add("ldaps:\\" + LDAP_SERVER1_IP);
    param.setMode("ldap");
    return rSys.path("/vdc/admin/authnproviders").post(ClientResponse.class, param);
}
Also used : AuthnCreateParam(com.emc.storageos.model.auth.AuthnCreateParam)

Example 14 with AuthnCreateParam

use of com.emc.storageos.model.auth.AuthnCreateParam in project coprhd-controller by CoprHD.

the class ApiTest method loneAuthnProviderDeleteTest.

// quick test to see that one can create and delete
// a provider with no errors if there are no tenants associated
public void loneAuthnProviderDeleteTest() throws Exception {
    AuthnCreateParam param = new AuthnCreateParam();
    param.setLabel("ldaps apitest config");
    param.setDescription("ldaps configuration created by ApiTest.java");
    param.setDisable(false);
    param.getDomains().add("secureldap.com");
    param.getDomains().add("someotherdomain2.com");
    param.setManagerDn("CN=Manager,DC=root,DC=com");
    param.setManagerPassword("secret");
    param.setSearchBase("OU=People,DC=root,DC=com");
    param.setSearchFilter("mail=%u");
    param.setServerUrls(new HashSet<String>());
    param.getServerUrls().add("ldaps:\\" + LDAP_SERVER1_IP);
    param.setMode("ldap");
    AuthnProviderRestRep resp = rSys.path("/vdc/admin/authnproviders").post(AuthnProviderRestRep.class, param);
    Assert.assertNotNull(resp);
    // update by removing a domain should work because neither are used by any tenants
    AuthnUpdateParam updateParam = new AuthnUpdateParam();
    updateParam.getDomainChanges().getRemove().add("someotherdomain2.com");
    ClientResponse response = rSys.path("/vdc/admin/authnproviders/" + resp.getId()).put(ClientResponse.class, updateParam);
    Assert.assertEquals(200, response.getStatus());
    // disable, delete, should work, because there are no tenants associated
    // with it.
    // disable it
    updateParam = new AuthnUpdateParam();
    updateParam.setDisable(true);
    response = rSys.path("/vdc/admin/authnproviders/" + resp.getId()).put(ClientResponse.class, updateParam);
    Assert.assertEquals(200, response.getStatus());
    // delete it
    response = rSys.path("/vdc/admin/authnproviders/" + resp.getId()).delete(ClientResponse.class);
    Assert.assertEquals(200, response.getStatus());
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) AuthnUpdateParam(com.emc.storageos.model.auth.AuthnUpdateParam) AuthnCreateParam(com.emc.storageos.model.auth.AuthnCreateParam) AuthnProviderRestRep(com.emc.storageos.model.auth.AuthnProviderRestRep)

Example 15 with AuthnCreateParam

use of com.emc.storageos.model.auth.AuthnCreateParam in project coprhd-controller by CoprHD.

the class ApiTest method disabledAuthnProviderTest.

/**
 * test tenantCreation will fail, if the authn provider is disabled
 *
 * @throws Exception
 */
public void disabledAuthnProviderTest() throws Exception {
    // create a disabled authn provider
    String domain = "secqe.com";
    AuthnCreateParam param = new AuthnCreateParam();
    param.setLabel("secqe.com");
    param.setDescription("ad apitest disabled auth provider");
    param.setDisable(true);
    param.getDomains().add(domain);
    param.setGroupAttribute("CN");
    param.setManagerDn("CN=Administrator,CN=Users,DC=secqe,DC=com");
    param.setManagerPassword(AD_PASS_WORD);
    param.setSearchBase("CN=Users,DC=secqe,DC=com");
    param.setSearchFilter("userPrincipalName=%u");
    param.setServerUrls(new HashSet<String>());
    param.getServerUrls().add("ldap:\\" + AD_SERVER2_IP);
    param.setMode("ad");
    AuthnProviderRestRep resp = rSys.path("/vdc/admin/authnproviders").post(AuthnProviderRestRep.class, param);
    Assert.assertNotNull(resp.getId());
    // create tenant against the disabled authn provider, should fail
    String groupName = "e2egroup";
    ClientResponse response = createTenant("disabled_tenant" + new Random().nextInt(), domain, groupName);
    Assert.assertEquals(400, response.getStatus());
    // enable the authn provider
    AuthnUpdateParam updateParam = new AuthnUpdateParam();
    updateParam.setDisable(false);
    response = rSys.path("/vdc/admin/authnproviders/" + resp.getId()).put(ClientResponse.class, updateParam);
    Assert.assertEquals(200, response.getStatus());
    // create the tenant again, should success
    response = createTenant("disabled_tenant" + new Random().nextInt(), domain, groupName);
    Assert.assertEquals(200, response.getStatus());
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) AuthnUpdateParam(com.emc.storageos.model.auth.AuthnUpdateParam) Random(java.util.Random) AuthnCreateParam(com.emc.storageos.model.auth.AuthnCreateParam) AuthnProviderRestRep(com.emc.storageos.model.auth.AuthnProviderRestRep)

Aggregations

AuthnCreateParam (com.emc.storageos.model.auth.AuthnCreateParam)23 AuthnProviderRestRep (com.emc.storageos.model.auth.AuthnProviderRestRep)18 Test (org.junit.Test)13 AuthnUpdateParam (com.emc.storageos.model.auth.AuthnUpdateParam)12 ClientResponse (com.sun.jersey.api.client.ClientResponse)12 AuthnProviderList (com.emc.storageos.model.auth.AuthnProviderList)1 TenantCreateParam (com.emc.storageos.model.tenant.TenantCreateParam)1 UserMappingAttributeParam (com.emc.storageos.model.tenant.UserMappingAttributeParam)1 UserMappingParam (com.emc.storageos.model.tenant.UserMappingParam)1 ViPRClientHelper (com.emc.storageos.usermanagement.util.ViPRClientHelper)1 ADClient (com.emc.storageos.usermanagement.util.ad.ADClient)1 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)1 ClientHandlerException (com.sun.jersey.api.client.ClientHandlerException)1 UniformInterfaceException (com.sun.jersey.api.client.UniformInterfaceException)1 InputStream (java.io.InputStream)1 URI (java.net.URI)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 HashSet (java.util.HashSet)1 LinkedHashSet (java.util.LinkedHashSet)1 Properties (java.util.Properties)1