diff --git a/wsmaster/che-core-api-factory-gitlab-common/pom.xml b/wsmaster/che-core-api-factory-gitlab-common/pom.xml
index ddc3653370..b1f227cd5d 100644
--- a/wsmaster/che-core-api-factory-gitlab-common/pom.xml
+++ b/wsmaster/che-core-api-factory-gitlab-common/pom.xml
@@ -67,6 +67,10 @@
org.eclipse.che.core
che-core-api-workspace
+
+ org.eclipse.che.core
+ che-core-commons-annotations
+
org.eclipse.che.core
che-core-commons-lang
diff --git a/wsmaster/che-core-api-factory-gitlab-common/src/main/java/org/eclipse/che/api/factory/server/gitlab/AbstractGitlabUserDataFetcher.java b/wsmaster/che-core-api-factory-gitlab-common/src/main/java/org/eclipse/che/api/factory/server/gitlab/AbstractGitlabUserDataFetcher.java
index 2ed3a454b8..18dff4f6af 100644
--- a/wsmaster/che-core-api-factory-gitlab-common/src/main/java/org/eclipse/che/api/factory/server/gitlab/AbstractGitlabUserDataFetcher.java
+++ b/wsmaster/che-core-api-factory-gitlab-common/src/main/java/org/eclipse/che/api/factory/server/gitlab/AbstractGitlabUserDataFetcher.java
@@ -11,6 +11,8 @@
*/
package org.eclipse.che.api.factory.server.gitlab;
+import static com.google.common.base.Strings.isNullOrEmpty;
+
import com.google.common.base.Joiner;
import com.google.common.collect.ImmutableSet;
import java.util.Set;
@@ -19,6 +21,7 @@
import org.eclipse.che.api.factory.server.scm.exception.ScmCommunicationException;
import org.eclipse.che.api.factory.server.scm.exception.ScmItemNotFoundException;
import org.eclipse.che.api.factory.server.scm.exception.ScmUnauthorizedException;
+import org.eclipse.che.commons.annotation.Nullable;
/** Gitlab OAuth token retriever. */
public class AbstractGitlabUserDataFetcher extends AbstractGitUserDataFetcher {
@@ -29,14 +32,15 @@ public class AbstractGitlabUserDataFetcher extends AbstractGitUserDataFetcher {
public static final Set DEFAULT_TOKEN_SCOPES =
ImmutableSet.of("api", "write_repository", "openid");
+ private static final String GITLAB_SAAS_ENDPOINT = "https://gitlab.com";
public AbstractGitlabUserDataFetcher(
- String serverUrl,
+ @Nullable String serverUrl,
String apiEndpoint,
PersonalAccessTokenManager personalAccessTokenManager,
String providerName) {
super(providerName, serverUrl, personalAccessTokenManager);
- this.serverUrl = serverUrl;
+ this.serverUrl = isNullOrEmpty(serverUrl) ? GITLAB_SAAS_ENDPOINT : serverUrl;
this.apiEndpoint = apiEndpoint;
this.providerName = providerName;
}
diff --git a/wsmaster/che-core-api-factory-gitlab/src/test/java/org/eclipse/che/api/factory/server/gitlab/GitlabUserDataFetcherTest.java b/wsmaster/che-core-api-factory-gitlab/src/test/java/org/eclipse/che/api/factory/server/gitlab/GitlabUserDataFetcherTest.java
index 96a57b591a..572fd70f50 100644
--- a/wsmaster/che-core-api-factory-gitlab/src/test/java/org/eclipse/che/api/factory/server/gitlab/GitlabUserDataFetcherTest.java
+++ b/wsmaster/che-core-api-factory-gitlab/src/test/java/org/eclipse/che/api/factory/server/gitlab/GitlabUserDataFetcherTest.java
@@ -27,6 +27,7 @@
import com.github.tomakehurst.wiremock.client.WireMock;
import com.github.tomakehurst.wiremock.common.Slf4jNotifier;
import com.google.common.net.HttpHeaders;
+import java.lang.reflect.Field;
import java.util.Optional;
import org.eclipse.che.api.factory.server.scm.GitUserData;
import org.eclipse.che.api.factory.server.scm.PersonalAccessToken;
@@ -88,4 +89,17 @@ public void shouldFetchGitUserData() throws Exception {
assertEquals(gitUserData.getScmUsername(), "John Smith");
assertEquals(gitUserData.getScmUserEmail(), "john@example.com");
}
+
+ @Test
+ public void shouldSetSAASUrlAsDefault() throws Exception {
+ gitlabUserDataFetcher =
+ new GitlabUserDataFetcher(null, "http://che.api", personalAccessTokenManager);
+
+ Field serverUrlField =
+ gitlabUserDataFetcher.getClass().getSuperclass().getDeclaredField("serverUrl");
+ serverUrlField.setAccessible(true);
+ String serverUrl = (String) serverUrlField.get(gitlabUserDataFetcher);
+
+ assertEquals(serverUrl, "https://gitlab.com");
+ }
}