Skip to content

Commit

Permalink
Merge pull request #18 from armfergom/JENKINS-34336
Browse files Browse the repository at this point in the history
[JENKINS-34336] Upgrade to parent pom 2.6
  • Loading branch information
stephenc committed Apr 22, 2016
2 parents be49820 + 23d013a commit 7f642fe
Show file tree
Hide file tree
Showing 10 changed files with 77 additions and 135 deletions.
97 changes: 3 additions & 94 deletions pom.xml
Expand Up @@ -29,7 +29,7 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>1.532.2</version>
<version>2.6</version>
</parent>

<artifactId>ssh-credentials</artifactId>
Expand Down Expand Up @@ -65,11 +65,8 @@
</scm>

<properties>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<project.build.outputEncoding>UTF-8</project.build.outputEncoding>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.findbugs.version>3.0.1</maven.findbugs.version>
<maven.findbugs.failure.strict>true</maven.findbugs.failure.strict>
<jenkins.version>1.580.1</jenkins.version>
<java.level>6</java.level>
</properties>

<repositories>
Expand Down Expand Up @@ -101,100 +98,12 @@
</dependency>
<!-- jenkins dependencies -->
<!-- test dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.sshd</groupId>
<artifactId>sshd-core</artifactId>
<version>0.12.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
<version>1.6.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>annotations</artifactId>
<version>3.0.0</version>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.3.1</version>
<executions>
<execution>
<id>enforce-maven</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireMavenVersion>
<version>(,2.1.0),(2.1.0,2.2.0),(2.2.0,)</version>
<message>Maven 2.1.0 and 2.2.0 produce incorrect GPG signatures and checksums respectively.</message>
</requireMavenVersion>
<requireMavenVersion>
<version>(,3.0),[3.0.4,)</version>
<message>Maven 3.0 through 3.0.3 inclusive do not pass correct settings.xml to Maven Release Plugin.</message>
</requireMavenVersion>
</rules>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.jenkins-ci.tools</groupId>
<artifactId>maven-hpi-plugin</artifactId>
<configuration>
<compatibleSinceVersion>1.0</compatibleSinceVersion>
</configuration>
</plugin>
<plugin>
<artifactId>maven-release-plugin</artifactId>
<version>2.5</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>${maven.findbugs.version}</version>
<configuration>
<xmlOutput>true</xmlOutput>
<findbugsXmlWithMessages>true</findbugsXmlWithMessages>
<excludeFilterFile>src/findbugs/excludesFilter.xml</excludeFilterFile>
<failOnError>${maven.findbugs.failure.strict}</failOnError>
</configuration>
<executions>
<execution>
<id>run-findbugs</id>
<phase>verify</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
Expand Up @@ -30,13 +30,14 @@
import com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials;
import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import hudson.model.BuildListener;
import hudson.model.Hudson;
import hudson.model.TaskListener;
import hudson.remoting.Callable;
import hudson.remoting.Channel;
import hudson.util.StreamTaskListener;
import jenkins.model.Jenkins;
import jenkins.security.MasterToSlaveCallable;
import net.jcip.annotations.GuardedBy;

