From 37701b110102be350f5d9aeab147d1fb6ab7a977 Mon Sep 17 00:00:00 2001 From: guruprasad Date: Thu, 13 Mar 2025 17:30:37 +0530 Subject: [PATCH 1/8] trying to write TLS based test for agents --- .../agents/TLSCustomCertificateTest.java | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 test/src/test/java/jenkins/agents/TLSCustomCertificateTest.java diff --git a/test/src/test/java/jenkins/agents/TLSCustomCertificateTest.java b/test/src/test/java/jenkins/agents/TLSCustomCertificateTest.java new file mode 100644 index 000000000000..cda28fffd169 --- /dev/null +++ b/test/src/test/java/jenkins/agents/TLSCustomCertificateTest.java @@ -0,0 +1,43 @@ +package jenkins.agents; + +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.jvnet.hudson.test.InboundAgentRule; +import org.jvnet.hudson.test.RealJenkinsRule; + +public class TLSCustomCertificateTest { + + @Rule + public final RealJenkinsRule rjr = new RealJenkinsRule().https(); + + @Rule + public InboundAgentRule iar = new InboundAgentRule(); + + @Before + public void setUp() throws Throwable { + rjr.startJenkins(); + } + + @Test + public void test_noCertificateCheck_worksInWebSocketAgent() throws Throwable { + // TODO need to configure `-noCertificateCheck` option + var options = InboundAgentRule.Options + .newBuilder() + .webSocket(); + + iar.createAgent(rjr, options.build()); + // try to run a build to ensure agent is connected. + } + + @Test + public void test_cert_worksInWebSocketAgent() throws Throwable { + // TODO need to configure `-cert` option with passing the rootCA as a string variable + var options = InboundAgentRule.Options + .newBuilder() + .webSocket(); + + iar.createAgent(rjr, options.build()); + // try to run a build to ensure agent is connected. + } +} From 9b16312c1fed06bcfd980e83365b80ddbf0d0ec8 Mon Sep 17 00:00:00 2001 From: guruprasad Date: Fri, 14 Mar 2025 00:13:47 +0530 Subject: [PATCH 2/8] add test for inbound agent tls cli arguments --- test/pom.xml | 2 +- .../InboundAgentTlsCliArgumentTest.java | 55 +++++++++++++++++++ .../agents/TLSCustomCertificateTest.java | 43 --------------- 3 files changed, 56 insertions(+), 44 deletions(-) create mode 100644 test/src/test/java/jenkins/agents/InboundAgentTlsCliArgumentTest.java delete mode 100644 test/src/test/java/jenkins/agents/TLSCustomCertificateTest.java diff --git a/test/pom.xml b/test/pom.xml index 4bd4d5a94b07..ea9332251450 100644 --- a/test/pom.xml +++ b/test/pom.xml @@ -178,7 +178,7 @@ THE SOFTWARE. org.jenkins-ci.main jenkins-test-harness - 2414.v185474555e66 + 2416.v986b_081cf07d test diff --git a/test/src/test/java/jenkins/agents/InboundAgentTlsCliArgumentTest.java b/test/src/test/java/jenkins/agents/InboundAgentTlsCliArgumentTest.java new file mode 100644 index 000000000000..f95860f36763 --- /dev/null +++ b/test/src/test/java/jenkins/agents/InboundAgentTlsCliArgumentTest.java @@ -0,0 +1,55 @@ +package jenkins.agents; + +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.jvnet.hudson.test.InboundAgentRule; +import org.jvnet.hudson.test.RealJenkinsRule; + +public class InboundAgentTlsCliArgumentTest { + + @Rule + public final RealJenkinsRule rjr = new RealJenkinsRule().https(); + + @Rule + public InboundAgentRule iar = new InboundAgentRule(); + + @Before + public void setUp() throws Throwable { + rjr.startJenkins(); + } + + @Test + public void shouldConnectOverWebSocketWithoutCertificateCheck() throws Throwable { + var options = InboundAgentRule.Options + .newBuilder() + .webSocket() + .noCertificateCheck(); + iar.createAgent(rjr, options.build()); + } + + @Test + public void shouldConnectOverWebSocketWithCertificateFromCLI() throws Throwable { + var options = InboundAgentRule.Options + .newBuilder() + .webSocket() + .cert(rjr.getRootCAPem()); + iar.createAgent(rjr, options.build()); + } + + @Test + public void shouldConnectOverTcpWithoutCertificateCheck() throws Throwable { + var options = InboundAgentRule.Options + .newBuilder() + .noCertificateCheck(); + iar.createAgent(rjr, options.build()); + } + + @Test + public void shouldConnectOverTcpWithCertificateFromCLI() throws Throwable { + var options = InboundAgentRule.Options + .newBuilder() + .cert(rjr.getRootCAPem()); + iar.createAgent(rjr, options.build()); + } +} diff --git a/test/src/test/java/jenkins/agents/TLSCustomCertificateTest.java b/test/src/test/java/jenkins/agents/TLSCustomCertificateTest.java deleted file mode 100644 index cda28fffd169..000000000000 --- a/test/src/test/java/jenkins/agents/TLSCustomCertificateTest.java +++ /dev/null @@ -1,43 +0,0 @@ -package jenkins.agents; - -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.jvnet.hudson.test.InboundAgentRule; -import org.jvnet.hudson.test.RealJenkinsRule; - -public class TLSCustomCertificateTest { - - @Rule - public final RealJenkinsRule rjr = new RealJenkinsRule().https(); - - @Rule - public InboundAgentRule iar = new InboundAgentRule(); - - @Before - public void setUp() throws Throwable { - rjr.startJenkins(); - } - - @Test - public void test_noCertificateCheck_worksInWebSocketAgent() throws Throwable { - // TODO need to configure `-noCertificateCheck` option - var options = InboundAgentRule.Options - .newBuilder() - .webSocket(); - - iar.createAgent(rjr, options.build()); - // try to run a build to ensure agent is connected. - } - - @Test - public void test_cert_worksInWebSocketAgent() throws Throwable { - // TODO need to configure `-cert` option with passing the rootCA as a string variable - var options = InboundAgentRule.Options - .newBuilder() - .webSocket(); - - iar.createAgent(rjr, options.build()); - // try to run a build to ensure agent is connected. - } -} From ec1af385f85cacc373eaa5094c6eb10303fd4db9 Mon Sep 17 00:00:00 2001 From: guruprasad Date: Fri, 14 Mar 2025 01:01:15 +0530 Subject: [PATCH 3/8] update to the latest incremental version of JTH and add comment --- test/pom.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/pom.xml b/test/pom.xml index ea9332251450..0695136c5b82 100644 --- a/test/pom.xml +++ b/test/pom.xml @@ -178,7 +178,8 @@ THE SOFTWARE. org.jenkins-ci.main jenkins-test-harness - 2416.v986b_081cf07d + + 2418.v56818013edb_9 test From 65d76b1ac91d06e84db0a46708c848c34cf3e351 Mon Sep 17 00:00:00 2001 From: guruprasad Date: Fri, 14 Mar 2025 08:03:08 +0530 Subject: [PATCH 4/8] shorten and clear test method names --- ...lsCliArgumentTest.java => InboundAgentTlsTest.java} | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) rename test/src/test/java/jenkins/agents/{InboundAgentTlsCliArgumentTest.java => InboundAgentTlsTest.java} (75%) diff --git a/test/src/test/java/jenkins/agents/InboundAgentTlsCliArgumentTest.java b/test/src/test/java/jenkins/agents/InboundAgentTlsTest.java similarity index 75% rename from test/src/test/java/jenkins/agents/InboundAgentTlsCliArgumentTest.java rename to test/src/test/java/jenkins/agents/InboundAgentTlsTest.java index f95860f36763..39593397bb60 100644 --- a/test/src/test/java/jenkins/agents/InboundAgentTlsCliArgumentTest.java +++ b/test/src/test/java/jenkins/agents/InboundAgentTlsTest.java @@ -6,7 +6,7 @@ import org.jvnet.hudson.test.InboundAgentRule; import org.jvnet.hudson.test.RealJenkinsRule; -public class InboundAgentTlsCliArgumentTest { +public class InboundAgentTlsTest { @Rule public final RealJenkinsRule rjr = new RealJenkinsRule().https(); @@ -20,7 +20,7 @@ public void setUp() throws Throwable { } @Test - public void shouldConnectOverWebSocketWithoutCertificateCheck() throws Throwable { + public void webSocketNoCertificateCheck() throws Throwable { var options = InboundAgentRule.Options .newBuilder() .webSocket() @@ -29,7 +29,7 @@ public void shouldConnectOverWebSocketWithoutCertificateCheck() throws Throwable } @Test - public void shouldConnectOverWebSocketWithCertificateFromCLI() throws Throwable { + public void webSocketWithCertByValue() throws Throwable { var options = InboundAgentRule.Options .newBuilder() .webSocket() @@ -38,7 +38,7 @@ public void shouldConnectOverWebSocketWithCertificateFromCLI() throws Throwable } @Test - public void shouldConnectOverTcpWithoutCertificateCheck() throws Throwable { + public void tcpWithNoCertificateCheck() throws Throwable { var options = InboundAgentRule.Options .newBuilder() .noCertificateCheck(); @@ -46,7 +46,7 @@ public void shouldConnectOverTcpWithoutCertificateCheck() throws Throwable { } @Test - public void shouldConnectOverTcpWithCertificateFromCLI() throws Throwable { + public void tcpWithCertByValue() throws Throwable { var options = InboundAgentRule.Options .newBuilder() .cert(rjr.getRootCAPem()); From 53fba4afcf4699f8001e1f7e48aa8aceb74c2859 Mon Sep 17 00:00:00 2001 From: guruprasad Date: Fri, 14 Mar 2025 11:16:46 +0530 Subject: [PATCH 5/8] update to the new incremental version of jenkins-test-harness --- test/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/pom.xml b/test/pom.xml index 0695136c5b82..e293f8b61dbf 100644 --- a/test/pom.xml +++ b/test/pom.xml @@ -179,7 +179,7 @@ THE SOFTWARE. org.jenkins-ci.main jenkins-test-harness - 2418.v56818013edb_9 + 2420.v7deff9656e72 test From 5e6fd4a83ee5e1c4b20a1798ac9c4e066b9dd54d Mon Sep 17 00:00:00 2001 From: guruprasad Date: Fri, 14 Mar 2025 15:29:40 +0530 Subject: [PATCH 6/8] use the remoting incremental build --- pom.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c43c9780a7bb..880f7a39a16b 100644 --- a/pom.xml +++ b/pom.xml @@ -86,8 +86,9 @@ THE SOFTWARE. https://www.jenkins.io/changelog + - 3291.vb_131b_dc231fa_ + 3295.vd3a_13e38380c Max Medium From 29b2f4bc97a613a55c4a3b2e683bc2fe83c3447b Mon Sep 17 00:00:00 2001 From: guruprasad Date: Fri, 14 Mar 2025 15:31:44 +0530 Subject: [PATCH 7/8] fix the todo comment for JTH version --- test/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/pom.xml b/test/pom.xml index e293f8b61dbf..5c16d90630b1 100644 --- a/test/pom.xml +++ b/test/pom.xml @@ -178,7 +178,7 @@ THE SOFTWARE. org.jenkins-ci.main jenkins-test-harness - + 2420.v7deff9656e72 test From 73f53dec6093e66654ef0bffa43fbbcc64588e51 Mon Sep 17 00:00:00 2001 From: guruprasad Date: Tue, 18 Mar 2025 13:04:41 +0530 Subject: [PATCH 8/8] Trigger CI: empty commit