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());
}
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);
}
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);
}
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());
}
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());
}
Aggregations