use of org.eclipse.che.api.workspace.server.spi.NamespaceResolutionContext in project che-server by eclipse-che.
the class KubernetesNamespaceFactoryTest method testEvalNamespaceUsesNamespaceFromUserPreferencesIfExist.
@Test
public void testEvalNamespaceUsesNamespaceFromUserPreferencesIfExist() throws Exception {
namespaceFactory = new KubernetesNamespaceFactory("che-<userid>", true, true, true, NAMESPACE_LABELS, NAMESPACE_ANNOTATIONS, emptySet(), clientFactory, cheClientFactory, userManager, preferenceManager, pool);
Map<String, String> prefs = new HashMap<>();
prefs.put(WORKSPACE_INFRASTRUCTURE_NAMESPACE_ATTRIBUTE, "che-123");
prefs.put(NAMESPACE_TEMPLATE_ATTRIBUTE, "che-<userid>");
when(preferenceManager.find(anyString())).thenReturn(prefs);
String namespace = namespaceFactory.evaluateNamespaceName(new NamespaceResolutionContext("workspace123", "user123", "jondoe"));
assertEquals(namespace, "che-123");
}
use of org.eclipse.che.api.workspace.server.spi.NamespaceResolutionContext in project che-server by eclipse-che.
the class CredentialsSecretConfiguratorTest method setUp.
@BeforeMethod
public void setUp() throws InfrastructureException {
configurator = new CredentialsSecretConfigurator(clientFactory);
serverMock = new KubernetesServer(true, true);
serverMock.before();
KubernetesClient client = spy(serverMock.getClient());
when(clientFactory.create()).thenReturn(client);
namespaceResolutionContext = new NamespaceResolutionContext(TEST_WORKSPACE_ID, TEST_USER_ID, TEST_USERNAME);
}
use of org.eclipse.che.api.workspace.server.spi.NamespaceResolutionContext in project che-server by eclipse-che.
the class PreferencesConfigMapConfiguratorTest method setUp.
@BeforeMethod
public void setUp() throws InfrastructureException {
configurator = new PreferencesConfigMapConfigurator(clientFactory);
serverMock = new KubernetesServer(true, true);
serverMock.before();
KubernetesClient client = spy(serverMock.getClient());
when(clientFactory.create()).thenReturn(client);
namespaceResolutionContext = new NamespaceResolutionContext(TEST_WORKSPACE_ID, TEST_USER_ID, TEST_USERNAME);
}
use of org.eclipse.che.api.workspace.server.spi.NamespaceResolutionContext in project che-server by eclipse-che.
the class SshKeysConfiguratorTest method setUp.
@BeforeMethod
public void setUp() throws InfrastructureException, NotFoundException, ServerException {
context = new NamespaceResolutionContext(null, USER_ID, USER_NAME);
kubernetesServer = new KubernetesServer(true, true);
kubernetesServer.before();
when(sshManager.getPairs(USER_ID, "vcs")).thenReturn(Collections.singletonList(sshPair));
when(clientFactory.create()).thenReturn(kubernetesServer.getClient());
}
use of org.eclipse.che.api.workspace.server.spi.NamespaceResolutionContext in project che-server by eclipse-che.
the class UserPreferencesConfiguratorTest method setUp.
@BeforeMethod
public void setUp() throws InfrastructureException, NotFoundException, ServerException {
context = new NamespaceResolutionContext(null, USER_ID, USER_NAME);
kubernetesServer = new KubernetesServer(true, true);
kubernetesServer.before();
Map<String, String> preferences = new HashMap<>();
preferences.put("preference-name", "preference");
lenient().when(userManager.getById(USER_ID)).thenReturn(new UserImpl(USER_ID, USER_EMAIL, USER_NAME));
lenient().when(namespaceFactory.evaluateNamespaceName(any())).thenReturn(USER_NAMESPACE);
lenient().when(clientFactory.create()).thenReturn(kubernetesServer.getClient());
lenient().when(preferenceManager.find(USER_ID)).thenReturn(preferences);
}
Aggregations