From 197a2b8e78691a6659cfd543070b546a64eb47f7 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 10 Dec 2025 19:00:36 +0000 Subject: [PATCH 1/2] Initial plan From 0646056f40d8a4d1653de1383d22f46439a24278 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 10 Dec 2025 19:08:01 +0000 Subject: [PATCH 2/2] Fix User-Agent to use Configuration.VERSION instead of hardcoded value Co-authored-by: brendandburns <5751682+brendandburns@users.noreply.github.com> --- .../kubernetes/client/openapi/ApiClient.java | 2 +- .../client/openapi/ApiClientTest.java | 48 +++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 kubernetes/src/test/java/io/kubernetes/client/openapi/ApiClientTest.java diff --git a/kubernetes/src/main/java/io/kubernetes/client/openapi/ApiClient.java b/kubernetes/src/main/java/io/kubernetes/client/openapi/ApiClient.java index d5d3fd68c2..795893c831 100644 --- a/kubernetes/src/main/java/io/kubernetes/client/openapi/ApiClient.java +++ b/kubernetes/src/main/java/io/kubernetes/client/openapi/ApiClient.java @@ -140,7 +140,7 @@ private void init() { json = new JSON(); // Set default User-Agent. - setUserAgent("Kubernetes Java Client/25.0.0-SNAPSHOT"); + setUserAgent("Kubernetes Java Client/" + Configuration.VERSION); authentications = new HashMap(); } diff --git a/kubernetes/src/test/java/io/kubernetes/client/openapi/ApiClientTest.java b/kubernetes/src/test/java/io/kubernetes/client/openapi/ApiClientTest.java new file mode 100644 index 0000000000..d7b550b741 --- /dev/null +++ b/kubernetes/src/test/java/io/kubernetes/client/openapi/ApiClientTest.java @@ -0,0 +1,48 @@ +/* +Copyright 2025 The Kubernetes Authors. +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at +http://www.apache.org/licenses/LICENSE-2.0 +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +package io.kubernetes.client.openapi; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.util.Collections; +import okhttp3.Request; +import org.junit.jupiter.api.Test; + +class ApiClientTest { + + @Test + void testUserAgentMatchesConfigurationVersion() throws ApiException { + ApiClient apiClient = new ApiClient(); + + // Build a simple request to verify User-Agent header + Request request = + apiClient.buildRequest( + "http://localhost", + "/api/v1/test", + "GET", + Collections.emptyList(), + Collections.emptyList(), + null, + Collections.emptyMap(), + Collections.emptyMap(), + Collections.emptyMap(), + new String[] {}, + null); + + // Verify the User-Agent header matches the version from Configuration + String expectedUserAgent = "Kubernetes Java Client/" + Configuration.VERSION; + String actualUserAgent = request.header("User-Agent"); + + assertThat(actualUserAgent).isEqualTo(expectedUserAgent); + } +}