Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
5 changes: 2 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>4.38</version>
<version>4.40</version>
Copy link
Member Author

Choose a reason for hiding this comment

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

This is needed to allow testing with Java 17 in jenkinsci/bom.

<relativePath />
</parent>

Expand All @@ -29,10 +29,9 @@
<properties>
<revision>3.10.0</revision>
<changelist>-SNAPSHOT</changelist>
<gitHubRepo>jenkinsci/config-file-provider-plugin</gitHubRepo>
<gitHubRepo>jenkinsci/${project.artifactId}-plugin</gitHubRepo>
Copy link
Member Author

Choose a reason for hiding this comment

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

While I was here, improving this bit of logic to be consistent with the canonical format in jenkinsci/archetypes.

<maven.javadoc.skip>true</maven.javadoc.skip>
<jenkins.version>2.303.3</jenkins.version>
Copy link
Member Author

Choose a reason for hiding this comment

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

Note that we are not bumping the baseline here. This is to support my efforts to switch jenkinsci/bom to JENKINS-45047. This also is friendlier to users by allowing new releases to be adopted by older consumers.

<java.level>8</java.level>
Copy link
Member Author

Choose a reason for hiding this comment

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

As of the update to parent POM 4.40, java.level is deprecated and inferred from the Jenkins core version. So this is no longer needed. I am deleting it to silence the deprecation warning.

<hpi.compatibleSinceVersion>2.15</hpi.compatibleSinceVersion>
</properties>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.gargoylesoftware.htmlunit.html.HtmlInput;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import com.gargoylesoftware.htmlunit.html.HtmlRadioButtonInput;
import hudson.util.VersionNumber;
import org.jenkinsci.plugins.configfiles.custom.CustomConfig;
import org.junit.Rule;
import org.junit.Test;
Expand Down Expand Up @@ -55,7 +56,8 @@ public void regularCaseStillWorking() throws Exception {
assertThat(store.getConfigs(), hasSize(1));

HtmlPage configFiles = wc.goTo("configfiles");
HtmlAnchor removeAnchor = configFiles.getDocumentElement().getFirstByXPath("//a[contains(@onclick, 'removeConfig?id=" + CONFIG_ID + "')]");
String attribute = j.jenkins.getVersion().isOlderThan(new VersionNumber("2.324")) ? "onclick" : "data-url";
Copy link
Member Author

Choose a reason for hiding this comment

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

Here and elsewhere, we make the test compatible with both old and new versions of Jenkins by choosing the correct attribute based on the Jenkins version of the code under test.

HtmlAnchor removeAnchor = configFiles.getDocumentElement().getFirstByXPath("//a[contains(@" + attribute + ", 'removeConfig?id=" + CONFIG_ID + "')]");

AtomicReference<Boolean> confirmCalled = new AtomicReference<>(false);
wc.setConfirmHandler((page, s) -> {
Expand Down Expand Up @@ -87,7 +89,8 @@ public void xssPrevention() throws Exception {
JenkinsRule.WebClient wc = j.createWebClient();

HtmlPage configFiles = wc.goTo("configfiles");
HtmlAnchor removeAnchor = configFiles.getDocumentElement().getFirstByXPath("//a[contains(@onclick, 'removeConfig?id=" + CONFIG_ID + "')]");
String attribute = j.jenkins.getVersion().isOlderThan(new VersionNumber("2.324")) ? "onclick" : "data-url";
HtmlAnchor removeAnchor = configFiles.getDocumentElement().getFirstByXPath("//a[contains(@" + attribute + ", 'removeConfig?id=" + CONFIG_ID + "')]");

AtomicReference<Boolean> confirmCalled = new AtomicReference<>(false);
AtomicReference<Boolean> alertCalled = new AtomicReference<>(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.gargoylesoftware.htmlunit.html.HtmlAnchor;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import hudson.model.Item;
import hudson.util.VersionNumber;
import jenkins.model.Jenkins;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
Expand Down Expand Up @@ -241,7 +242,8 @@ public void xssPreventionInFolder() throws Exception {
// Clicking the button works
// If we click on the link, it goes via POST, therefore it removes it successfully
HtmlPage configFiles = wc.goTo(f1.getUrl() + "configfiles");
HtmlAnchor removeAnchor = configFiles.getDocumentElement().getFirstByXPath("//a[contains(@onclick, 'removeConfig?id=" + CONFIG_ID + "')]");
String attribute = r.jenkins.getVersion().isOlderThan(new VersionNumber("2.324")) ? "onclick" : "data-url";
HtmlAnchor removeAnchor = configFiles.getDocumentElement().getFirstByXPath("//a[contains(@" + attribute + ", 'removeConfig?id=" + CONFIG_ID + "')]");

AtomicReference<Boolean> confirmCalled = new AtomicReference<>(false);
wc.setConfirmHandler((page, s) -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.gargoylesoftware.htmlunit.html.HtmlAnchor;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import hudson.util.VersionNumber;
import jenkins.model.GlobalConfiguration;
import org.jenkinsci.plugins.configfiles.GlobalConfigFiles;
import org.jenkinsci.plugins.configfiles.custom.CustomConfig;
Expand Down Expand Up @@ -50,7 +51,8 @@ public void xssPrevention() throws Exception {
// Clicking the button works
// If we click on the link, it goes via POST, therefore it removes it successfully
HtmlPage configFiles = wc.goTo("configfiles");
HtmlAnchor removeAnchor = configFiles.getDocumentElement().getFirstByXPath("//a[contains(@onclick, 'removeConfig?id=" + CONFIG_ID + "')]");
String attribute = j.jenkins.getVersion().isOlderThan(new VersionNumber("2.324")) ? "onclick" : "data-url";
HtmlAnchor removeAnchor = configFiles.getDocumentElement().getFirstByXPath("//a[contains(@" + attribute + ", 'removeConfig?id=" + CONFIG_ID + "')]");

AtomicReference<Boolean> confirmCalled = new AtomicReference<>(false);
wc.setConfirmHandler((page, s) -> {
Expand Down