Search in sources :

Example 6 with SubjectImpl

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));
}
Also used : AgentKey(org.eclipse.che.api.agent.shared.model.AgentKey) SubjectImpl(org.eclipse.che.commons.subject.SubjectImpl) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 7 with SubjectImpl

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();
        }
    };
}
Also used : SubjectImpl(org.eclipse.che.commons.subject.SubjectImpl) Test(org.testng.annotations.Test)

Example 8 with SubjectImpl

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());
}
Also used : SubjectImpl(org.eclipse.che.commons.subject.SubjectImpl) Subject(org.eclipse.che.commons.subject.Subject) Test(org.testng.annotations.Test)

Example 9 with SubjectImpl

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);
}
Also used : HashMap(java.util.HashMap) SubjectImpl(org.eclipse.che.commons.subject.SubjectImpl)

Example 10 with SubjectImpl

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");
}
Also used : EnvironmentContext(org.eclipse.che.commons.env.EnvironmentContext) SubjectImpl(org.eclipse.che.commons.subject.SubjectImpl) Before(org.junit.Before)

Aggregations

SubjectImpl (org.eclipse.che.commons.subject.SubjectImpl)12 EnvironmentContext (org.eclipse.che.commons.env.EnvironmentContext)5 BeforeMethod (org.testng.annotations.BeforeMethod)4 Test (org.testng.annotations.Test)4 Subject (org.eclipse.che.commons.subject.Subject)3 HashMap (java.util.HashMap)2 ThreadFactoryBuilder (com.google.common.util.concurrent.ThreadFactoryBuilder)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 HttpSession (javax.servlet.http.HttpSession)1 AccountImpl (org.eclipse.che.account.spi.AccountImpl)1 AgentKey (org.eclipse.che.api.agent.shared.model.AgentKey)1 MachineConfig (org.eclipse.che.api.core.model.machine.MachineConfig)1 CheEnvironmentEngine (org.eclipse.che.api.environment.server.CheEnvironmentEngine)1 DefaultServicesStartStrategy (org.eclipse.che.api.environment.server.DefaultServicesStartStrategy)1 RecipeImpl (org.eclipse.che.api.machine.server.recipe.RecipeImpl)1 ProfileImpl (org.eclipse.che.api.user.server.model.impl.ProfileImpl)1 WorkspaceImpl (org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl)1 ProjectConfigDto (org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto)1 ContainerCreated (org.eclipse.che.plugin.docker.client.json.ContainerCreated)1 CreateContainerParams (org.eclipse.che.plugin.docker.client.params.CreateContainerParams)1