Search in sources :

Example 21 with AuthnCreateParam

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

Example 22 with AuthnCreateParam

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

Example 23 with AuthnCreateParam

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());
}
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

AuthnCreateParam (com.emc.storageos.model.auth.AuthnCreateParam)23 AuthnProviderRestRep (com.emc.storageos.model.auth.AuthnProviderRestRep)18 Test (org.junit.Test)13 AuthnUpdateParam (com.emc.storageos.model.auth.AuthnUpdateParam)12 ClientResponse (com.sun.jersey.api.client.ClientResponse)12 AuthnProviderList (com.emc.storageos.model.auth.AuthnProviderList)1 TenantCreateParam (com.emc.storageos.model.tenant.TenantCreateParam)1 UserMappingAttributeParam (com.emc.storageos.model.tenant.UserMappingAttributeParam)1 UserMappingParam (com.emc.storageos.model.tenant.UserMappingParam)1 ViPRClientHelper (com.emc.storageos.usermanagement.util.ViPRClientHelper)1 ADClient (com.emc.storageos.usermanagement.util.ad.ADClient)1 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)1 ClientHandlerException (com.sun.jersey.api.client.ClientHandlerException)1 UniformInterfaceException (com.sun.jersey.api.client.UniformInterfaceException)1 InputStream (java.io.InputStream)1 URI (java.net.URI)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 HashSet (java.util.HashSet)1 LinkedHashSet (java.util.LinkedHashSet)1 Properties (java.util.Properties)1