Search in sources :

Example 16 with ProjectImpl

use of org.eclipse.che.api.workspace.server.model.impl.devfile.ProjectImpl in project devspaces-images by redhat-developer.

the class ProjectConverterTest method testClonePathCannotEscapeProjectsRoot.

@Test(expectedExceptions = DevfileException.class)
public void testClonePathCannotEscapeProjectsRoot() throws Exception {
    ProjectImpl devfileProject = new ProjectImpl("myProject", new SourceImpl("git", "https://github.com/eclipse/che.git", "master", null, null, null, null), "cant/hack/../../../usr/bin");
    projectConverter.toWorkspaceProject(devfileProject);
}
Also used : ProjectImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.ProjectImpl) SourceImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.SourceImpl) Test(org.testng.annotations.Test)

Example 17 with ProjectImpl

use of org.eclipse.che.api.workspace.server.model.impl.devfile.ProjectImpl in project devspaces-images by redhat-developer.

the class ProjectConverterTest method testOnlyOneOfStartPointAttributesAllowed.

@Test(expectedExceptions = DevfileException.class, expectedExceptionsMessageRegExp = "Only one of '" + START_POINT_PARAMETER_NAME + "', '" + TAG_PARAMETER_NAME + "', '" + COMMIT_ID_PARAMETER_NAME + "' can be specified\\.", dataProvider = "invalidStartPointOrTagOrCommitIdCombinations")
public void testOnlyOneOfStartPointAttributesAllowed(String startPoint, String tag, String commitId) throws Exception {
    ProjectImpl devfileProject = new ProjectImpl("myProject", new SourceImpl("git", "https://github.com/eclipse/che.git", null, startPoint, tag, commitId, null), null);
    projectConverter.toWorkspaceProject(devfileProject);
}
Also used : ProjectImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.ProjectImpl) SourceImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.SourceImpl) Test(org.testng.annotations.Test)

Example 18 with ProjectImpl

use of org.eclipse.che.api.workspace.server.model.impl.devfile.ProjectImpl in project devspaces-images by redhat-developer.

the class ProjectConverterTest method testUndefinedCloneParametersNotTransferredToWorkspaceConfig.

@Test
public void testUndefinedCloneParametersNotTransferredToWorkspaceConfig() throws Exception {
    ProjectImpl devfileProject = new ProjectImpl("myProject", new SourceImpl("git", "https://github.com/eclipse/che.git", null, null, null, null, null), null);
    ProjectConfigImpl wsProject = projectConverter.toWorkspaceProject(devfileProject);
    SourceStorageImpl wsSource = wsProject.getSource();
    assertFalse(wsSource.getParameters().containsKey(BRANCH_PARAMETER_NAME));
    assertFalse(wsSource.getParameters().containsKey(START_POINT_PARAMETER_NAME));
    assertFalse(wsSource.getParameters().containsKey(TAG_PARAMETER_NAME));
    assertFalse(wsSource.getParameters().containsKey(COMMIT_ID_PARAMETER_NAME));
    assertFalse(wsSource.getParameters().containsKey(SPARSE_CHECKOUT_DIR_PARAMETER_NAME));
}
Also used : SourceStorageImpl(org.eclipse.che.api.workspace.server.model.impl.SourceStorageImpl) ProjectImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.ProjectImpl) SourceImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.SourceImpl) ProjectConfigImpl(org.eclipse.che.api.workspace.server.model.impl.ProjectConfigImpl) Test(org.testng.annotations.Test)

Example 19 with ProjectImpl

use of org.eclipse.che.api.workspace.server.model.impl.devfile.ProjectImpl in project devspaces-images by redhat-developer.

the class ProjectConverterTest method testConvertingDevfileProjectToProjectConfig.

