Skip to content

Commit 9508fc8

Browse files
olexii4cursoragent
andcommitted
test: add IPv6 URL parsing examples
Add IPv6 coverage for GitLab, GitHub and Azure DevOps URL parsers. Signed-off-by: Oleksii Orel <oorel@redhat.com> Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 1ea2692 commit 9508fc8

File tree

3 files changed

+68
-3
lines changed

3 files changed

+68
-3
lines changed

wsmaster/che-core-api-factory-azure-devops/src/test/java/org/eclipse/che/api/factory/server/azure/devops/AzureDevOpsURLParserTest.java

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2012-2025 Red Hat, Inc.
2+
* Copyright (c) 2012-2026 Red Hat, Inc.
33
* This program and the accompanying materials are made
44
* available under the terms of the Eclipse Public License 2.0
55
* which is available at https://www.eclipse.org/legal/epl-2.0/
@@ -60,6 +60,25 @@ public void shouldParseWithUrlBranch() {
6060
assertEquals(azureDevOpsUrl.getBranch(), "main");
6161
}
6262

63+
@Test
64+
public void shouldParseServerUrlWithIpv6Host() {
65+
// given
66+
azureDevOpsURLParser =
67+
new AzureDevOpsURLParser(
68+
mock(DevfileFilenamesProvider.class),
69+
mock(PersonalAccessTokenManager.class),
70+
"https://[2001:db8::1]/");
71+
72+
// when
73+
AzureDevOpsUrl azureDevOpsUrl =
74+
azureDevOpsURLParser.parse("https://[2001:db8::1]/MyOrg/MyProject/_git/MyRepo", null);
75+
76+
// then
77+
assertEquals(azureDevOpsUrl.getOrganization(), "MyOrg");
78+
assertEquals(azureDevOpsUrl.getProject(), "MyProject");
79+
assertEquals(azureDevOpsUrl.getRepository(), "MyRepo");
80+
}
81+
6382
@Test(dataProvider = "parsing")
6483
public void testParse(
6584
String url,

wsmaster/che-core-api-factory-github/src/test/java/org/eclipse/che/api/factory/server/github/GithubURLParserTest.java

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2012-2025 Red Hat, Inc.
2+
* Copyright (c) 2012-2026 Red Hat, Inc.
33
* This program and the accompanying materials are made
44
* available under the terms of the Eclipse Public License 2.0
55
* which is available at https://www.eclipse.org/legal/epl-2.0/
@@ -100,6 +100,28 @@ public void shouldParseWithUrlBranch() throws ApiException {
100100
assertEquals(githubUrl.getBranch(), "master");
101101
}
102102

103+
@Test
104+
public void shouldParseGithubServerUrlWithIpv6Host() throws ApiException {
105+
// given
106+
githubUrlParser =
107+
new GithubURLParser(
108+
personalAccessTokenManager,
109+
devfileFilenamesProvider,
110+
githubApiClient,
111+
"https://[2001:db8::1]",
112+
false);
113+
when(githubApiClient.isConnected(eq("https://[2001:db8::1]"))).thenReturn(true);
114+
when(devfileFilenamesProvider.getConfiguredDevfileFilenames())
115+
.thenReturn(asList("devfile.yaml", ".devfile.yaml"));
116+
117+
// when
118+
GithubUrl githubUrl = githubUrlParser.parse("https://[2001:db8::1]/eclipse/che", null);
119+
120+
// then
121+
assertEquals(githubUrl.getUsername(), "eclipse");
122+
assertEquals(githubUrl.getRepository(), "che");
123+
}
124+
103125
/** Check URLs are valid with regexp */
104126
@Test(dataProvider = "UrlsProvider")
105127
public void checkRegexp(String url) {

wsmaster/che-core-api-factory-gitlab/src/test/java/org/eclipse/che/api/factory/server/gitlab/GitlabUrlParserTest.java

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2012-2025 Red Hat, Inc.
2+
* Copyright (c) 2012-2026 Red Hat, Inc.
33
* This program and the accompanying materials are made
44
* available under the terms of the Eclipse Public License 2.0
55
* which is available at https://www.eclipse.org/legal/epl-2.0/
@@ -89,6 +89,30 @@ public void shouldGetProviderUrlWithExtraSegment() throws ApiException {
8989
assertEquals(gitlabUrl.getProviderUrl(), "https://gitlab-server.com/scm");
9090
}
9191

92+
@Test
93+
public void shouldGetProviderUrlWithExtraSegmentOnIpv6Endpoint() throws ApiException {
94+
gitlabUrlParser =
95+
new GitlabUrlParser(
96+
"https://[2001:db8::1]/scm",
97+
devfileFilenamesProvider,
98+
mock(PersonalAccessTokenManager.class));
99+
GitlabUrl gitlabUrl =
100+
gitlabUrlParser.parse("https://[2001:db8::1]/scm/user/project/test.git", null);
101+
assertEquals(gitlabUrl.getProviderUrl(), "https://[2001:db8::1]/scm");
102+
}
103+
104+
@Test
105+
public void shouldGetProviderUrlWithExtraSegmentOnIpv6EndpointWithPort() throws ApiException {
106+
gitlabUrlParser =
107+
new GitlabUrlParser(
108+
"https://[2001:db8::1]:8443/scm",
109+
devfileFilenamesProvider,
110+
mock(PersonalAccessTokenManager.class));
111+
GitlabUrl gitlabUrl =
112+
gitlabUrlParser.parse("https://[2001:db8::1]:8443/scm/user/project/test.git", null);
113+
assertEquals(gitlabUrl.getProviderUrl(), "https://[2001:db8::1]:8443/scm");
114+
}
115+
92116
@Test
93117
public void shouldParseWithUrlBranch() throws ApiException {
94118
GitlabUrl gitlabUrl =

0 commit comments

Comments
 (0)