Search in sources :

Example 1 with AuthnProviderRestRep

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

the class ApiTestAuthnProviders method validateAuthProviderCreateSuccess.

private void validateAuthProviderCreateSuccess(AuthnCreateParam expected, AuthnProviderRestRep actual) {
    validateAuthProviderCommon(expected, actual);
    Assert.assertArrayEquals(expected.getGroupObjectClasses().toArray(), actual.getGroupObjectClasses().toArray());
    Assert.assertArrayEquals(expected.getGroupMemberAttributes().toArray(), actual.getGroupMemberAttributes().toArray());
    // Add the created authnprovider to cleanup list, so that at the end of this test
    // the object will be destroyed.
    final String deleteObjectURL = this.getTestEditApi(actual.getId());
    CleanupResource authnProviderToCleanup = new CleanupResource("delete", deleteObjectURL, rSys, null);
    registerResourceForCleanup(authnProviderToCleanup);
    // Query the APIService about the new created 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.getGroupObjectClasses().toArray(), createResp.getGroupObjectClasses().toArray());
    Assert.assertArrayEquals(expected.getGroupMemberAttributes().toArray(), createResp.getGroupMemberAttributes().toArray());
}
Also used : AuthnProviderRestRep(com.emc.storageos.model.auth.AuthnProviderRestRep)

Example 2 with AuthnProviderRestRep

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

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

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

the class ApiTestAuthnProviders method validateAuthProviderEditSuccess.

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

Example 5 with AuthnProviderRestRep

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

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