use of com.emc.storageos.model.auth.AuthnUpdateParam in project coprhd-controller by CoprHD.
the class ApiTestAuthnProviderUtils method getAuthnUpdateParamFromAuthnProviderRestResp.
public AuthnUpdateParam getAuthnUpdateParamFromAuthnProviderRestResp(AuthnProviderRestRep createResponse) {
AuthnUpdateParam param = new AuthnUpdateParam();
param.setLabel(createResponse.getName());
param.setDescription(createResponse.getDescription());
param.setDisable(createResponse.getDisable());
param.getDomainChanges().getAdd().addAll(createResponse.getDomains());
param.getDomainChanges().getRemove().addAll(new HashSet<String>());
param.setManagerDn(createResponse.getManagerDN());
param.setManagerPassword(DEFAULT_TEST_LDAP_SERVER_MANAGER_DN_PWD);
param.setSearchBase(createResponse.getSearchBase());
param.setSearchFilter(createResponse.getSearchFilter());
param.getServerUrlChanges().getAdd().addAll(createResponse.getServerUrls());
param.getServerUrlChanges().getRemove().addAll(new HashSet<String>());
param.setMode(createResponse.getMode());
param.setGroupAttribute(createResponse.getGroupAttribute());
param.setSearchScope(createResponse.getSearchScope());
param.getGroupObjectClassChanges().getAdd().addAll(createResponse.getGroupObjectClasses());
param.getGroupMemberAttributeChanges().getAdd().addAll(createResponse.getGroupMemberAttributes());
return param;
}
use of com.emc.storageos.model.auth.AuthnUpdateParam in project coprhd-controller by CoprHD.
the class ApiTestAuthnProviders method testAuthnProviderEditWithLDAPGroupPropertiesAndNonManagerDN.
@Test
public void testAuthnProviderEditWithLDAPGroupPropertiesAndNonManagerDN() {
final String testName = "testAuthnProviderEditWithLDAPGroupPropertiesAndNonManagerDN - ";
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);
// overwrite the managerdn with some user information. Just to make sure that ldap schema schema search
// does not need only the managerdn's.
editParam.setManagerDn(getNonManagerBindDN());
editParam.setManagerPassword(getNonManagerBindDNPwd());
editParam.setDescription(testName + "Edit with Non Mananger DN user");
// 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);
validateAuthProviderEditSuccess(editParam, editResp);
}
use of com.emc.storageos.model.auth.AuthnUpdateParam in project coprhd-controller by CoprHD.
the class ApiTestAuthnProviders method testAuthnProviderEditWithLDAPGroupObjectClassesOnly.
@Test
public void testAuthnProviderEditWithLDAPGroupObjectClassesOnly() {
final String testName = "testAuthnProviderEditWithLDAPGroupObjectClassesOnly - ";
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 memberAttributes from the editParam.
editParam.getGroupMemberAttributeChanges().getAdd().clear();
editParam.setDescription(testName + "Edit with only group objectClasses");
// 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);
validateAuthProviderEditSuccessForGroupObjectClassOnly(editParam, editResp);
// Validate the counts separately to make sure that the counts are removed.
// GroupMemberAttributes wont change here as the edit did not change
// the GroupMemberAttributes
final int expected = 4;
Assert.assertEquals(expected, editResp.getGroupObjectClasses().size());
Assert.assertEquals(expected, editResp.getGroupMemberAttributes().size());
}
use of com.emc.storageos.model.auth.AuthnUpdateParam in project coprhd-controller by CoprHD.
the class ApiTestAuthnProviders method testAuthnProviderEditWithLDAPGroupProperties.
@Test
public void testAuthnProviderEditWithLDAPGroupProperties() {
final String testName = "testAuthnProviderEditWithLDAPGroupProperties - ";
AuthnCreateParam createParam = getDefaultAuthnCreateParam(testName + "Creating default authn provider for edit");
AuthnProviderRestRep createResp = rSys.path(getTestApi()).post(AuthnProviderRestRep.class, createParam);
// Succesful authn provider creation with default values.
validateAuthProviderCreateSuccess(createParam, createResp);
// Now edit the created authn provider.
final String editAPI = getTestEditApi(createResp.getId());
AuthnUpdateParam editParam = getAuthnUpdateParamFromAuthnProviderRestResp(createResp);
// Adding some invalid group objectClasses and memberAttributes at the time of edit.
editParam.getGroupObjectClassChanges().getAdd().add("some1");
editParam.getGroupObjectClassChanges().getAdd().add("some1");
editParam.getGroupObjectClassChanges().getAdd().add("some2");
editParam.getGroupObjectClassChanges().getAdd().add("some3");
editParam.getGroupMemberAttributeChanges().getAdd().add("someAttribute1");
editParam.getGroupMemberAttributeChanges().getAdd().add("someAttribute1");
editParam.getGroupMemberAttributeChanges().getAdd().add("someAttribute2");
editParam.getGroupMemberAttributeChanges().getAdd().add("someAttribute3");
editParam.getGroupMemberAttributeChanges().getAdd().add("someAttribute4");
editParam.getGroupMemberAttributeChanges().getAdd().add("someAttribute5");
editParam.setDescription(testName + "Edit with invalid group objectClasses and memberAttributes");
ClientResponse clientEditResp = rSys.path(editAPI).put(ClientResponse.class, editParam);
// 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, clientEditResp);
// Remove the invalid values from group objectClasses and set with default values.
editParam.getGroupObjectClassChanges().getAdd().clear();
editParam.getGroupObjectClassChanges().getAdd().addAll(getDefaultGroupObjectClasses());
editParam.setDescription(testName + "Edit with invalid memberAttributes");
clientEditResp = rSys.path(editAPI).put(ClientResponse.class, editParam);
// After we removed of invalid objectClasses from createParam, it contains only
// invalid group memberAttributes. So, the post request should fail with the below errors.
// Here the failure will be only for the memberAttributes.
// So validate the error message against only the memberAttributes 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, clientEditResp);
// Remove the invalid values from group memberAttributes and set with default values.
editParam.getGroupMemberAttributeChanges().getAdd().clear();
editParam.getGroupMemberAttributeChanges().getAdd().addAll(getDefaultGroupMemberAttributes());
editParam.setDescription(testName + "Successful Edit");
// Now, all the parameters in the post payload is valid. So the request should be successful.
AuthnProviderRestRep editResp = rSys.path(editAPI).put(AuthnProviderRestRep.class, editParam);
validateAuthProviderEditSuccess(editParam, editResp);
}
use of com.emc.storageos.model.auth.AuthnUpdateParam 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());
}
Aggregations