use of org.eclipse.che.workspace.infrastructure.kubernetes.api.shared.KubernetesNamespaceMeta in project devspaces-images by redhat-developer.
the class OpenShiftProjectFactoryTest method shouldReturnPreparedNamespacesWhenFound.
@Test
public void shouldReturnPreparedNamespacesWhenFound() throws InfrastructureException {
// given
List<Project> projects = Arrays.asList(createProject("ns1", "project1", "desc1", "Active", Map.of(NAMESPACE_ANNOTATION_NAME, "jondoe")), createProject("ns3", "project3", "desc3", "Active", Map.of(NAMESPACE_ANNOTATION_NAME, "some_other_user")), createProject("ns2", "project2", "desc2", "Active", Map.of(NAMESPACE_ANNOTATION_NAME, "jondoe")));
doReturn(projects).when(projectList).getItems();
projectFactory = new OpenShiftProjectFactory("<userid>-che", true, true, true, NAMESPACE_LABELS, NAMESPACE_ANNOTATIONS, true, emptySet(), clientFactory, cheClientFactory, cheServerOpenshiftClientFactory, userManager, preferenceManager, pool, NO_OAUTH_IDENTITY_PROVIDER);
EnvironmentContext.getCurrent().setSubject(new SubjectImpl("jondoe", "123", null, false));
// when
List<KubernetesNamespaceMeta> availableNamespaces = projectFactory.list();
// then
assertEquals(availableNamespaces.size(), 2);
assertEquals(availableNamespaces.get(0).getName(), "ns1");
assertEquals(availableNamespaces.get(1).getName(), "ns2");
}
use of org.eclipse.che.workspace.infrastructure.kubernetes.api.shared.KubernetesNamespaceMeta in project devspaces-images by redhat-developer.
the class OpenShiftProjectFactoryTest method shouldReturnDefaultProjectWhenItDoesNotExistAndUserDefinedIsNotAllowed.
@Test
public void shouldReturnDefaultProjectWhenItDoesNotExistAndUserDefinedIsNotAllowed() throws Exception {
throwOnTryToGetProjectByName(USER_NAME + "-che", new KubernetesClientException("forbidden", 403, null));
projectFactory = new OpenShiftProjectFactory("<username>-che", true, true, true, NAMESPACE_LABELS, NAMESPACE_ANNOTATIONS, true, emptySet(), clientFactory, cheClientFactory, cheServerOpenshiftClientFactory, userManager, preferenceManager, pool, NO_OAUTH_IDENTITY_PROVIDER);
List<KubernetesNamespaceMeta> availableNamespaces = projectFactory.list();
assertEquals(availableNamespaces.size(), 1);
KubernetesNamespaceMeta defaultNamespace = availableNamespaces.get(0);
assertEquals(defaultNamespace.getName(), USER_NAME + "-che");
assertEquals(defaultNamespace.getAttributes().get(DEFAULT_ATTRIBUTE), "true");
assertNull(defaultNamespace.getAttributes().get(// no phase - means such project does not exist
PHASE_ATTRIBUTE));
}
Aggregations