From e0990b4b6c03210b344318015787d8cde645cb6a Mon Sep 17 00:00:00 2001 From: Jeff Thompson Date: Mon, 19 Oct 2020 14:47:36 -0600 Subject: [PATCH] Add tests for downloading JNLP file at new and obsoleted names. --- .../java/hudson/slaves/SlaveComputer.java | 1 - .../java/hudson/slaves/JNLPLauncherTest.java | 19 +++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/hudson/slaves/SlaveComputer.java b/core/src/main/java/hudson/slaves/SlaveComputer.java index 9d79829343..786da68f8e 100644 --- a/core/src/main/java/hudson/slaves/SlaveComputer.java +++ b/core/src/main/java/hudson/slaves/SlaveComputer.java @@ -814,7 +814,6 @@ public class SlaveComputer extends Computer { @WebMethod(name="slave-agent.jnlp") public HttpResponse doSlaveAgentJnlp(StaplerRequest req, StaplerResponse res) { - return doJenkinsAgentJnlp(req, res); } diff --git a/test/src/test/java/hudson/slaves/JNLPLauncherTest.java b/test/src/test/java/hudson/slaves/JNLPLauncherTest.java index fdbb659e82..1d2cced055 100644 --- a/test/src/test/java/hudson/slaves/JNLPLauncherTest.java +++ b/test/src/test/java/hudson/slaves/JNLPLauncherTest.java @@ -23,6 +23,7 @@ */ package hudson.slaves; +import com.gargoylesoftware.htmlunit.Page; import com.gargoylesoftware.htmlunit.html.HtmlPage; import hudson.Proc; import hudson.Util; @@ -49,6 +50,7 @@ import java.util.ArrayList; import java.util.List; import java.util.concurrent.TimeUnit; +import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; @@ -297,4 +299,21 @@ public class JNLPLauncherTest { j.assertEqualBeans(original,s.getLauncher(),"tunnel,vmargs"); j.assertEqualDataBoundBeans(((JNLPLauncher) s.getLauncher()).getWorkDirSettings(), custom); } + + @Test + public void testJnlpFileDownload() throws Exception { + assertJnlpFileDownload("/jenkins-agent.jnlp"); + } + + @Test + public void testObsoletedJnlpFileDownload() throws Exception { + assertJnlpFileDownload("/slave-agent.jnlp"); + } + + private void assertJnlpFileDownload(String filename) throws Exception { + Computer c = addTestAgent(false); + Page p = j.createWebClient().getPage(j.getURL() + "computer/" + c.getName() + filename); + assertThat(p.getWebResponse().getStatusCode(), is(200)); + } + } -- GitLab