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());
}
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());
}
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);
}
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());
}
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();
}
Aggregations