Skip to content
Permalink
Browse files
[JENKINS-32493] Baseline 1.580.1 and Parent POM 2.3
  • Loading branch information
Andres Rodriguez committed Feb 2, 2016
1 parent 9361695 commit 1b010247984b0cd51dc51c68a9bc32cad7f14699
Showing 4 changed files with 69 additions and 68 deletions.
99 pom.xml
@@ -1,18 +1,20 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>1.580.1</version>
</parent>
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>2.3</version>
</parent>

<artifactId>script-security</artifactId>
<version>1.18-SNAPSHOT</version>
<packaging>hpi</packaging>
<name>Script Security Plugin</name>
<description>Allows Jenkins administrators to control what in-process scripts can be run by less-privileged users.</description>
<url>https://wiki.jenkins-ci.org/display/JENKINS/Script+Security+Plugin</url>
<properties>
<findbugs-maven-plugin.version>3.0.2</findbugs-maven-plugin.version>
<jenkins.version>1.580.1</jenkins.version>
<java.level>6</java.level>
<!--TODO: make true after the code cleanup-->
<findbugs.failOnError>false</findbugs.failOnError>
</properties>
@@ -28,57 +30,38 @@
<url>https://github.com/jenkinsci/${project.artifactId}-plugin</url>
<tag>HEAD</tag>
</scm>
<repositories>
<repository>
<id>repo.jenkins-ci.org</id>
<url>http://repo.jenkins-ci.org/public/</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>repo.jenkins-ci.org</id>
<url>http://repo.jenkins-ci.org/public/</url>
</pluginRepository>
</pluginRepositories>
<dependencies>
<dependency>
<groupId>org.kohsuke</groupId>
<artifactId>groovy-sandbox</artifactId>
<version>1.10</version>
<exclusions>
<exclusion>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>annotations</artifactId>
<version>3.0.0</version>
<scope>provided</scope>
</dependency>

<repositories>
<repository>
<id>repo.jenkins-ci.org</id>
<url>http://repo.jenkins-ci.org/public/</url>
</repository>
</repositories>

<pluginRepositories>
<pluginRepository>
<id>repo.jenkins-ci.org</id>
<url>http://repo.jenkins-ci.org/public/</url>
</pluginRepository>
</pluginRepositories>

