From 8355ec6300e7a87e56213721bf8df155527d5dfb Mon Sep 17 00:00:00 2001 From: olivier lamy Date: Thu, 19 Mar 2020 17:29:41 +1000 Subject: [PATCH] fix pct tests failing Signed-off-by: olivier lamy --- pom.xml | 37 ++++++++++++------- .../java/hudson/plugins/jira/JiraSite.java | 2 +- .../jira/JiraSiteSecurity1029Test.java | 10 ++++- 3 files changed, 33 insertions(+), 16 deletions(-) diff --git a/pom.xml b/pom.xml index 9fc8813ba..12c21d63c 100644 --- a/pom.xml +++ b/pom.xml @@ -24,9 +24,10 @@ 5.2.1 3.0.0 2.0 + 1.7.26 - 2.60.3 + 2.176.4 false @@ -34,7 +35,7 @@ 2.4.5 2.20 - 1.8 + 1.36 @@ -267,7 +268,7 @@ org.jenkins-ci.plugins jackson2-api - 2.8.11.2 + 2.10.2 @@ -319,23 +320,16 @@ org.jenkins-ci.plugins credentials - 2.1.19 + 2.2.1 - io.jenkins - configuration-as-code + io.jenkins.configuration-as-code + test-harness ${configuration-as-code.version} test - - io.jenkins - configuration-as-code - ${configuration-as-code.version} - tests - test - org.hamcrest hamcrest-all @@ -400,10 +394,25 @@ org.jenkins-ci.plugins junit - 1.3 + 1.20 + test + + + + org.jenkins-ci.main + jenkins-test-harness + 2.56 + + + org.codehaus.groovy + groovy-all + 2.4.12 + + + diff --git a/src/main/java/hudson/plugins/jira/JiraSite.java b/src/main/java/hudson/plugins/jira/JiraSite.java index f006bf090..f808797dd 100644 --- a/src/main/java/hudson/plugins/jira/JiraSite.java +++ b/src/main/java/hudson/plugins/jira/JiraSite.java @@ -1126,7 +1126,7 @@ public FormValidation doValidate(@QueryParameter String url, @AncestorInPath Item item) { if (item == null) { - Jenkins.getInstance().checkPermission(Jenkins.ADMINISTER); + Jenkins.get().checkPermission(Jenkins.ADMINISTER); } else { item.checkPermission(Item.CONFIGURE); } diff --git a/src/test/java/hudson/plugins/jira/JiraSiteSecurity1029Test.java b/src/test/java/hudson/plugins/jira/JiraSiteSecurity1029Test.java index 392db3ba2..ba176d7e2 100644 --- a/src/test/java/hudson/plugins/jira/JiraSiteSecurity1029Test.java +++ b/src/test/java/hudson/plugins/jira/JiraSiteSecurity1029Test.java @@ -11,6 +11,7 @@ import hudson.model.Item; import hudson.model.User; import jenkins.model.Jenkins; +import jenkins.security.ApiTokenProperty; import net.sf.json.JSONObject; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.ServerConnector; @@ -81,13 +82,20 @@ public void cannotLeakCredentials() throws Exception { systemProvider.save(); User admin = User.getById(ADMIN, true); + admin.addProperty( new ApiTokenProperty() ); + admin.getProperty( ApiTokenProperty.class ).changeApiToken(); User user = User.getById(USER, true); + user.addProperty( new ApiTokenProperty() ); + user.getProperty( ApiTokenProperty.class ).changeApiToken(); + User userFolderConfigure = User.getById(USER_FOLDER_CONFIGURE, true); + userFolderConfigure.addProperty( new ApiTokenProperty() ); + userFolderConfigure.getProperty( ApiTokenProperty.class ).changeApiToken(); { // as an admin I should be able to validate my url / credentials JenkinsRule.WebClient wc = j.createWebClient(); wc.getOptions().setThrowExceptionOnFailingStatusCode(false); - wc.withBasicApiToken(admin); + wc = wc.withBasicApiToken(admin); String jiraSiteValidateUrl = j.getURL() + "descriptorByName/" + JiraSite.class.getName() + "/validate"; WebRequest request = new WebRequest(new URL(jiraSiteValidateUrl), HttpMethod.POST);