Skip to content

Commit 441d3a4

Browse files
committed
Fix bug in VmwHarborProxyImageNameSubstitutor when resolving non-Spring Docker Images in VMware Harbor Proxy.
1 parent c41796e commit 441d3a4

File tree

2 files changed

+56
-4
lines changed

2 files changed

+56
-4
lines changed

spring-geode-project/spring-geode/src/test/java/example/app/crm/config/testcontainers/VmwHarborProxyImageNameSubstitutor.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ public class VmwHarborProxyImageNameSubstitutor extends ImageNameSubstitutor {
4141
private static final String TESTCONTAINERS_HUB_IMAGE_NAME_PREFIX =
4242
VMWARE_HARBOR_PROXY_URL.concat("/dockerhub-proxy-cache/");
4343

44-
private static final String TESTCONTAINERS_HUB_IMAGE_NAME_TEMPLATE =
44+
protected static final String TESTCONTAINERS_HUB_IMAGE_NAME_TEMPLATE =
4545
TESTCONTAINERS_HUB_IMAGE_NAME_PREFIX.concat("%s");
4646

4747
private static final String TESTCONTAINERS_SPRINGCI_HUB_IMAGE_NAME_PREFIX =
4848
TESTCONTAINERS_HUB_IMAGE_NAME_PREFIX.concat("springci/");
4949

50-
private static final String TESTCONTAINERS_SPRINGCI_HUB_IMAGE_NAME_TEMPLATE =
50+
protected static final String TESTCONTAINERS_SPRINGCI_HUB_IMAGE_NAME_TEMPLATE =
5151
TESTCONTAINERS_SPRINGCI_HUB_IMAGE_NAME_PREFIX.concat("%s");
5252

5353
private static final String SPRING_JAVA_VERSION =
@@ -115,8 +115,8 @@ private String substituteCassandraDockerImageName(String originalDockerImageName
115115
: originalDockerImageName;
116116
}
117117

118-
private String toUnqualifiedDockerImageName(String dockerImageName) {
119-
return dockerImageName.substring(dockerImageName.lastIndexOf("/") + 1);
118+
String toUnqualifiedDockerImageName(String dockerImageName) {
119+
return dockerImageName.replace(TESTCONTAINERS_HUB_IMAGE_NAME_PREFIX, "");
120120
}
121121

122122
@Override
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* Copyright 2017-present the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
13+
* or implied. See the License for the specific language governing
14+
* permissions and limitations under the License.
15+
*/
16+
package example.app.crm.config.testcontainers;
17+
18+
import static org.assertj.core.api.Assertions.assertThat;
19+
20+
import org.junit.jupiter.api.Test;
21+
22+
/**
23+
* Unit Tests for {@link VmwHarborProxyImageNameSubstitutor}.
24+
*
25+
* @author John Blum
26+
* @see org.junit.Test
27+
* @see example.app.crm.config.testcontainers.VmwHarborProxyImageNameSubstitutor
28+
* @since 1.7.6
29+
*/
30+
public class VmwHarborProxyImageNameSubstitutorUnitTests {
31+
32+
@Test
33+
public void toUnqualifiedDockerImageNameFromQualifiedName() {
34+
35+
VmwHarborProxyImageNameSubstitutor imageNameSubstitutor = new VmwHarborProxyImageNameSubstitutor();
36+
37+
String qualifiedDockerImageName = String.format(VmwHarborProxyImageNameSubstitutor
38+
.TESTCONTAINERS_HUB_IMAGE_NAME_TEMPLATE, "testcontainers/ryuk:0.4.0");
39+
40+
assertThat(imageNameSubstitutor.toUnqualifiedDockerImageName(qualifiedDockerImageName))
41+
.isEqualTo("testcontainers/ryuk:0.4.0");
42+
}
43+
44+
@Test
45+
public void toUnqualifiedDockerImageNameFromUnqualifiedName() {
46+
47+
VmwHarborProxyImageNameSubstitutor imageNameSubstitutor = new VmwHarborProxyImageNameSubstitutor();
48+
49+
assertThat(imageNameSubstitutor.toUnqualifiedDockerImageName("testcontainers/ryuk:0.4.0"))
50+
.isEqualTo("testcontainers/ryuk:0.4.0");
51+
}
52+
}

0 commit comments

Comments
 (0)