@Test
public void testConvertingDevfileProjectToProjectConfig() throws Exception {
    ProjectImpl devfileProject = new ProjectImpl("myProject", new SourceImpl("git", "https://github.com/eclipse/che.git", "master", "3434d", null, null, "core"), null);
    ProjectConfigImpl workspaceProject = projectConverter.toWorkspaceProject(devfileProject);
    assertEquals(workspaceProject.getName(), "myProject");
    assertEquals(workspaceProject.getPath(), "/myProject");
    SourceStorageImpl source = workspaceProject.getSource();
    assertEquals(source.getType(), "git");
    assertEquals(source.getLocation(), "https://github.com/eclipse/che.git");
    assertEquals(source.getParameters().get(BRANCH_PARAMETER_NAME), "master");
    assertEquals(source.getParameters().get(START_POINT_PARAMETER_NAME), "3434d");
    assertEquals(source.getParameters().get("keepDir"), "core");
}
Also used : SourceStorageImpl(org.eclipse.che.api.workspace.server.model.impl.SourceStorageImpl) ProjectImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.ProjectImpl) SourceImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.SourceImpl) ProjectConfigImpl(org.eclipse.che.api.workspace.server.model.impl.ProjectConfigImpl) Test(org.testng.annotations.Test)

Example 20 with ProjectImpl

use of org.eclipse.che.api.workspace.server.model.impl.devfile.ProjectImpl in project devspaces-images by redhat-developer.

the class ProjectConverterTest method testUpDirOkInClonePathAsLongAsItDoesntEscapeProjectsRoot.

@Test
public void testUpDirOkInClonePathAsLongAsItDoesntEscapeProjectsRoot() throws Exception {
    ProjectImpl devfileProject = new ProjectImpl("myProject", new SourceImpl("git", "https://github.com/eclipse/che.git", "master", null, null, null, null), "cant/hack/../../usr/bin");
    ProjectConfigImpl workspaceProject = projectConverter.toWorkspaceProject(devfileProject);
    // this is OK, because the absolute-looking path is applied to the projects root
    assertEquals(workspaceProject.getPath(), "/usr/bin");
}
Also used : ProjectImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.ProjectImpl) SourceImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.SourceImpl) ProjectConfigImpl(org.eclipse.che.api.workspace.server.model.impl.ProjectConfigImpl) Test(org.testng.annotations.Test)

Aggregations

ProjectImpl (org.eclipse.che.api.workspace.server.model.impl.devfile.ProjectImpl)36 SourceImpl (org.eclipse.che.api.workspace.server.model.impl.devfile.SourceImpl)30 Test (org.testng.annotations.Test)24 DevfileImpl (org.eclipse.che.api.workspace.server.model.impl.devfile.DevfileImpl)16 ComponentImpl (org.eclipse.che.api.workspace.server.model.impl.devfile.ComponentImpl)14 ProjectConfigImpl (org.eclipse.che.api.workspace.server.model.impl.ProjectConfigImpl)12 ActionImpl (org.eclipse.che.api.workspace.server.model.impl.devfile.ActionImpl)12 EndpointImpl (org.eclipse.che.api.workspace.server.model.impl.devfile.EndpointImpl)10 EntrypointImpl (org.eclipse.che.api.workspace.server.model.impl.devfile.EntrypointImpl)10 EnvImpl (org.eclipse.che.api.workspace.server.model.impl.devfile.EnvImpl)10 MetadataImpl (org.eclipse.che.api.workspace.server.model.impl.devfile.MetadataImpl)10 UserDevfileImpl (org.eclipse.che.api.devfile.server.model.impl.UserDevfileImpl)8 CommandImpl (org.eclipse.che.api.workspace.server.model.impl.devfile.CommandImpl)8 CommandImpl (org.eclipse.che.api.workspace.server.model.impl.CommandImpl)6 SourceStorageImpl (org.eclipse.che.api.workspace.server.model.impl.SourceStorageImpl)6 VolumeImpl (org.eclipse.che.api.workspace.server.model.impl.VolumeImpl)4 WorkspaceConfigImpl (org.eclipse.che.api.workspace.server.model.impl.WorkspaceConfigImpl)4 AccountImpl (org.eclipse.che.account.spi.AccountImpl)2 Command (org.eclipse.che.api.core.model.workspace.devfile.Command)2 FileContentProvider (org.eclipse.che.api.workspace.server.devfile.FileContentProvider)2