use of org.eclipse.che.commons.env.EnvironmentContext in project che by eclipse.
the class DashboardRedirectionFilterTest method shouldRedirectIfRequestWithoutNamespace.
@Test(dataProvider = "nonNamespacePathProvider")
public void shouldRedirectIfRequestWithoutNamespace(String uri, String url) throws Exception {
//given
when(request.getMethod()).thenReturn("GET");
when(request.getRequestURI()).thenReturn(uri);
when(request.getRequestURL()).thenReturn(new StringBuffer(url));
EnvironmentContext context = new EnvironmentContext();
context.setSubject(new SubjectImpl("id123", "name", "token123", false));
EnvironmentContext.setCurrent(context);
//when
filter.doFilter(request, response, chain);
//then
verify(response).sendRedirect(eq("/dashboard/"));
}
use of org.eclipse.che.commons.env.EnvironmentContext in project che by eclipse.
the class DefaultHttpJsonRequestTest method shouldUseTokenFromCurrentContextForAuthorization.
@Test
public void shouldUseTokenFromCurrentContextForAuthorization(ITestContext ctx) throws Exception {
final EnvironmentContext context = new EnvironmentContext();
context.setSubject(TEST_SUBJECT);
EnvironmentContext.setCurrent(context);
new DefaultHttpJsonRequest(getUrl(ctx) + "/token").usePostMethod().request();
}
use of org.eclipse.che.commons.env.EnvironmentContext in project che by eclipse.
the class MachineProviderImplTest method setUp.
@BeforeMethod
public void setUp() throws Exception {
when(dockerConnectorConfiguration.getDockerHostIp()).thenReturn("123.123.123.123");
provider = spy(new MachineProviderBuilder().build());
EnvironmentContext envCont = new EnvironmentContext();
envCont.setSubject(new SubjectImpl(USER_NAME, "userId", USER_TOKEN, false));
EnvironmentContext.setCurrent(envCont);
when(recipeRetriever.getRecipe(any(MachineConfig.class))).thenReturn(new RecipeImpl().withType(DOCKER_FILE_TYPE).withScript("FROM codenvy"));
when(dockerMachineFactory.createNode(anyString(), anyString())).thenReturn(dockerNode);
when(dockerConnector.createContainer(any(CreateContainerParams.class))).thenReturn(new ContainerCreated(CONTAINER_ID, new String[0]));
when(dockerConnector.inspectContainer(any(InspectContainerParams.class))).thenReturn(containerInfo);
when(containerInfo.getState()).thenReturn(containerState);
when(containerState.isRunning()).thenReturn(false);
}
use of org.eclipse.che.commons.env.EnvironmentContext in project che by eclipse.
the class CompletionJavadocTest method setUp.
@Before
public void setUp() throws Exception {
super.setUp();
EnvironmentContext customEnvironment = mock(EnvironmentContext.class);
doReturn(new SubjectImpl(vfsUser, "", "", false)).when(customEnvironment).getSubject();
EnvironmentContext.setCurrent(customEnvironment);
fJProject1 = Java18ProjectTestSetup.getProject();
fSourceFolder = JavaProjectHelper.addSourceContainer(fJProject1, "src");
}
use of org.eclipse.che.commons.env.EnvironmentContext in project che by eclipse.
the class WorkspaceManagerTest method setUp.
@BeforeMethod
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
workspaceManager = new WorkspaceManager(workspaceDao, runtimes, eventService, accountManager, false, false, snapshotDao, sharedPool);
when(accountManager.getByName(NAMESPACE)).thenReturn(new AccountImpl("accountId", NAMESPACE, "test"));
when(accountManager.getByName(NAMESPACE_2)).thenReturn(new AccountImpl("accountId2", NAMESPACE_2, "test"));
when(workspaceDao.create(any(WorkspaceImpl.class))).thenAnswer(invocation -> invocation.getArguments()[0]);
when(workspaceDao.update(any(WorkspaceImpl.class))).thenAnswer(invocation -> invocation.getArguments()[0]);
EnvironmentContext.setCurrent(new EnvironmentContext() {
@Override
public Subject getSubject() {
return new SubjectImpl(NAMESPACE, USER_ID, "token", false);
}
});
}
Aggregations