Search in sources :

Example 6 with AuthnProviderRestRep

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

Example 7 with AuthnProviderRestRep

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

the class ApiTestAuthnProviders method testAuthnProviderCreateWithoutLDAPGroupProperties.

@Test
public void testAuthnProviderCreateWithoutLDAPGroupProperties() {
    final String testName = "testAuthnProviderCreateWithoutLDAPGroupProperties - ";
    AuthnCreateParam createParam = getDefaultAuthnCreateParam(testName + "GroupAttribute (\"\")");
    // Set the groupAttribute to "", so that the create request will fail, as
    // GroupAttribute is an mandatory parameter in the API.
    createParam.setGroupAttribute("");
    ClientResponse clientCreateResp = rSys.path(getTestApi()).post(ClientResponse.class, createParam);
    // Since the createParam contains invalid groupAttribute,
    // the post request should fail with the below errors.
    String partialExpectedErrorMsg = "Required parameter group_attribute was missing or empty";
    validateAuthProviderBadRequest(HttpStatus.SC_BAD_REQUEST, partialExpectedErrorMsg, clientCreateResp);
    // Set the groupAttribute to null (to validate if there is no null pointer exception),
    // so that the create request will fail, as groupAttribute is an mandatory parameter in the API.
    createParam.setGroupAttribute(null);
    createParam.setDescription(testName + "GroupAttribute (null)");
    clientCreateResp = rSys.path(getTestApi()).post(ClientResponse.class, createParam);
    // Since the createParam contains invalid groupAttribute,
    // the post request should fail with the below errors.
    partialExpectedErrorMsg = AUTHN_PROVIDER_ADD_UPDATE_PARTIAL_ERROR + "modified because of the following error: Could not find group attribute";
    validateAuthProviderBadRequest(HttpStatus.SC_BAD_REQUEST, partialExpectedErrorMsg, clientCreateResp);
    // Set the groupAttribute to "some" (invalid group attribute. The imported ldap schema does not have an attribute called some),
    // so that the create request will fail, as groupAttribute is an mandatory parameter in the API.
    createParam.setGroupAttribute("some");
    createParam.setDescription(testName + "GroupAttribute (some)");
    clientCreateResp = rSys.path(getTestApi()).post(ClientResponse.class, createParam);
    // Since the createParam contains invalid groupAttribute,
    // the post request should fail with the below errors.
    partialExpectedErrorMsg = AUTHN_PROVIDER_ADD_UPDATE_PARTIAL_ERROR + "modified because of the following error: Could not find group attribute";
    validateAuthProviderBadRequest(HttpStatus.SC_BAD_REQUEST, partialExpectedErrorMsg, clientCreateResp);
    // Remove the LDAP Group search properties (Group ObjectClasses and MemberAttributes).
    createParam.setGroupObjectClasses(new HashSet<String>());
    createParam.setGroupMemberAttributes(new HashSet<String>());
    // Set the groupAttribute to valid groupAttribute to the post to be success.
    createParam.setGroupAttribute(getDefaultGroupAttribute());
    createParam.setDescription(testName + TRACE_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 8 with AuthnProviderRestRep

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

Example 9 with AuthnProviderRestRep

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

the class ApiTestAuthnProviders method validateAuthProviderEditSuccessForGroupMemberAttributeOnly.

private void validateAuthProviderEditSuccessForGroupMemberAttributeOnly(AuthnUpdateParam expected, AuthnProviderRestRep actual) {
    validateAuthProviderCommon(expected, actual);
    Assert.assertArrayEquals(expected.getGroupMemberAttributeChanges().getAdd().toArray(), actual.getGroupMemberAttributes().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.getGroupMemberAttributeChanges().getAdd().toArray(), createResp.getGroupMemberAttributes().toArray());
}
Also used : AuthnProviderRestRep(com.emc.storageos.model.auth.AuthnProviderRestRep)

Example 10 with AuthnProviderRestRep

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

the class ApiTestBase method updateADConfig.

protected void updateADConfig() {
    if (rSys == null) {
        // Tests depending on what Junit feels like doing that day
        try {
            rSys = createHttpsClient(SYSADMIN, SYSADMIN_PASS_WORD, baseUrls);
            rSys.path("/tenant").get(String.class);
        } catch (Exception e) {
            Assert.fail();
        }
    }
    AuthnCreateParam param = new AuthnCreateParam();
    param.setLabel("ad apitest config good");
    param.setDescription("ad configuration created by ApiTest.java");
    param.setDisable(false);
    // Put spaces in the doman to verify it does not cause a problem
    param.getDomains().add(" SANITY.LOCAL ");
    param.setGroupAttribute("CN");
    param.getGroupWhitelistValues().add("*Admins*");
    param.getGroupWhitelistValues().add("*Test*");
    param.getGroupWhitelistValues().add("*Users*");
    param.setManagerDn("CN=Administrator,CN=Users,DC=sanity,DC=local");
    param.setManagerPassword("P@ssw0rd");
    param.setSearchBase("DC=sanity,DC=local");
    param.setSearchFilter("userPrincipalName=%u");
    param.getServerUrls().add("ldap://" + AD_SERVER1_IP);
    param.setMode("ad");
    param.setSearchScope("SUBTREE");
    try {
        AuthnProviderRestRep authnResp = rSys.path("/vdc/admin/authnproviders").post(AuthnProviderRestRep.class, param);
        Assert.assertNotNull(authnResp);
        _goodADConfig = authnResp.getId();
    } catch (UniformInterfaceException e) {
        if (e.getResponse().getStatus() != 400) {
            Assert.fail();
        }
    } catch (Exception e) {
        Assert.fail();
    }
}
Also used : UniformInterfaceException(com.sun.jersey.api.client.UniformInterfaceException) AuthnCreateParam(com.emc.storageos.model.auth.AuthnCreateParam) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) UniformInterfaceException(com.sun.jersey.api.client.UniformInterfaceException) ClientHandlerException(com.sun.jersey.api.client.ClientHandlerException) AuthnProviderRestRep(com.emc.storageos.model.auth.AuthnProviderRestRep)

Aggregations

AuthnProviderRestRep (com.emc.storageos.model.auth.AuthnProviderRestRep)29 AuthnCreateParam (com.emc.storageos.model.auth.AuthnCreateParam)18 AuthnUpdateParam (com.emc.storageos.model.auth.AuthnUpdateParam)12 ClientResponse (com.sun.jersey.api.client.ClientResponse)11 Test (org.junit.Test)11 FlashException (controllers.util.FlashException)2 RestLinkRep (com.emc.storageos.model.RestLinkRep)1 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 Gson (com.google.gson.Gson)1 ClientHandlerException (com.sun.jersey.api.client.ClientHandlerException)1 UniformInterfaceException (com.sun.jersey.api.client.UniformInterfaceException)1 URI (java.net.URI)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 HashSet (java.util.HashSet)1 LinkedHashSet (java.util.LinkedHashSet)1 Random (java.util.Random)1 OpenStackTenantsDataTable (models.datatable.OpenStackTenantsDataTable)1