diff --git a/src/main/java/org/jenkinsci/plugins/authorizeproject/AuthorizeProjectStrategyDescriptor.java b/src/main/java/org/jenkinsci/plugins/authorizeproject/AuthorizeProjectStrategyDescriptor.java index 8236cdc..9826cc9 100644 --- a/src/main/java/org/jenkinsci/plugins/authorizeproject/AuthorizeProjectStrategyDescriptor.java +++ b/src/main/java/org/jenkinsci/plugins/authorizeproject/AuthorizeProjectStrategyDescriptor.java @@ -88,7 +88,7 @@ public String getGlobalSecurityConfigPage() { */ public static List getDescriptorsForGlobalSecurityConfigPage() { List> all = AuthorizeProjectStrategy.all(); - List r = new ArrayList(all.size()); + List r = new ArrayList<>(all.size()); for (Descriptor d: all) { if ( d instanceof AuthorizeProjectStrategyDescriptor diff --git a/src/main/java/org/jenkinsci/plugins/authorizeproject/strategy/SpecificUsersAuthorizationStrategy.java b/src/main/java/org/jenkinsci/plugins/authorizeproject/strategy/SpecificUsersAuthorizationStrategy.java index c2d13e0..9d650e6 100644 --- a/src/main/java/org/jenkinsci/plugins/authorizeproject/strategy/SpecificUsersAuthorizationStrategy.java +++ b/src/main/java/org/jenkinsci/plugins/authorizeproject/strategy/SpecificUsersAuthorizationStrategy.java @@ -255,7 +255,7 @@ protected static SpecificUsersAuthorizationStrategy getCurrentStrategy(Job protected Object readResolve() throws ObjectStreamException { SpecificUsersAuthorizationStrategy self = (SpecificUsersAuthorizationStrategy)super.readResolve(); if (self.noNeedReauthentication != null) { - self.setDontRestrictJobConfiguration(self.noNeedReauthentication.booleanValue()); + self.setDontRestrictJobConfiguration(self.noNeedReauthentication); } return self; } diff --git a/src/main/resources/org/jenkinsci/plugins/authorizeproject/AuthorizeProjectProperty/help-strategy.groovy b/src/main/resources/org/jenkinsci/plugins/authorizeproject/AuthorizeProjectProperty/help-strategy.groovy index bb32c86..e492996 100644 --- a/src/main/resources/org/jenkinsci/plugins/authorizeproject/AuthorizeProjectProperty/help-strategy.groovy +++ b/src/main/resources/org/jenkinsci/plugins/authorizeproject/AuthorizeProjectProperty/help-strategy.groovy @@ -22,18 +22,18 @@ * THE SOFTWARE. */ -package org.jenkinsci.plugins.authorizeproject; +package org.jenkinsci.plugins.authorizeproject -import jenkins.model.Jenkins; +import jenkins.model.Jenkins -st = namespace("jelly:stapler"); +st = namespace("jelly:stapler") -def descriptor = Jenkins.instance.getDescriptorOrDie(AuthorizeProjectProperty.class); +def descriptor = Jenkins.instance.getDescriptorOrDie(AuthorizeProjectProperty.class) -def myselfName = descriptor.plugin.shortName; +def myselfName = descriptor.plugin.shortName // help file for strategy itself. -def strategyRawHelpFile = descriptor.getHelpFile("strategyRaw"); +def strategyRawHelpFile = descriptor.getHelpFile("strategyRaw") if (strategyRawHelpFile != null) { div( @@ -41,25 +41,24 @@ if (strategyRawHelpFile != null) { helpURL: String.format("%s%s", rootURL, strategyRawHelpFile), myselfName: myselfName, ) { - text("Loading..."); + text("Loading...") } } dl() { descriptor.strategyList.each() { d -> - def helpFile = d.getHelpFile(); - dt(d.displayName); + def helpFile = d.getHelpFile() + dt(d.displayName) if (helpFile != null) { dd( class: "authorize-project-nested-help", helpURL: String.format("%s%s", rootURL, helpFile), myselfName: myselfName, ) { - text("Loading..."); + text("Loading...") } } else { - dd("No help available."); + dd("No help available.") } } } - diff --git a/src/test/java/org/jenkinsci/plugins/authorizeproject/ProjectQueueItemAuthenticatorTest.java b/src/test/java/org/jenkinsci/plugins/authorizeproject/ProjectQueueItemAuthenticatorTest.java index 80a088a..08dcf87 100644 --- a/src/test/java/org/jenkinsci/plugins/authorizeproject/ProjectQueueItemAuthenticatorTest.java +++ b/src/test/java/org/jenkinsci/plugins/authorizeproject/ProjectQueueItemAuthenticatorTest.java @@ -74,9 +74,6 @@ import hudson.FilePath; import hudson.Launcher; -/** - * - */ public class ProjectQueueItemAuthenticatorTest { @Rule public JenkinsRule j = new AuthorizeProjectJenkinsRule(SpecificUsersAuthorizationStrategy.class); diff --git a/src/test/java/org/jenkinsci/plugins/authorizeproject/strategy/AnonymousAuthorizationStrategyTest.java b/src/test/java/org/jenkinsci/plugins/authorizeproject/strategy/AnonymousAuthorizationStrategyTest.java index 786d817..389a173 100644 --- a/src/test/java/org/jenkinsci/plugins/authorizeproject/strategy/AnonymousAuthorizationStrategyTest.java +++ b/src/test/java/org/jenkinsci/plugins/authorizeproject/strategy/AnonymousAuthorizationStrategyTest.java @@ -36,9 +36,6 @@ import org.junit.Test; import org.jvnet.hudson.test.JenkinsRule; -/** - * - */ public class AnonymousAuthorizationStrategyTest { @Rule public JenkinsRule j = new AuthorizeProjectJenkinsRule(); diff --git a/src/test/java/org/jenkinsci/plugins/authorizeproject/strategy/SpecificUsersAuthorizationStrategyTest.java b/src/test/java/org/jenkinsci/plugins/authorizeproject/strategy/SpecificUsersAuthorizationStrategyTest.java index e619d0c..17f70f3 100644 --- a/src/test/java/org/jenkinsci/plugins/authorizeproject/strategy/SpecificUsersAuthorizationStrategyTest.java +++ b/src/test/java/org/jenkinsci/plugins/authorizeproject/strategy/SpecificUsersAuthorizationStrategyTest.java @@ -78,9 +78,6 @@ import com.gargoylesoftware.htmlunit.xml.XmlPage; import com.google.common.collect.Sets; -/** - * - */ public class SpecificUsersAuthorizationStrategyTest { @Rule public JenkinsRule j = new AuthorizeProjectJenkinsRule(SpecificUsersAuthorizationStrategy.class); @@ -346,8 +343,8 @@ public void testRestInterfaceSuccess() throws Exception { srcProject.save(); WebClient wc = j.createWebClient(); - wc.login("test1", "test1"); - + wc.login("test1"); + // GET config.xml of srcProject (userid is set to test1) String configXml = getConfigXml(wc.goToXml(String.format("%s/config.xml", srcProject.getUrl()))); @@ -400,8 +397,8 @@ public void testRestInterfaceFailure() throws Exception { srcProject.save(); WebClient wc = j.createWebClient(); - wc.login("test1", "test1"); - + wc.login("test1"); + // GET config.xml of srcProject (userid is set to admin) String configXml = getConfigXml(wc.goToXml(String.format("%s/config.xml", srcProject.getUrl()))); @@ -459,7 +456,7 @@ public void testCliSuccess() throws Exception { srcProject.save(); WebClient wc = j.createWebClient(); - wc.login("test1", "test1"); + wc.login("test1"); // GET config.xml of srcProject (userid is set to test1) String configXml = null; @@ -527,8 +524,8 @@ public void testCliFailure() throws Exception { srcProject.save(); WebClient wc = j.createWebClient(); - wc.login("test1", "test1"); - + wc.login("test1"); + // GET config.xml of srcProject (userid is set to admin) String configXml = null; { @@ -942,8 +939,8 @@ public void testConfigureJobByTheUserIsAllowed() throws Exception { p.save(); WebClient wc = j.createWebClient(); - wc.login("test1", "test1"); - + wc.login("test1"); + j.submit(wc.getPage(p, "configure").getFormByName("config")); } @@ -956,8 +953,8 @@ public void testConfigureJobByAnotherUserIsForbidden() throws Exception { p.save(); WebClient wc = j.createWebClient(); - wc.login("test2", "test2"); - + wc.login("test2"); + try { j.submit(wc.getPage(p, "configure").getFormByName("config")); } catch (FailingHttpStatusCodeException e) { @@ -976,8 +973,8 @@ public void testDontRestrictJobConfiguration() throws Exception { p.save(); WebClient wc = j.createWebClient(); - wc.login("test2", "test2"); - + wc.login("test2"); + j.submit(wc.getPage(p, "configure").getFormByName("config")); } @@ -996,8 +993,8 @@ public void testConfigureJobBySystemAdminIsAllowed() throws Exception { p.save(); WebClient wc = j.createWebClient(); - wc.login("admin", "admin"); - + wc.login("admin"); + j.submit(wc.getPage(p, "configure").getFormByName("config")); } @@ -1017,7 +1014,7 @@ public void testConfigureJobByJobAdminIsNotAllowed() throws Exception { p.save(); WebClient wc = j.createWebClient(); - wc.login("test2", "test2"); + wc.login("test2"); try { j.submit(wc.getPage(p, "configure").getFormByName("config")); diff --git a/src/test/java/org/jenkinsci/plugins/authorizeproject/strategy/SystemAuthorizationStrategyTest.java b/src/test/java/org/jenkinsci/plugins/authorizeproject/strategy/SystemAuthorizationStrategyTest.java index a3e5b90..afbae29 100644 --- a/src/test/java/org/jenkinsci/plugins/authorizeproject/strategy/SystemAuthorizationStrategyTest.java +++ b/src/test/java/org/jenkinsci/plugins/authorizeproject/strategy/SystemAuthorizationStrategyTest.java @@ -66,9 +66,6 @@ import static org.junit.Assert.assertThat; import static org.junit.Assert.fail; -/** - * - */ public class SystemAuthorizationStrategyTest { @Rule public JenkinsRule j = new AuthorizeProjectJenkinsRule(SystemAuthorizationStrategy.class); @@ -171,7 +168,7 @@ public void testRestInterfaceSuccess() throws Exception { srcProject.save(); WebClient wc = j.createWebClient(); - wc.login("admin", "admin"); + wc.login("admin"); // GET config.xml of srcProject String configXml = getConfigXml(wc.goToXml(String.format("%s/config.xml", srcProject.getUrl()))); @@ -219,7 +216,7 @@ public void testRestInterfaceFailure() throws Exception { srcProject.save(); WebClient wc = j.createWebClient(); - wc.login("test1", "test1"); + wc.login("test1"); // we want to verify that you cannot clone a job even if you can reconfigure a job that uses this strategy j.getInstance().getDescriptorByType(SystemAuthorizationStrategy.DescriptorImpl.class) @@ -276,7 +273,7 @@ public void testCliSuccess() throws Exception { srcProject.save(); WebClient wc = j.createWebClient(); - wc.login("admin", "admin"); + wc.login("admin"); // GET config.xml of srcProject String configXml = null; @@ -340,7 +337,7 @@ public void testCliFailure() throws Exception { srcProject.save(); WebClient wc = j.createWebClient(); - wc.login("test1", "test1"); + wc.login("test1"); // we want to verify that you cannot clone a job even if you can reconfigure a job that uses this strategy j.getInstance().getDescriptorByType(SystemAuthorizationStrategy.DescriptorImpl.class).setPermitReconfiguration(true); diff --git a/src/test/java/org/jenkinsci/plugins/authorizeproject/strategy/TriggeringUsersAuthorizationStrategyTest.java b/src/test/java/org/jenkinsci/plugins/authorizeproject/strategy/TriggeringUsersAuthorizationStrategyTest.java index ca16f34..2d50999 100644 --- a/src/test/java/org/jenkinsci/plugins/authorizeproject/strategy/TriggeringUsersAuthorizationStrategyTest.java +++ b/src/test/java/org/jenkinsci/plugins/authorizeproject/strategy/TriggeringUsersAuthorizationStrategyTest.java @@ -50,9 +50,6 @@ import org.jvnet.hudson.test.JenkinsRule.WebClient; import org.jvnet.hudson.test.recipes.LocalData; -/** - * - */ public class TriggeringUsersAuthorizationStrategyTest { @Rule public JenkinsRule j = new AuthorizeProjectJenkinsRule(); @@ -106,7 +103,7 @@ public void testAuthenticate() throws Exception { // if triggered from a user, run in the privilege of that user. { assertNull(p.getLastBuild()); - WebClient wc = j.createWebClient().login("test1", "test1"); + WebClient wc = j.createWebClient().login("test1"); triggerBuildWithoutParameters(wc, p); j.waitUntilNoActivity(); FreeStyleBuild b = p.getLastBuild(); @@ -120,7 +117,7 @@ public void testAuthenticate() throws Exception { // test with another user. { assertNull(p.getLastBuild()); - WebClient wc = j.createWebClient().login("test2", "test2"); + WebClient wc = j.createWebClient().login("test2"); triggerBuildWithoutParameters(wc, p); j.waitUntilNoActivity(); FreeStyleBuild b = p.getLastBuild(); @@ -148,7 +145,7 @@ public void testAuthenticateDownstream() throws Exception { // if triggered from a user, its downstream runs in the privilege of that user. { assertNull(p.getLastBuild()); - WebClient wc = j.createWebClient().login("test1", "test1"); + WebClient wc = j.createWebClient().login("test1"); triggerBuildWithoutParameters(wc, upstream); j.waitUntilNoActivity(); FreeStyleBuild b = p.getLastBuild(); diff --git a/src/test/java/org/jenkinsci/plugins/authorizeproject/testutil/AuthorizationCheckBuilder.java b/src/test/java/org/jenkinsci/plugins/authorizeproject/testutil/AuthorizationCheckBuilder.java index efed364..8607896 100644 --- a/src/test/java/org/jenkinsci/plugins/authorizeproject/testutil/AuthorizationCheckBuilder.java +++ b/src/test/java/org/jenkinsci/plugins/authorizeproject/testutil/AuthorizationCheckBuilder.java @@ -37,9 +37,6 @@ import hudson.tasks.BuildStepDescriptor; import hudson.tasks.Builder; -/** - * - */ public class AuthorizationCheckBuilder extends Builder { // "transient" is required for exclusion from serialization - see https://jenkins.io/redirect/class-filter/ diff --git a/src/test/java/org/jenkinsci/plugins/authorizeproject/testutil/AuthorizeProjectJenkinsRule.java b/src/test/java/org/jenkinsci/plugins/authorizeproject/testutil/AuthorizeProjectJenkinsRule.java index 39fd623..8b809b4 100644 --- a/src/test/java/org/jenkinsci/plugins/authorizeproject/testutil/AuthorizeProjectJenkinsRule.java +++ b/src/test/java/org/jenkinsci/plugins/authorizeproject/testutil/AuthorizeProjectJenkinsRule.java @@ -39,9 +39,6 @@ import com.gargoylesoftware.htmlunit.WebResponse; -/** - * - */ public class AuthorizeProjectJenkinsRule extends JenkinsRule { private Set>> enabledStrategiesByClass; private Set>> disabledStrategiesByClass;