use of org.eclipse.che.commons.subject.SubjectImpl in project che by eclipse.
the class CheEnvironmentEngineTest method setUp.
@BeforeMethod
public void setUp() throws Exception {
engine = spy(new CheEnvironmentEngine(snapshotDao, machineInstanceProviders, System.getProperty("java.io.tmpdir"), DEFAULT_MACHINE_MEM_LIMIT_MB, eventService, environmentParser, new DefaultServicesStartStrategy(), machineProvider, infrastructureProvisioner, API_ENDPOINT, recipeDownloader, containerNameGenerator, agentRegistry, sharedPool));
when(machineInstanceProviders.getProvider("docker")).thenReturn(instanceProvider);
when(instanceProvider.getRecipeTypes()).thenReturn(Collections.singleton("dockerfile"));
when(agentRegistry.getAgent(any(AgentKey.class))).thenReturn(agent);
EnvironmentContext.getCurrent().setSubject(new SubjectImpl("name", "id", "token", false));
}
use of org.eclipse.che.commons.subject.SubjectImpl in project che by eclipse.
the class EnvironmentContextTest method shouldNotBeAbleToSeeContextInOtherThread.
@Test(enabled = false)
public void shouldNotBeAbleToSeeContextInOtherThread() {
//given
final EnvironmentContext expected = EnvironmentContext.getCurrent();
expected.setSubject(new SubjectImpl("user", "id", "token", false));
Thread otherThread = new Thread() {
@Override
public void run() {
EnvironmentContext.getCurrent();
}
};
}
use of org.eclipse.che.commons.subject.SubjectImpl in project che by eclipse.
the class EnvironmentContextTest method shouldBeAbleToSetEnvContextInSameThread.
@Test
public void shouldBeAbleToSetEnvContextInSameThread() {
//given
EnvironmentContext expected = EnvironmentContext.getCurrent();
expected.setSubject(new SubjectImpl("user", "id", "token", false));
EnvironmentContext actual = EnvironmentContext.getCurrent();
Subject actualSubject = actual.getSubject();
assertEquals(actualSubject.getUserName(), "user");
assertEquals(actualSubject.getUserId(), "id");
assertEquals(actualSubject.getToken(), "token");
assertFalse(actualSubject.isTemporary());
}
use of org.eclipse.che.commons.subject.SubjectImpl in project che by eclipse.
the class UserSpecificDockerRegistryCredentialsProviderTest method setCredentialsIntoPreferences.
private void setCredentialsIntoPreferences(String base64encodedCredentials) throws ServerException {
Map<String, String> preferences = new HashMap<>();
preferences.put(DOCKER_REGISTRY_CREDENTIALS_KEY, base64encodedCredentials);
EnvironmentContext.getCurrent().setSubject(new SubjectImpl("name", "id", "token1234", false));
when(preferenceManager.find(anyObject(), anyObject())).thenReturn(preferences);
}
use of org.eclipse.che.commons.subject.SubjectImpl 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");
}
Aggregations