Search in sources :

Example 1 with AuthnUpdateParam

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;
}
Also used : AuthnUpdateParam(com.emc.storageos.model.auth.AuthnUpdateParam)

Example 2 with AuthnUpdateParam

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);
}
Also used : AuthnUpdateParam(com.emc.storageos.model.auth.AuthnUpdateParam) AuthnCreateParam(com.emc.storageos.model.auth.AuthnCreateParam) AuthnProviderRestRep(com.emc.storageos.model.auth.AuthnProviderRestRep) Test(org.junit.Test)

Example 3 with AuthnUpdateParam

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());
}
Also used : AuthnUpdateParam(com.emc.storageos.model.auth.AuthnUpdateParam) AuthnCreateParam(com.emc.storageos.model.auth.AuthnCreateParam) AuthnProviderRestRep(com.emc.storageos.model.auth.AuthnProviderRestRep) Test(org.junit.Test)

Example 4 with AuthnUpdateParam

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);
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) AuthnUpdateParam(com.emc.storageos.model.auth.AuthnUpdateParam) AuthnCreateParam(com.emc.storageos.model.auth.AuthnCreateParam) AuthnProviderRestRep(com.emc.storageos.model.auth.AuthnProviderRestRep) Test(org.junit.Test)

Example 5 with AuthnUpdateParam

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());
}
Also used : AuthnUpdateParam(com.emc.storageos.model.auth.AuthnUpdateParam) AuthnCreateParam(com.emc.storageos.model.auth.AuthnCreateParam) AuthnProviderRestRep(com.emc.storageos.model.auth.AuthnProviderRestRep) Test(org.junit.Test)

Aggregations

AuthnUpdateParam (com.emc.storageos.model.auth.AuthnUpdateParam)15 AuthnCreateParam (com.emc.storageos.model.auth.AuthnCreateParam)12 AuthnProviderRestRep (com.emc.storageos.model.auth.AuthnProviderRestRep)12 ClientResponse (com.sun.jersey.api.client.ClientResponse)9 Test (org.junit.Test)6 RoleAssignmentChanges (com.emc.storageos.model.auth.RoleAssignmentChanges)2 RoleAssignmentEntry (com.emc.storageos.model.auth.RoleAssignmentEntry)2 TenantCreateParam (com.emc.storageos.model.tenant.TenantCreateParam)2 TenantResponse (com.emc.storageos.model.tenant.TenantResponse)2 UserMappingAttributeParam (com.emc.storageos.model.tenant.UserMappingAttributeParam)2 UserMappingParam (com.emc.storageos.model.tenant.UserMappingParam)2 AuthnProviderList (com.emc.storageos.model.auth.AuthnProviderList)1 RoleAssignments (com.emc.storageos.model.auth.RoleAssignments)1 ProjectParam (com.emc.storageos.model.project.ProjectParam)1 TenantOrgList (com.emc.storageos.model.tenant.TenantOrgList)1 TenantOrgRestRep (com.emc.storageos.model.tenant.TenantOrgRestRep)1 TenantUpdateParam (com.emc.storageos.model.tenant.TenantUpdateParam)1 UserMappingChanges (com.emc.storageos.model.tenant.UserMappingChanges)1 VirtualArrayList (com.emc.storageos.model.varray.VirtualArrayList)1 UserTenant (com.emc.storageos.security.resource.UserInfoPage.UserTenant)1