Search in sources :

Example 6 with UserMappingParam

use of com.emc.storageos.model.tenant.UserMappingParam in project coprhd-controller by CoprHD.

the class KeystoneUtils method prepareUserMappings.

/**
 * Prepares userMappings with OpenStack Tenant ID for CoprHD Tenant.
 *
 * @param openstackId OpenStack Tenant ID.
 * @return UserMappings.
 */
public List<UserMappingParam> prepareUserMappings(String openstackId) {
    AuthnProvider provider = getKeystoneProvider();
    // Create mapping rules
    List<UserMappingParam> userMappings = new ArrayList<>();
    List<String> values = new ArrayList<>();
    values.add(openstackId);
    List<UserMappingAttributeParam> attributes = new ArrayList<>();
    attributes.add(new UserMappingAttributeParam(KeystoneUtils.OPENSTACK_TENANT_ID, values));
    userMappings.add(new UserMappingParam(provider.getDomains().iterator().next(), attributes, new ArrayList<String>()));
    return userMappings;
}
Also used : UserMappingAttributeParam(com.emc.storageos.model.tenant.UserMappingAttributeParam) UserMappingParam(com.emc.storageos.model.tenant.UserMappingParam)

Example 7 with UserMappingParam

use of com.emc.storageos.model.tenant.UserMappingParam in project coprhd-controller by CoprHD.

the class KeystoneUtilsTest method testPrepareUserMappings.

@Test
public void testPrepareUserMappings() {
    KeystoneUtils spyKeystoneUtils = spy(_keystoneUtils);
    doReturn(keystoneProvider).when(spyKeystoneUtils).getKeystoneProvider();
    List<UserMappingParam> createdUserMapping = spyKeystoneUtils.prepareUserMappings(TENANT_OS_ID);
    UserMappingParam expectedParams = userMappings.iterator().next();
    UserMappingParam createdParams = createdUserMapping.iterator().next();
    assertEquals(expectedParams.getDomain(), createdParams.getDomain());
    assertEquals(expectedParams.getAttributes(), createdParams.getAttributes());
    assertEquals(expectedParams.getGroups(), createdParams.getGroups());
}
Also used : KeystoneUtils(com.emc.storageos.keystone.restapi.utils.KeystoneUtils) UserMappingParam(com.emc.storageos.model.tenant.UserMappingParam) Test(org.junit.Test)

Example 8 with UserMappingParam

use of com.emc.storageos.model.tenant.UserMappingParam in project coprhd-controller by CoprHD.

the class KeystoneUtilsTest method prepareUserMapping.

private void prepareUserMapping() {
    userMappings = new ArrayList<>();
    List<String> values = new ArrayList<>();
    values.add(TENANT_OS_ID);
    List<UserMappingAttributeParam> attributes = new ArrayList<>();
    attributes.add(new UserMappingAttributeParam(KeystoneUtils.OPENSTACK_TENANT_ID, values));
    userMappings.add(new UserMappingParam(PROVIDER_DOMAIN, attributes, new ArrayList<>()));
}
Also used : UserMappingAttributeParam(com.emc.storageos.model.tenant.UserMappingAttributeParam) ArrayList(java.util.ArrayList) UserMappingParam(com.emc.storageos.model.tenant.UserMappingParam)

Example 9 with UserMappingParam

use of com.emc.storageos.model.tenant.UserMappingParam in project coprhd-controller by CoprHD.

the class TenantModificationTest method securityAdminModifyUserMapping.

@Test
public void securityAdminModifyUserMapping() throws Exception {
    TenantUpdateParam tenantUpdateParam = new TenantUpdateParam();
    UserMappingChanges changes = new UserMappingChanges();
    List<UserMappingParam> listAdd = new ArrayList<UserMappingParam>();
    UserMappingParam param = new UserMappingParam();
    param.setDomain("Not Exist");
    listAdd.add(param);
    changes.setAdd(listAdd);
    tenantUpdateParam.setUserMappingChanges(changes);
    try {
        secAdminClient.tenants().update(rootTenantID, tenantUpdateParam);
        Assert.fail("fail, as the input contains wrong domain");
    } catch (ServiceErrorException see) {
        // verify the exception is not insufficent permission.
        Assert.assertNotEquals(see.getCode(), 3000);
        Assert.assertTrue(see.getMessage().contains("Parameter was provided but invalid"));
    }
}
Also used : UserMappingChanges(com.emc.storageos.model.tenant.UserMappingChanges) UserMappingParam(com.emc.storageos.model.tenant.UserMappingParam) ArrayList(java.util.ArrayList) ServiceErrorException(com.emc.vipr.client.exceptions.ServiceErrorException) TenantUpdateParam(com.emc.storageos.model.tenant.TenantUpdateParam) Test(org.junit.Test)

Example 10 with UserMappingParam

use of com.emc.storageos.model.tenant.UserMappingParam in project coprhd-controller by CoprHD.

the class FilePolicyApiTest method getDefaultUserMappingParam.

private UserMappingParam getDefaultUserMappingParam() {
    UserMappingParam param = new UserMappingParam();
    param.setDomain(getTestDomainName());
    param.getGroups().add(apiTestAuthnProviderUtils.getLDAPGroup(2));
    return param;
}
Also used : UserMappingParam(com.emc.storageos.model.tenant.UserMappingParam)

Aggregations

UserMappingParam (com.emc.storageos.model.tenant.UserMappingParam)16 UserMappingAttributeParam (com.emc.storageos.model.tenant.UserMappingAttributeParam)9 TenantCreateParam (com.emc.storageos.model.tenant.TenantCreateParam)5 TenantUpdateParam (com.emc.storageos.model.tenant.TenantUpdateParam)4 UserMappingChanges (com.emc.storageos.model.tenant.UserMappingChanges)4 ArrayList (java.util.ArrayList)4 TenantOrgRestRep (com.emc.storageos.model.tenant.TenantOrgRestRep)3 TenantResponse (com.emc.storageos.model.tenant.TenantResponse)3 ClientResponse (com.sun.jersey.api.client.ClientResponse)3 Test (org.junit.Test)3 AuthnUpdateParam (com.emc.storageos.model.auth.AuthnUpdateParam)2 ServiceErrorException (com.emc.vipr.client.exceptions.ServiceErrorException)2 HashSet (java.util.HashSet)2 NamedURI (com.emc.storageos.db.client.model.NamedURI)1 TenantOrg (com.emc.storageos.db.client.model.TenantOrg)1 KeystoneUtils (com.emc.storageos.keystone.restapi.utils.KeystoneUtils)1 AuthnCreateParam (com.emc.storageos.model.auth.AuthnCreateParam)1 AuthnProviderRestRep (com.emc.storageos.model.auth.AuthnProviderRestRep)1 RoleAssignmentChanges (com.emc.storageos.model.auth.RoleAssignmentChanges)1 RoleAssignmentEntry (com.emc.storageos.model.auth.RoleAssignmentEntry)1