use of com.emc.storageos.model.auth.AuthnCreateParam in project coprhd-controller by CoprHD.
the class ApiTestAuthnProviders method testAuthnProviderCreateWithLDAPGroupMemberAttributesOnly.
@Test
public void testAuthnProviderCreateWithLDAPGroupMemberAttributesOnly() {
final String testName = "testAuthnProviderCreateWithLDAPGroupMemberAttributesOnly - ";
AuthnCreateParam createParam = getDefaultAuthnCreateParam(testName + TRACE_SUCCESSFUL);
// Remove the group objectClasses from the createParam.
createParam.getGroupObjectClasses().clear();
ClientResponse clientCreateResp = rSys.path(getTestApi()).post(ClientResponse.class, createParam);
// Since the createParam does not contain group objectClasses, the request
// should fail with the below error.
String partialExpectedErrorMsg = AUTHN_PROVIDER_ADD_UPDATE_PARTIAL_ERROR + "modified because of the following error: Group object classes are not provided.";
validateAuthProviderBadRequest(HttpStatus.SC_BAD_REQUEST, partialExpectedErrorMsg, clientCreateResp);
}
use of com.emc.storageos.model.auth.AuthnCreateParam in project coprhd-controller by CoprHD.
the class ApiTestAuthnProviders method testAuthnProviderCreateWithLDAPGroupProperties.
@Test
public void testAuthnProviderCreateWithLDAPGroupProperties() {
final String testName = "testAuthnProviderCreateWithLDAPGroupProperties - ";
AuthnCreateParam createParam = getDefaultAuthnCreateParam(testName + "Invalid group objectClasses and memberAttributes");
// Add some invalid group objectclasses and memberAttributes.
createParam.getGroupObjectClasses().add("some0");
createParam.getGroupObjectClasses().add("some0");
createParam.getGroupObjectClasses().add("some2");
createParam.getGroupObjectClasses().add("some3");
createParam.getGroupMemberAttributes().add("someAttribute0");
createParam.getGroupMemberAttributes().add("someAttribute0");
createParam.getGroupMemberAttributes().add("someAttribute2");
createParam.getGroupMemberAttributes().add("someAttribute3");
createParam.getGroupMemberAttributes().add("someAttribute4");
createParam.getGroupMemberAttributes().add("someAttribute5");
ClientResponse clientCreateResp = rSys.path(getTestApi()).post(ClientResponse.class, createParam);
// Since the createParam contains invalid group ObjectClasses and memberAttributes
// the post request should fail with the below errors. Here the failure will be only for the
// objectClasses. So validate the error message against only the objectClasses error.
String partialExpectedErrorMsg = AUTHN_PROVIDER_ADD_UPDATE_PARTIAL_ERROR + "modified because of the following error: Could not find objectClasses";
validateAuthProviderBadRequest(HttpStatus.SC_BAD_REQUEST, partialExpectedErrorMsg, clientCreateResp);
// Remove the invalid values from group objectClasses and set with default values.
createParam.getGroupObjectClasses().clear();
createParam.setGroupObjectClasses(getDefaultGroupObjectClasses());
createParam.setDescription(testName + "Invalid memberAttributes");
clientCreateResp = rSys.path(getTestApi()).post(ClientResponse.class, createParam);
// After we removal of invalid objectClasses from createParam, it contains only
// invalid group member attributes. So, the post request should fail with the below errors.
// Here the failure will be only for the member attributes.
// So validate the error message against only the member attributes error.
partialExpectedErrorMsg = "The authentication provider could not be added or modified because of the following error: Could not find attributes";
validateAuthProviderBadRequest(HttpStatus.SC_BAD_REQUEST, partialExpectedErrorMsg, clientCreateResp);
// Remove the invalid values from group member attributes and set with default values.
createParam.getGroupMemberAttributes().clear();
createParam.setGroupMemberAttributes(getDefaultGroupMemberAttributes());
createParam.setDescription(testName + TRACE_SUCCESSFUL);
// Now, all the paramaters in the post payload is valid. So the request should be successful.
AuthnProviderRestRep createResp = rSys.path(getTestApi()).post(AuthnProviderRestRep.class, createParam);
validateAuthProviderCreateSuccess(createParam, createResp);
}
use of com.emc.storageos.model.auth.AuthnCreateParam in project coprhd-controller by CoprHD.
the class ApiTestAuthnProviders method testAuthnProviderEditWithLDAPGroupMemberAttributesOnly.
@Test
public void testAuthnProviderEditWithLDAPGroupMemberAttributesOnly() {
final String testName = "testAuthnProviderEditWithLDAPGroupMemberAttributesOnly - ";
AuthnCreateParam createParam = getDefaultAuthnCreateParam(testName + TRACE_AUTHN_PROVIDER_SUCCESSFUL);
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);
// Remove the objectClasses from the editParam.
editParam.getGroupObjectClassChanges().getAdd().clear();
editParam.setDescription(testName + "Edit with only group memberAttributes");
// Now, Send the put request to edit the auth provider with duplicate ldap group properties.
// The reqeust should be be successful and ldap group properties should not have any duplicates.
AuthnProviderRestRep editResp = rSys.path(editAPI).put(AuthnProviderRestRep.class, editParam);
validateAuthProviderEditSuccessForGroupMemberAttributeOnly(editParam, editResp);
// Validate the counts separately to make sure that the counts are removed.
// GroupObjectClasses wont change here as the edit did not change
// the GroupObjectClasses
final int expected = 4;
Assert.assertEquals(expected, editResp.getGroupObjectClasses().size());
Assert.assertEquals(expected, editResp.getGroupMemberAttributes().size());
}
Aggregations