use of com.emc.storageos.model.auth.AuthnProviderRestRep in project coprhd-controller by CoprHD.
the class ApiTestAuthnProviders method testAuthnProviderCreateWithNullLDAPGroupProperties.
@Test
public void testAuthnProviderCreateWithNullLDAPGroupProperties() {
final String testName = "testAuthnProviderCreateWithNullLDAPGroupProperties - ";
AuthnCreateParam createParam = getDefaultAuthnCreateParam(testName + TRACE_SUCCESSFUL + "(null group objectClasses and memberAttributes)");
// Remove the LDAP Group search properties (Group ObjectClasses and MemberAttributes).
createParam.getGroupObjectClasses().clear();
createParam.setGroupObjectClasses(null);
createParam.getGroupMemberAttributes().clear();
createParam.setGroupMemberAttributes(null);
AuthnProviderRestRep createResp = rSys.path(getTestApi()).post(AuthnProviderRestRep.class, createParam);
validateAuthProviderCreateSuccess(createParam, createResp);
}
use of com.emc.storageos.model.auth.AuthnProviderRestRep in project coprhd-controller by CoprHD.
the class ApiTestAuthnProviders method testAuthnProviderCreateWithoutLDAPGroupProperties.
@Test
public void testAuthnProviderCreateWithoutLDAPGroupProperties() {
final String testName = "testAuthnProviderCreateWithoutLDAPGroupProperties - ";
AuthnCreateParam createParam = getDefaultAuthnCreateParam(testName + "GroupAttribute (\"\")");
// Set the groupAttribute to "", so that the create request will fail, as
// GroupAttribute is an mandatory parameter in the API.
createParam.setGroupAttribute("");
ClientResponse clientCreateResp = rSys.path(getTestApi()).post(ClientResponse.class, createParam);
// Since the createParam contains invalid groupAttribute,
// the post request should fail with the below errors.
String partialExpectedErrorMsg = "Required parameter group_attribute was missing or empty";
validateAuthProviderBadRequest(HttpStatus.SC_BAD_REQUEST, partialExpectedErrorMsg, clientCreateResp);
// Set the groupAttribute to null (to validate if there is no null pointer exception),
// so that the create request will fail, as groupAttribute is an mandatory parameter in the API.
createParam.setGroupAttribute(null);
createParam.setDescription(testName + "GroupAttribute (null)");
clientCreateResp = rSys.path(getTestApi()).post(ClientResponse.class, createParam);
// Since the createParam contains invalid groupAttribute,
// the post request should fail with the below errors.
partialExpectedErrorMsg = AUTHN_PROVIDER_ADD_UPDATE_PARTIAL_ERROR + "modified because of the following error: Could not find group attribute";
validateAuthProviderBadRequest(HttpStatus.SC_BAD_REQUEST, partialExpectedErrorMsg, clientCreateResp);
// Set the groupAttribute to "some" (invalid group attribute. The imported ldap schema does not have an attribute called some),
// so that the create request will fail, as groupAttribute is an mandatory parameter in the API.
createParam.setGroupAttribute("some");
createParam.setDescription(testName + "GroupAttribute (some)");
clientCreateResp = rSys.path(getTestApi()).post(ClientResponse.class, createParam);
// Since the createParam contains invalid groupAttribute,
// the post request should fail with the below errors.
partialExpectedErrorMsg = AUTHN_PROVIDER_ADD_UPDATE_PARTIAL_ERROR + "modified because of the following error: Could not find group attribute";
validateAuthProviderBadRequest(HttpStatus.SC_BAD_REQUEST, partialExpectedErrorMsg, clientCreateResp);
// Remove the LDAP Group search properties (Group ObjectClasses and MemberAttributes).
createParam.setGroupObjectClasses(new HashSet<String>());
createParam.setGroupMemberAttributes(new HashSet<String>());
// Set the groupAttribute to valid groupAttribute to the post to be success.
createParam.setGroupAttribute(getDefaultGroupAttribute());
createParam.setDescription(testName + TRACE_SUCCESSFUL);
AuthnProviderRestRep createResp = rSys.path(getTestApi()).post(AuthnProviderRestRep.class, createParam);
validateAuthProviderCreateSuccess(createParam, createResp);
}
use of com.emc.storageos.model.auth.AuthnProviderRestRep in project coprhd-controller by CoprHD.
the class ApiTestAuthnProviders method testAuthnProviderEditDuplicateLDAPGroupProperties.
@Test
public void testAuthnProviderEditDuplicateLDAPGroupProperties() {
final String testName = "testAuthnProviderEditDuplicateLDAPGroupProperties - ";
AuthnCreateParam createParam = getDefaultAuthnCreateParam(testName + TRACE_AUTHN_PROVIDER_SUCCESSFUL);
// Add the same group objectClasses and memberAttributes to the createParam as duplicates.
createParam.getGroupObjectClasses().addAll(getDefaultGroupObjectClasses());
createParam.getGroupMemberAttributes().addAll(getDefaultGroupMemberAttributes());
AuthnProviderRestRep createResp = rSys.path(getTestApi()).post(AuthnProviderRestRep.class, createParam);
validateAuthProviderCreateSuccess(createParam, createResp);
// Now edit the created authn provider.
final String editAPI = getTestEditApi(createResp.getId());
AuthnUpdateParam editParam = getAuthnUpdateParamFromAuthnProviderRestResp(createResp);
// Add the same group objectClasses and memberAttributes to the editParam as duplicates.
editParam.getGroupObjectClassChanges().getAdd().addAll(getDefaultGroupObjectClasses());
editParam.getGroupObjectClassChanges().getAdd().addAll(getDefaultGroupObjectClasses());
editParam.setDescription(testName + "Edit with Duplicate ldap group properties");
// Now, Send the put request to edit the auth provider with duplicate ldap group properties.
// The request should be be successful and ldap group properties should not have any duplicates.
AuthnProviderRestRep editResp = rSys.path(editAPI).put(AuthnProviderRestRep.class, editParam);
validateAuthProviderEditSuccess(editParam, editResp);
// Validate the counts separately to make sure that the counts are removed.
final int expected = 4;
Assert.assertEquals(expected, createResp.getGroupObjectClasses().size());
Assert.assertEquals(expected, createResp.getGroupMemberAttributes().size());
}
use of com.emc.storageos.model.auth.AuthnProviderRestRep in project coprhd-controller by CoprHD.
the class ApiTestAuthnProviders method validateAuthProviderEditSuccessForGroupMemberAttributeOnly.
private void validateAuthProviderEditSuccessForGroupMemberAttributeOnly(AuthnUpdateParam expected, AuthnProviderRestRep actual) {
validateAuthProviderCommon(expected, actual);
Assert.assertArrayEquals(expected.getGroupMemberAttributeChanges().getAdd().toArray(), actual.getGroupMemberAttributes().toArray());
// Query the APIService about the new edited resource and make
// sure the properties are right in the DB too.
final String getObjectURL = this.getTestEditApi(actual.getId());
AuthnProviderRestRep createResp = rSys.path(getObjectURL).get(AuthnProviderRestRep.class);
Assert.assertNotNull(createResp);
Assert.assertArrayEquals(expected.getGroupMemberAttributeChanges().getAdd().toArray(), createResp.getGroupMemberAttributes().toArray());
}
use of com.emc.storageos.model.auth.AuthnProviderRestRep in project coprhd-controller by CoprHD.
the class ApiTestBase method updateADConfig.
protected void updateADConfig() {
if (rSys == null) {
// Tests depending on what Junit feels like doing that day
try {
rSys = createHttpsClient(SYSADMIN, SYSADMIN_PASS_WORD, baseUrls);
rSys.path("/tenant").get(String.class);
} catch (Exception e) {
Assert.fail();
}
}
AuthnCreateParam param = new AuthnCreateParam();
param.setLabel("ad apitest config good");
param.setDescription("ad configuration created by ApiTest.java");
param.setDisable(false);
// Put spaces in the doman to verify it does not cause a problem
param.getDomains().add(" SANITY.LOCAL ");
param.setGroupAttribute("CN");
param.getGroupWhitelistValues().add("*Admins*");
param.getGroupWhitelistValues().add("*Test*");
param.getGroupWhitelistValues().add("*Users*");
param.setManagerDn("CN=Administrator,CN=Users,DC=sanity,DC=local");
param.setManagerPassword("P@ssw0rd");
param.setSearchBase("DC=sanity,DC=local");
param.setSearchFilter("userPrincipalName=%u");
param.getServerUrls().add("ldap://" + AD_SERVER1_IP);
param.setMode("ad");
param.setSearchScope("SUBTREE");
try {
AuthnProviderRestRep authnResp = rSys.path("/vdc/admin/authnproviders").post(AuthnProviderRestRep.class, param);
Assert.assertNotNull(authnResp);
_goodADConfig = authnResp.getId();
} catch (UniformInterfaceException e) {
if (e.getResponse().getStatus() != 400) {
Assert.fail();
}
} catch (Exception e) {
Assert.fail();
}
}
Aggregations