Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ THE SOFTWARE.
<dependency>
<groupId>org.jenkins-ci.main</groupId>
<artifactId>jenkins-test-harness</artifactId>
<version>2276.va_79e4182e71e</version>
<version>2287.v4f0199c6eda_8</version>
<scope>test</scope>
<exclusions>
<exclusion>
Expand Down
4 changes: 2 additions & 2 deletions test/src/test/java/hudson/slaves/JNLPLauncherRealTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@
package hudson.slaves;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.endsWith;
import static org.hamcrest.Matchers.is;

import hudson.ExtensionList;
import hudson.PluginWrapper;
import hudson.model.FreeStyleBuild;
import hudson.model.FreeStyleProject;
import hudson.model.Slave;
import java.io.File;
import jenkins.agents.WebSocketAgentsTest;
import jenkins.slaves.JnlpSlaveAgentProtocol4;
import org.junit.Rule;
Expand Down Expand Up @@ -104,7 +104,7 @@ public void run(JenkinsRule r) throws Throwable {
p.setAssignedNode(agent);
FreeStyleBuild b = r.buildAndAssertSuccess(p);
if (webSocket) {
assertThat(agent.toComputer().getSystemProperties().get("java.class.path"), is(new File(r.jenkins.root, "agent.jar").getAbsolutePath()));
assertThat(agent.toComputer().getSystemProperties().get("java.class.path").toString(), endsWith("agent.jar"));

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assertion introduced in #6780, if I recall correctly just to somehow use the Channel, and made more brittle in #7192. Does not need to check the exact path, or even really this property, it is just exercising Remoting.

}
System.err.println(JenkinsRule.getLog(b));
}
Expand Down
9 changes: 6 additions & 3 deletions test/src/test/java/jenkins/security/Security3430Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import org.hamcrest.Description;
import org.hamcrest.Matcher;
import org.hamcrest.TypeSafeMatcher;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.jvnet.hudson.test.InboundAgentRule;
Expand All @@ -63,14 +64,16 @@ public void runWithPreviousAgentJar() throws Throwable {
runWithRemoting("3256.v88a_f6e922152", "/old-remoting/remoting-before-SECURITY-3430-fix.jar", true);
}

@Ignore("TODO Expected: is an empty collection; but: <[Allowing URL: file:/…/test/target/webroot…/WEB-INF/lib/stapler-1903.v994a_db_314d58.jar, Determined to be core jar: file:/…/test/target/webroot…/WEB-INF/lib/stapler-1903.v994a_db_314d58.jar]>")
Comment thread
daniel-beck marked this conversation as resolved.
@Test
public void runWithCurrentAgentJar() throws Throwable {
runWithRemoting(null, null, false);
}

private void runWithRemoting(String expectedRemotingVersion, String remotingResourcePath, boolean requestingJarFromAgent) throws Throwable {
if (expectedRemotingVersion != null) {
FileUtils.copyURLToFile(Security3430Test.class.getResource(remotingResourcePath), new File(jj.getHome(), "agent.jar"));
// TODO brittle; rather call InboundAgentRule.start(AgentArguments, Options) with a known agentJar
FileUtils.copyURLToFile(Security3430Test.class.getResource(remotingResourcePath), new File(System.getProperty("java.io.tmpdir"), "agent.jar"));

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Introduced in 5d26b53. jenkinsci/jenkins-test-harness#838 picks a different location.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jenkinsci/jenkins-test-harness#843 fixes location reuse that likely caused the failure being @Ignored here.

}

jj.startJenkins();
Expand Down Expand Up @@ -126,7 +129,7 @@ private static void _run(JenkinsRule j, String agentName, String expectedRemotin
if (requestingJarFromAgent) {
assertThat(logRecords, hasItem(logMessageContainsString("Allowing URL: file:/")));
} else {
assertThat(logRecords, is(empty()));
assertThat(logRecords.stream().map(LogRecord::getMessage).toList(), is(empty()));

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previous failure message was unhelpful (LogRecord does not override toString).

}

logHandler.clear();
Expand All @@ -140,7 +143,7 @@ private static void _run(JenkinsRule j, String agentName, String expectedRemotin
assertThat(ex.getMessage(), containsString("No hudson.remoting.JarURLValidator has been set for this channel, so all #fetchJar calls are rejected. This is likely a bug in Jenkins. As a workaround, try updating the agent.jar file."));
} else {
assertTrue(channel.preloadJar(j.jenkins.getPluginManager().uberClassLoader, Stapler.class));
assertThat(logRecords, is(empty()));
assertThat(logRecords.stream().map(LogRecord::getMessage).toList(), is(empty()));
}
}
}
Expand Down