<dependencies>
<dependency>
<groupId>org.kohsuke</groupId>
<artifactId>groovy-sandbox</artifactId>
<version>1.10</version>
<exclusions>
<exclusion>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>matrix-auth</artifactId>
<version>1.2</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>${findbugs-maven-plugin.version}</version>
<configuration>
<xmlOutput>true</xmlOutput>
<failOnError>${findbugs.failOnError}</failOnError>
</configuration>
<executions>
<execution>
<id>run-findbugs</id>
<phase>verify</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
@@ -1,3 +1,4 @@
<?jelly escape-by-default='true'?>
<div>
Allows Jenkins administrators to control what in-process scripts can be run by less-privileged users.
</div>
@@ -93,6 +93,7 @@ public class SecureGroovyScriptTest {
HtmlForm config = page.getFormByName("config");
getButtonByCaption(config, "Add post-build action").click(); // lib/hudson/project/config-publishers2.jelly
page.getAnchorByText(r.jenkins.getExtensionList(BuildStepDescriptor.class).get(TestGroovyRecorder.DescriptorImpl.class).getDisplayName()).click();
wc.waitForBackgroundJavaScript(10000);
HtmlTextArea script = config.getTextAreaByName("_.script");
String groovy = "build.externalizableId";
script.setText(groovy);
@@ -156,6 +157,7 @@ public class SecureGroovyScriptTest {
HtmlForm config = page.getFormByName("config");
getButtonByCaption(config, "Add post-build action").click(); // lib/hudson/project/config-publishers2.jelly
page.getAnchorByText(r.jenkins.getExtensionList(BuildStepDescriptor.class).get(TestGroovyRecorder.DescriptorImpl.class).getDisplayName()).click();
wc.waitForBackgroundJavaScript(10000);
HtmlTextArea script = config.getTextAreaByName("_.script");
String groovy = "build.externalizableId";
script.setText(groovy);
@@ -194,6 +196,7 @@ public class SecureGroovyScriptTest {
HtmlForm config = page.getFormByName("config");
getButtonByCaption(config, "Add post-build action").click(); // lib/hudson/project/config-publishers2.jelly
page.getAnchorByText(r.jenkins.getExtensionList(BuildStepDescriptor.class).get(TestGroovyRecorder.DescriptorImpl.class).getDisplayName()).click();
wc.waitForBackgroundJavaScript(10000);
HtmlTextArea script = config.getTextAreaByName("_.script");
String groovy = "build.externalizableId";
script.setText(groovy);
@@ -24,6 +24,7 @@

package org.jenkinsci.plugins.scriptsecurity.scripts;

import com.gargoylesoftware.htmlunit.html.HtmlElement;
import org.jenkinsci.plugins.scriptsecurity.scripts.languages.GroovyLanguage;
import org.junit.Test;
import static org.junit.Assert.*;
@@ -33,6 +34,7 @@
import com.gargoylesoftware.htmlunit.Page;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import hudson.Util;
import java.io.IOException;
import java.net.URL;
import java.util.TreeSet;
import org.jvnet.hudson.test.WithoutJenkins;
@@ -119,9 +121,8 @@ public boolean handleConfirm(Page page, String message) {
assertNotNull(page.getElementById(String.format("pcp-%s", CLASSPATH_HASH5)));

// approve a classpath
page.getElementById(String.format("pcp-%s", CLASSPATH_HASH3))
.getElementsByAttribute("button", "class", "approve").get(0).click();

click(page, String.format("pcp-%s", CLASSPATH_HASH3), "approve");

assertNotNull(page.getElementById(String.format("acp-%s", CLASSPATH_HASH1)));
assertNotNull(page.getElementById(String.format("acp-%s", CLASSPATH_HASH2)));
assertNotNull(page.getElementById(String.format("acp-%s", CLASSPATH_HASH3)));
@@ -134,8 +135,7 @@ public boolean handleConfirm(Page page, String message) {
assertNotNull(page.getElementById(String.format("pcp-%s", CLASSPATH_HASH5)));

// deny a classpath
page.getElementById(String.format("pcp-%s", CLASSPATH_HASH4))
.getElementsByAttribute("button", "class", "deny").get(0).click();
click(page, String.format("pcp-%s", CLASSPATH_HASH4), "deny");

assertNotNull(page.getElementById(String.format("acp-%s", CLASSPATH_HASH1)));
assertNotNull(page.getElementById(String.format("acp-%s", CLASSPATH_HASH2)));
@@ -149,9 +149,8 @@ public boolean handleConfirm(Page page, String message) {
assertNotNull(page.getElementById(String.format("pcp-%s", CLASSPATH_HASH5)));

// delete a classpath
page.getElementById(String.format("acp-%s", CLASSPATH_HASH1))
.getElementsByAttribute("button", "class", "delete").get(0).click();

click(page, String.format("acp-%s", CLASSPATH_HASH1), "delete");

assertNull(page.getElementById(String.format("acp-%s", CLASSPATH_HASH1)));
assertNotNull(page.getElementById(String.format("acp-%s", CLASSPATH_HASH2)));
assertNotNull(page.getElementById(String.format("acp-%s", CLASSPATH_HASH3)));
@@ -164,8 +163,8 @@ public boolean handleConfirm(Page page, String message) {
assertNotNull(page.getElementById(String.format("pcp-%s", CLASSPATH_HASH5)));

// clear all classpaths
page.getElementById("approvedClasspathEntries-clear")
.getElementsByTagName("button").get(0).click();
clickAndWait(page.getElementById("approvedClasspathEntries-clear")
.getElementsByTagName("button").get(0));

assertNull(page.getElementById(String.format("acp-%s", CLASSPATH_HASH1)));
assertNull(page.getElementById(String.format("acp-%s", CLASSPATH_HASH2)));
@@ -179,4 +178,19 @@ public boolean handleConfirm(Page page, String message) {
assertNotNull(page.getElementById(String.format("pcp-%s", CLASSPATH_HASH5)));
}

private void clickAndWait(HtmlElement e) throws IOException {
e.click();
e.getPage().getWebClient().waitForBackgroundJavaScript(10000);
}

private void click(HtmlPage page, String id, String value) throws IOException {
for (HtmlElement e : page.getElementById(id).getElementsByTagName("button")) {
if (e.hasAttribute("class") && value.equals(e.getAttribute("class"))) {
clickAndWait(e);
return;
}
}
throw new AssertionError(String.format("Unable to find button with class [%s] in element [%s]", value, id));
}

}

0 comments on commit 1b01024

Please sign in to comment.