use of com.emc.storageos.model.auth.AuthnProviderRestRep in project coprhd-controller by CoprHD.
the class ApiTestAuthnProviders method testAuthnProviderEditByRemovingLDAPGroupProperties.
@Test
public void testAuthnProviderEditByRemovingLDAPGroupProperties() {
final String testName = "testAuthnProviderEditByRemovingLDAPGroupProperties - ";
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);
Set<String> addedGroupObjectClasses = new LinkedHashSet<String>();
addedGroupObjectClasses.addAll(editParam.getGroupObjectClassChanges().getAdd());
Set<String> addedGroupMemberAttributes = new LinkedHashSet<String>();
addedGroupMemberAttributes.addAll(editParam.getGroupMemberAttributeChanges().getAdd());
// Remove everything from the add list
editParam.getGroupObjectClassChanges().getAdd().clear();
editParam.getGroupMemberAttributeChanges().getAdd().clear();
// Add everything to the remove list.
editParam.getGroupObjectClassChanges().getRemove().addAll(addedGroupObjectClasses);
editParam.getGroupMemberAttributeChanges().getRemove().addAll(addedGroupMemberAttributes);
editParam.setDescription(testName + "Edit by removing the 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);
editParam = getAuthnUpdateParamFromAuthnProviderRestResp(createResp);
editParam.setDescription(testName + "Edit after removing the ldap group properties to reset with default values");
// 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.
editResp = rSys.path(editAPI).put(AuthnProviderRestRep.class, editParam);
validateAuthProviderEditSuccess(editParam, editResp);
editParam.getGroupObjectClassChanges().getAdd().clear();
editParam.getGroupMemberAttributeChanges().getAdd().clear();
// Add only first two group object classes to the add list.
editParam.getGroupObjectClassChanges().getAdd().add(this.getGroupObjectClass(0));
editParam.getGroupObjectClassChanges().getAdd().add(this.getGroupObjectClass(1));
// Add only last two group object classes to the remove list.
editParam.getGroupObjectClassChanges().getRemove().add(this.getGroupObjectClass(2));
editParam.getGroupObjectClassChanges().getRemove().add(this.getGroupObjectClass(3));
// Add only first two group member attributes to the add list.
editParam.getGroupMemberAttributeChanges().getAdd().add(this.getGroupMemberAttribute(0));
editParam.getGroupMemberAttributeChanges().getAdd().add(this.getGroupMemberAttribute(1));
// Add only last two group member attributes to the remove list.
editParam.getGroupMemberAttributeChanges().getRemove().add(this.getGroupMemberAttribute(2));
editParam.getGroupMemberAttributeChanges().getRemove().add(this.getGroupMemberAttribute(3));
editParam.setDescription(testName + "Edit by removing and adding the ldap group properties in one update");
// 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.
editResp = rSys.path(editAPI).put(AuthnProviderRestRep.class, editParam);
validateAuthProviderEditSuccess(editParam, editResp);
editParam.getGroupObjectClassChanges().getAdd().clear();
editParam.getGroupMemberAttributeChanges().getAdd().clear();
editParam.getGroupObjectClassChanges().getRemove().clear();
editParam.getGroupMemberAttributeChanges().getRemove().clear();
editParam.getGroupObjectClassChanges().getRemove().add(this.getGroupObjectClass(0));
editParam.getGroupObjectClassChanges().getRemove().add(this.getGroupObjectClass(1));
editParam.setDescription(testName + "Edit by just removing all the group object classes only.");
// Now, Send the put request to edit the auth provider to remove all the object classes and keep
// member attributes.
// The request should fail as both group object classes and member attributes
// can be empty or both can have values. Just only one containing values is
// not allowed.
ClientResponse clientEditResp = rSys.path(editAPI).put(ClientResponse.class, editParam);
// Since the createParam does not contain group object classes, 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, clientEditResp);
editParam.getGroupObjectClassChanges().getAdd().clear();
editParam.getGroupMemberAttributeChanges().getAdd().clear();
editParam.getGroupObjectClassChanges().getRemove().clear();
editParam.getGroupMemberAttributeChanges().getRemove().clear();
editParam.getGroupMemberAttributeChanges().getRemove().add(this.getGroupMemberAttribute(0));
editParam.getGroupMemberAttributeChanges().getRemove().add(this.getGroupMemberAttribute(1));
editParam.setDescription(testName + "Edit by just removing all the group member attributes only.");
// Now, Send the put request to edit the auth provider to remove all the member attributes and keep
// object classes.
// The request should fail as both group object classes and member attributes
// can be empty or both can have values. Just only one containing values is
// not allowed.
clientEditResp = rSys.path(editAPI).put(ClientResponse.class, editParam);
// Since the createParam does not contain group member attributes, the request
// should fail with the below error.
partialExpectedErrorMsg = AUTHN_PROVIDER_ADD_UPDATE_PARTIAL_ERROR + "modified because of the following error: Group member attributes are not provided.";
validateAuthProviderBadRequest(HttpStatus.SC_BAD_REQUEST, partialExpectedErrorMsg, clientEditResp);
}
use of com.emc.storageos.model.auth.AuthnProviderRestRep in project coprhd-controller by CoprHD.
the class ApiTestAuthnProviders method validateAuthProviderEditSuccessForGroupObjectClassOnly.
private void validateAuthProviderEditSuccessForGroupObjectClassOnly(AuthnUpdateParam expected, AuthnProviderRestRep actual) {
validateAuthProviderCommon(expected, actual);
Assert.assertArrayEquals(expected.getGroupObjectClassChanges().getAdd().toArray(), actual.getGroupObjectClasses().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.getGroupObjectClassChanges().getAdd().toArray(), createResp.getGroupObjectClasses().toArray());
}
use of com.emc.storageos.model.auth.AuthnProviderRestRep 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.AuthnProviderRestRep 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