diff --git a/platform-api/che-core-api-factory/src/main/java/org/eclipse/che/api/factory/FactoryBaseValidator.java b/platform-api/che-core-api-factory/src/main/java/org/eclipse/che/api/factory/FactoryBaseValidator.java index e9a6ad9d8..d171eb2c9 100644 --- a/platform-api/che-core-api-factory/src/main/java/org/eclipse/che/api/factory/FactoryBaseValidator.java +++ b/platform-api/che-core-api-factory/src/main/java/org/eclipse/che/api/factory/FactoryBaseValidator.java @@ -306,7 +306,7 @@ protected void validateProjectRunnerNames(Factory factory) throws BadRequestExce NewProject project = factory.getProject(); if (project != null && project.getRunners() != null && project.getRunners().getConfigs() != null) { for (String runnerName : project.getRunners().getConfigs().keySet()) { - if (!RUNNER_NAME_VALIDATOR.matcher(runnerName).matches()) { + if (!runnerName.startsWith("system:") && !RUNNER_NAME_VALIDATOR.matcher(runnerName).matches()) { throw new BadRequestException("Invalid runner name " + runnerName); } } diff --git a/platform-api/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/ProjectService.java b/platform-api/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/ProjectService.java index 6723dc9a3..19b378c38 100644 --- a/platform-api/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/ProjectService.java +++ b/platform-api/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/ProjectService.java @@ -1572,7 +1572,7 @@ void checkProjectName(String name) throws BadRequestException { void checkProjectRunners(RunnersDescriptor runnersDescriptor) throws BadRequestException { if (runnersDescriptor != null && runnersDescriptor.getConfigs() != null && !runnersDescriptor.getConfigs().isEmpty()) { for (String runnerName : runnersDescriptor.getConfigs().keySet()) { - if (!RUNNER_NAME_VALIDATOR.matcher(runnerName).matches()) { + if (!runnerName.startsWith("system:") && !RUNNER_NAME_VALIDATOR.matcher(runnerName).matches()) { throw new BadRequestException("Runner name " + runnerName + " is invalid"); } } diff --git a/platform-api/che-core-api-project/src/test/java/org/eclipse/che/api/project/server/ProjectServiceTest.java b/platform-api/che-core-api-project/src/test/java/org/eclipse/che/api/project/server/ProjectServiceTest.java index fe79dcf00..8abeabfaf 100644 --- a/platform-api/che-core-api-project/src/test/java/org/eclipse/che/api/project/server/ProjectServiceTest.java +++ b/platform-api/che-core-api-project/src/test/java/org/eclipse/che/api/project/server/ProjectServiceTest.java @@ -3036,6 +3036,16 @@ public void shouldThrowExceptionWhenProjectNameIsInvalid() throws Exception { projectService.checkProjectName("!#project-name#!"); } + @Test + public void shouldNotThrowExceptionIfRunnerIsSystemScope() throws Exception { + RunnersDescriptor runnersDescriptor = mock(RunnersDescriptor.class); + ProjectService projectService = spy(new ProjectService()); + RunnerConfiguration config = mock(RunnerConfiguration.class); + when(runnersDescriptor.getConfigs()).thenReturn(ImmutableMap.of("system:/javascript/web/simple", config)); + + projectService.checkProjectRunners(runnersDescriptor); + } + @Test(expectedExceptions = BadRequestException.class, expectedExceptionsMessageRegExp = "Runner name !#runenr#! is invalid") public void shouldThrowExceptionWhenRunnerNameIsInvalid() throws Exception { RunnersDescriptor runnersDescriptor = mock(RunnersDescriptor.class);