Search in sources :

Example 1 with AuthnCreateParam

use of com.emc.storageos.model.auth.AuthnCreateParam in project coprhd-controller by CoprHD.

the class ApiTestAuthnProviderUtils method getDefaultAuthnCreateParam.

public AuthnCreateParam getDefaultAuthnCreateParam(String description) {
    AuthnCreateParam param = new AuthnCreateParam();
    param.setLabel(DEFAULT_TEST_LDAP_AUTHN_PROVIDER_LABEL);
    if (StringUtils.isNotBlank(description)) {
        param.setDescription(description);
    } else {
        param.setDescription(DEFAULT_TEST_LDAP_AUTHN_PROVIDER_DESCRIPTION);
    }
    param.setDisable(false);
    param.getDomains().add(DEFAULT_TEST_LDAP_SERVER_DOMIN);
    param.setManagerDn(DEFAULT_TEST_LDAP_SERVER_MANAGER_DN);
    param.setManagerPassword(DEFAULT_TEST_LDAP_SERVER_MANAGER_DN_PWD);
    param.setSearchBase(DEFAULT_TEST_LDAP_SERVER_SEARCH_BASE);
    param.setSearchFilter(DEFAULT_TEST_LDAP_SERVER_SEARCH_FILTER);
    param.setServerUrls(new HashSet<String>());
    param.getServerUrls().add(DEFAULT_TEST_LDAP_SERVER_URL);
    param.setMode(DEFAULT_TEST_LDAP_AUTHN_PROVIDER_MODE);
    param.setGroupAttribute(DEFAULT_TEST_LDAP_SERVER_GROUP_ATTRIBUTE);
    param.setSearchScope(DEFAULT_TEST_LDAP_SERVER_SEARCH_SCOPE);
    param.setGroupObjectClasses(getDefaultGroupObjectClasses());
    param.setGroupMemberAttributes(getDefaultGroupMemberAttributes());
    return param;
}
Also used : AuthnCreateParam(com.emc.storageos.model.auth.AuthnCreateParam)

Example 2 with AuthnCreateParam

use of com.emc.storageos.model.auth.AuthnCreateParam 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 AuthnCreateParam

use of com.emc.storageos.model.auth.AuthnCreateParam 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 AuthnCreateParam

use of com.emc.storageos.model.auth.AuthnCreateParam 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 AuthnCreateParam

use of com.emc.storageos.model.auth.AuthnCreateParam in project coprhd-controller by CoprHD.

the class ApiTestAuthnProviders method testAuthnProviderCreateWithNullLDAPGroupProperties.

@Test
public void testAuthnProviderCreateWithNullLDAPGroupProperties() {
    final String testName = "testAuthnProviderCreateWithNullLDAPGroupProperties - ";
    AuthnCreateParam createParam = getDefaultAuthnCreateParam(testName + TRACE_SUCCESSFUL + "(null group objectClasses and memberAttributes)");
    // Remove the LDAP Group search properties (Group ObjectClasses and MemberAttributes).
    createParam.getGroupObjectClasses().clear();
    createParam.setGroupObjectClasses(null);
    createParam.getGroupMemberAttributes().clear();
    createParam.setGroupMemberAttributes(null);
    AuthnProviderRestRep createResp = rSys.path(getTestApi()).post(AuthnProviderRestRep.class, createParam);
    validateAuthProviderCreateSuccess(createParam, createResp);
}
Also used : 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