import java.io.IOException;
Expand Down Expand Up @@ -180,6 +181,7 @@ public static <C, U extends StandardUsernameCredentials> SSHAuthenticator<C, U>
* @return a {@link SSHAuthenticator} that may or may not be able to successfully authenticate.
* @since 1.4
*/
@SuppressFBWarnings(value="NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE", justification="https://github.com/jenkinsci/jenkins/pull/2094")
@NonNull
public static <C, U extends StandardUsernameCredentials> SSHAuthenticator<C, U> newInstance(@NonNull C connection,
@NonNull U user,
Expand All @@ -194,7 +196,8 @@ public static <C, U extends StandardUsernameCredentials> SSHAuthenticator<C, U>
factories = Jenkins.getInstance().getExtensionList(SSHAuthenticatorFactory.class);
} else {
// if running on the slave, bring these factories over here
factories = Channel.current().call(new Callable<Collection<SSHAuthenticatorFactory>, IOException>() {
factories = Channel.current().call(new MasterToSlaveCallable<Collection<SSHAuthenticatorFactory>, IOException>() {
@SuppressFBWarnings(value="NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE", justification="https://github.com/jenkinsci/jenkins/pull/2094")
public Collection<SSHAuthenticatorFactory> call() throws IOException {
return new ArrayList<SSHAuthenticatorFactory>(
Jenkins.getInstance().getExtensionList(SSHAuthenticatorFactory.class));
Expand Down
Expand Up @@ -23,6 +23,7 @@
~ THE SOFTWARE.
-->

<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:f="/lib/form">
<f:entry title="${%Key}" field="privateKey">
<f:textarea/>
Expand Down
Expand Up @@ -23,6 +23,7 @@
~ THE SOFTWARE.
-->

<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:f="/lib/form">
<f:entry title="${%File}" field="privateKeyFile">
<f:textbox/>
Expand Down
Expand Up @@ -23,6 +23,7 @@
~ THE SOFTWARE.
-->

<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:f="/lib/form" xmlns:st="jelly:stapler">
<f:entry title="${%Username}" field="username">
<f:textbox/>
Expand Down
Expand Up @@ -33,6 +33,8 @@
import hudson.model.Hudson;
import hudson.remoting.Callable;
import hudson.security.ACL;
import jenkins.security.MasterToSlaveCallable;

import org.junit.Test;
import static org.junit.Assert.*;
import org.junit.Rule;
Expand All @@ -56,7 +58,7 @@ public class BasicSSHUserPrivateKeyTest {
// TODO would be more interesting to use a Docker fixture to demonstrate that the file load is happening only from the master side
assertEquals("[stuff]", r.createOnlineSlave().getChannel().call(new LoadPrivateKeys(key)));
}
private static class LoadPrivateKeys implements Callable<String,Exception> {
private static class LoadPrivateKeys extends MasterToSlaveCallable<String,Exception> {
private final SSHUserPrivateKey key;
LoadPrivateKeys(SSHUserPrivateKey key) {
this.key = key;
Expand Down
Expand Up @@ -24,9 +24,7 @@
package com.cloudbees.jenkins.plugins.sshcredentials.impl;

import com.cloudbees.jenkins.plugins.sshcredentials.SSHAuthenticator;
import com.cloudbees.jenkins.plugins.sshcredentials.SSHUserPassword;
import com.cloudbees.plugins.credentials.CredentialsScope;
import com.cloudbees.plugins.credentials.common.StandardUsernameCredentials;
import com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials;
import com.jcraft.jsch.HostKey;
import com.jcraft.jsch.HostKeyRepository;
Expand All @@ -40,29 +38,33 @@
import org.apache.sshd.server.auth.UserAuthPassword;
import org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider;
import org.apache.sshd.server.session.ServerSession;
import org.jvnet.hudson.test.HudsonTestCase;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.jvnet.hudson.test.JenkinsRule;

import java.util.Arrays;
import java.util.Properties;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.logging.Logger;

import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;

public class JSchSSHPasswordAuthenticatorTest extends HudsonTestCase {
public class JSchSSHPasswordAuthenticatorTest {

private JSchConnector connector;
private StandardUsernamePasswordCredentials user;

@Override
protected void tearDown() throws Exception {
@Rule public JenkinsRule r = new JenkinsRule();

@After
public void tearDown() throws Exception {
if (connector != null) {
connector.close();
connector = null;
}
super.tearDown();
}

// disabled as Apache MINA sshd does not provide easy mech for giving a Keyboard Interactive authenticator
Expand All @@ -87,11 +89,12 @@ public void dontTestKeyboardInteractive() throws Exception {
assertThat(connector.getSession().isConnected(), is(true));
}

protected void setUp() throws Exception {
super.setUp();
@Before
public void setUp() throws Exception {
user =(StandardUsernamePasswordCredentials) Items.XSTREAM.fromXML(Items.XSTREAM.toXML(new BasicSSHUserPassword(CredentialsScope.SYSTEM, null, "foobar", "foomanchu", null)));
}

@Test
public void testPassword() throws Exception {
SshServer sshd = SshServer.setUpDefaultServer();
sshd.setPort(0);
Expand Down Expand Up @@ -123,6 +126,7 @@ public boolean authenticate(String username, String password, ServerSession sess
}
}

@Test
public void testFactory() throws Exception {
SshServer sshd = SshServer.setUpDefaultServer();
sshd.setPort(0);
Expand Down
Expand Up @@ -27,8 +27,6 @@
import com.cloudbees.jenkins.plugins.sshcredentials.SSHUserPrivateKey;
import com.cloudbees.plugins.credentials.CredentialsDescriptor;
import com.cloudbees.plugins.credentials.CredentialsScope;
import com.trilead.ssh2.Connection;
import com.trilead.ssh2.ServerHostKeyVerifier;
import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;
import hudson.util.Secret;
Expand All @@ -39,7 +37,11 @@
import org.apache.sshd.server.auth.UserAuthPublicKey;
import org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider;
import org.apache.sshd.server.session.ServerSession;
import org.jvnet.hudson.test.HudsonTestCase;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.jvnet.hudson.test.JenkinsRule;

import java.security.PublicKey;
import java.util.Arrays;
Expand All @@ -52,22 +54,23 @@
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;

public class JSchSSHPublicKeyAuthenticatorTest extends HudsonTestCase {
public class JSchSSHPublicKeyAuthenticatorTest {

private JSchConnector connector;
private SSHUserPrivateKey user;

@Override
protected void tearDown() throws Exception {
@Rule public JenkinsRule r = new JenkinsRule();

@After
public void tearDown() throws Exception {
if (connector != null) {
connector.close();
connector = null;
}
super.tearDown();
}

protected void setUp() throws Exception {
super.setUp();
@Before
public void setUp() throws Exception {
user = new SSHUserPrivateKey() {

@NonNull
Expand Down Expand Up @@ -132,6 +135,7 @@ public List<String> getPrivateKeys() {
};
}

@Test
public void testAuthenticate() throws Exception {
SshServer sshd = SshServer.setUpDefaultServer();
sshd.setPort(0);
Expand Down Expand Up @@ -164,6 +168,7 @@ public boolean authenticate(String username, PublicKey key, ServerSession sessio
}
}

@Test
public void testFactory() throws Exception {
SshServer sshd = SshServer.setUpDefaultServer();
sshd.setPort(0);
Expand Down

0 comments on commit 7f642fe

Please sign in to comment.