Merge branch '3.1.x' into replace_junit_assertions

This commit is contained in:
wind57
2025-03-28 17:10:21 +02:00
4 changed files with 15 additions and 13 deletions

View File

@@ -48,7 +48,7 @@ record KubernetesCatalogWatchContext(CoreV1Api coreV1Api, ApiClient apiClient, K
}
static String labelSelector(Map<String, String> labels) {
return labels.entrySet().stream().map(en -> en.getKey() + "=" + en.getValue()).collect(Collectors.joining("&"));
return labels.entrySet().stream().map(en -> en.getKey() + "=" + en.getValue()).collect(Collectors.joining(","));
}
}

View File

@@ -16,6 +16,7 @@
package org.springframework.cloud.kubernetes.client.discovery.catalog;
import java.util.LinkedHashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;
@@ -40,10 +41,11 @@ class KubernetesCatalogWatchContextTests {
@Test
void multipleLabelsLabel() {
String result = KubernetesCatalogWatchContext.labelSelector(Map.of("a", "b", "c", "d"));
Assertions.assertTrue(result.contains("c=d"));
Assertions.assertTrue(result.contains("&"));
Assertions.assertTrue(result.contains("a=b"));
Map<String, String> labels = new LinkedHashMap<>();
labels.put("a", "b");
labels.put("c", "d");
String result = KubernetesCatalogWatchContext.labelSelector(labels);
Assertions.assertEquals("a=b,c=d", result);
}
}

View File

@@ -96,7 +96,7 @@ class KubernetesCatalogWatchEndpointSlicesTests extends KubernetesEndpointsAndEn
@Test
@Override
void testInAllNamespacesWithDoubleLabel() {
stubFor(get("/apis/discovery.k8s.io/v1/endpointslices?labelSelector=a%3Db%26c%3Dd")
stubFor(get("/apis/discovery.k8s.io/v1/endpointslices?labelSelector=a%3Db%2Cc%3Dd")
.willReturn(aResponse().withStatus(200).withBody(new JSON().serialize(endpointSlices("a", "default")))));
// otherwise the stub might fail
LinkedHashMap<String, String> map = new LinkedHashMap<>();
@@ -137,9 +137,9 @@ class KubernetesCatalogWatchEndpointSlicesTests extends KubernetesEndpointsAndEn
@Test
@Override
void testInSpecificNamespacesWithDoubleLabel() {
stubFor(get("/apis/discovery.k8s.io/v1/namespaces/one/endpointslices?labelSelector=a%3Db%26c%3Dd")
stubFor(get("/apis/discovery.k8s.io/v1/namespaces/one/endpointslices?labelSelector=a%3Db%2Cc%3Dd")
.willReturn(aResponse().withStatus(200).withBody(new JSON().serialize(endpointSlices("aa", "a")))));
stubFor(get("/apis/discovery.k8s.io/v1/namespaces/two/endpointslices?labelSelector=a%3Db%26c%3Dd")
stubFor(get("/apis/discovery.k8s.io/v1/namespaces/two/endpointslices?labelSelector=a%3Db%2Cc%3Dd")
.willReturn(aResponse().withStatus(200).withBody(new JSON().serialize(endpointSlices("bb", "b")))));
// otherwise the stub might fail
@@ -179,7 +179,7 @@ class KubernetesCatalogWatchEndpointSlicesTests extends KubernetesEndpointsAndEn
@Test
@Override
void testInOneNamespaceWithDoubleLabel() {
stubFor(get("/apis/discovery.k8s.io/v1/namespaces/b/endpointslices?labelSelector=key%3Dvalue%26key1%3Dvalue1")
stubFor(get("/apis/discovery.k8s.io/v1/namespaces/b/endpointslices?labelSelector=key%3Dvalue%2Ckey1%3Dvalue1")
.willReturn(aResponse().withStatus(200).withBody(new JSON().serialize(endpointSlices("a", "b")))));
// otherwise the stub might fail
LinkedHashMap<String, String> map = new LinkedHashMap<>();

View File

@@ -96,7 +96,7 @@ class KubernetesCatalogWatchEndpointsTests extends KubernetesEndpointsAndEndpoin
@Test
@Override
void testInAllNamespacesWithDoubleLabel() {
stubFor(get("/api/v1/endpoints?labelSelector=a%3Db%26c%3Dd")
stubFor(get("/api/v1/endpoints?labelSelector=a%3Db%2Cc%3Dd")
.willReturn(aResponse().withStatus(200).withBody(new JSON().serialize(endpoints("a", "default")))));
// otherwise the stub might fail
LinkedHashMap<String, String> map = new LinkedHashMap<>();
@@ -137,9 +137,9 @@ class KubernetesCatalogWatchEndpointsTests extends KubernetesEndpointsAndEndpoin
@Test
@Override
void testInSpecificNamespacesWithDoubleLabel() {
stubFor(get("/api/v1/namespaces/one/endpoints?labelSelector=a%3Db%26c%3Dd")
stubFor(get("/api/v1/namespaces/one/endpoints?labelSelector=a%3Db%2Cc%3Dd")
.willReturn(aResponse().withStatus(200).withBody(new JSON().serialize(endpoints("aa", "a")))));
stubFor(get("/api/v1/namespaces/two/endpoints?labelSelector=a%3Db%26c%3Dd")
stubFor(get("/api/v1/namespaces/two/endpoints?labelSelector=a%3Db%2Cc%3Dd")
.willReturn(aResponse().withStatus(200).withBody(new JSON().serialize(endpoints("bb", "b")))));
// otherwise the stub might fail
@@ -179,7 +179,7 @@ class KubernetesCatalogWatchEndpointsTests extends KubernetesEndpointsAndEndpoin
@Test
@Override
void testInOneNamespaceWithDoubleLabel() {
stubFor(get("/api/v1/namespaces/b/endpoints?labelSelector=key%3Dvalue%26key1%3Dvalue1")
stubFor(get("/api/v1/namespaces/b/endpoints?labelSelector=key%3Dvalue%2Ckey1%3Dvalue1")
.willReturn(aResponse().withStatus(200).withBody(new JSON().serialize(endpoints("a", "b")))));
// otherwise the stub might fail
LinkedHashMap<String, String> map = new LinkedHashMap<>();