Search in sources :

Example 1 with KeystoneUtils

use of com.emc.storageos.keystone.restapi.utils.KeystoneUtils 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 2 with KeystoneUtils

use of com.emc.storageos.keystone.restapi.utils.KeystoneUtils in project coprhd-controller by CoprHD.

the class KeystoneUtilsTest method testPrepareTenantParam.

@Test
public void testPrepareTenantParam() {
    String expectedTenantName = CinderConstants.TENANT_NAME_PREFIX + " " + TENANT_NAME;
    TenantCreateParam param = new TenantCreateParam(expectedTenantName, userMappings);
    KeystoneUtils spyKeystoneUtils = spy(_keystoneUtils);
    doReturn(userMappings).when(spyKeystoneUtils).prepareUserMappings(TENANT_OS_ID);
    doReturn(TENANT_DESCRIPTION).when(spyKeystoneUtils).getProperTenantDescription(TENANT_DESCRIPTION);
    TenantCreateParam createdParams = spyKeystoneUtils.prepareTenantParam(keystoneTenant);
    assertEquals(param.getUserMappings(), createdParams.getUserMappings());
    assertEquals(TENANT_DESCRIPTION, createdParams.getDescription());
    assertEquals(param.getLabel(), createdParams.getLabel());
}
Also used : KeystoneUtils(com.emc.storageos.keystone.restapi.utils.KeystoneUtils) TenantCreateParam(com.emc.storageos.model.tenant.TenantCreateParam) Test(org.junit.Test)

Example 3 with KeystoneUtils

use of com.emc.storageos.keystone.restapi.utils.KeystoneUtils in project coprhd-controller by CoprHD.

the class KeystoneUtilsTest method testGetCoprhdTenantWithOpenstackId.

@Test
public void testGetCoprhdTenantWithOpenstackId() {
    List<TenantOrg> tenants = new ArrayList<>();
    tenants.add(createTenantOrg());
    tenants.add(tenantOrg);
    KeystoneUtils spyKeystoneUtils = spy(_keystoneUtils);
    doReturn(tenants).when(spyKeystoneUtils).getCoprhdTenantsWithOpenStackId();
    doReturn(TENANT_USER_MAPPING_STRING).when(spyKeystoneUtils).getCoprhdTenantUserMapping(tenantOrg);
    TenantOrg returnedTenant = spyKeystoneUtils.getCoprhdTenantWithOpenstackId(TENANT_OS_ID);
    assertNotNull(returnedTenant);
    assertEquals(tenantOrg.getId(), returnedTenant.getId());
    TenantOrg returnedNullTenant = spyKeystoneUtils.getCoprhdTenantWithOpenstackId(EMPTY_STRING);
    assertNull(returnedNullTenant);
    TenantOrg returnedWrongNullTenant = spyKeystoneUtils.getCoprhdTenantWithOpenstackId(TENANT_WRONG_OS_ID);
    assertNull(returnedWrongNullTenant);
}
Also used : KeystoneUtils(com.emc.storageos.keystone.restapi.utils.KeystoneUtils) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 4 with KeystoneUtils

use of com.emc.storageos.keystone.restapi.utils.KeystoneUtils in project coprhd-controller by CoprHD.

the class KeystoneUtilsTest method testGetCoprhdTenantsWithOpenStackId.

@Test
public void testGetCoprhdTenantsWithOpenStackId() {
    List<TenantOrg> tenants = new ArrayList<>();
    List<URI> tenantsUri = new ArrayList<>();
    tenants.add(createTenantOrg());
    tenants.add(tenantOrg);
    tenants.add(createTenantOrg());
    KeystoneUtils spyKeystoneUtils = spy(_keystoneUtils);
    spyKeystoneUtils.setDbClient(_dbClient);
    when(_dbClient.queryByType(TenantOrg.class, true)).thenReturn(tenantsUri);
    when(_dbClient.queryIterativeObjects(TenantOrg.class, tenantsUri)).thenReturn(tenants.iterator());
    doReturn(null).doReturn(TENANT_OS_ID).doReturn(null).when(spyKeystoneUtils).getCoprhdTenantUserMapping(any(TenantOrg.class));
    List<TenantOrg> returnedTenants = spyKeystoneUtils.getCoprhdTenantsWithOpenStackId();
    assertNotNull(returnedTenants);
    assertEquals(1, returnedTenants.size());
}
Also used : KeystoneUtils(com.emc.storageos.keystone.restapi.utils.KeystoneUtils) ArrayList(java.util.ArrayList) URI(java.net.URI) Test(org.junit.Test)

Example 5 with KeystoneUtils

use of com.emc.storageos.keystone.restapi.utils.KeystoneUtils in project coprhd-controller by CoprHD.

the class KeystoneUtilsTest method setupTest.

@Before
public void setupTest() {
    _keystoneUtils = new KeystoneUtils();
    _keystoneUtils.setDbClient(_dbClient);
    prepareProject();
    prepareTenants();
    prepareUserMapping();
    prepareKeystoneProvider();
}
Also used : KeystoneUtils(com.emc.storageos.keystone.restapi.utils.KeystoneUtils) Before(org.junit.Before)

Aggregations

KeystoneUtils (com.emc.storageos.keystone.restapi.utils.KeystoneUtils)5 Test (org.junit.Test)4 ArrayList (java.util.ArrayList)2 TenantCreateParam (com.emc.storageos.model.tenant.TenantCreateParam)1 UserMappingParam (com.emc.storageos.model.tenant.UserMappingParam)1 URI (java.net.URI)1 Before (org.junit.Before)1