You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by lg...@apache.org on 2015/06/30 07:55:21 UTC
mina-sshd git commit: [SSHD-479] Upgrade used Maven artifacts
versions to more recent versions
Repository: mina-sshd
Updated Branches:
refs/heads/master 4b478c906 -> 78d703fd4
[SSHD-479] Upgrade used Maven artifacts versions to more recent versions
* Updated ganymed-ssh2 version build210 => 206
Project: http://git-wip-us.apache.org/repos/asf/mina-sshd/repo
Commit: http://git-wip-us.apache.org/repos/asf/mina-sshd/commit/78d703fd
Tree: http://git-wip-us.apache.org/repos/asf/mina-sshd/tree/78d703fd
Diff: http://git-wip-us.apache.org/repos/asf/mina-sshd/diff/78d703fd
Branch: refs/heads/master
Commit: 78d703fd41bed6e839f71647b0fd871d241ef97a
Parents: 4b478c9
Author: Lyor Goldstein <lg...@vmware.com>
Authored: Tue Jun 30 08:55:05 2015 +0300
Committer: Lyor Goldstein <lg...@vmware.com>
Committed: Tue Jun 30 08:55:05 2015 +0300
----------------------------------------------------------------------
pom.xml | 2 +-
.../sshd/server/channel/ChannelSession.java | 6 +-
.../org/apache/sshd/PortForwardingTest.java | 6 +-
.../org/apache/sshd/client/scp/ScpTest.java | 80 +++++++++++---------
.../test/java/org/apache/sshd/util/Utils.java | 6 +-
5 files changed, 56 insertions(+), 44 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/78d703fd/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 7b1d53f..c310ec4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -300,7 +300,7 @@
<dependency>
<groupId>ch.ethz.ganymed</groupId>
<artifactId>ganymed-ssh2</artifactId>
- <version>build210</version>
+ <version>262</version>
</dependency>
<dependency>
<groupId>org.eclipse.jgit</groupId>
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/78d703fd/sshd-core/src/main/java/org/apache/sshd/server/channel/ChannelSession.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/channel/ChannelSession.java b/sshd-core/src/main/java/org/apache/sshd/server/channel/ChannelSession.java
index 7edc72e..d68be79 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/channel/ChannelSession.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/channel/ChannelSession.java
@@ -493,13 +493,13 @@ public class ChannelSession extends AbstractServerChannel {
log.warn("No command factory for command: {}", commandLine);
return false;
}
- if (log.isInfoEnabled()) {
- log.info("Executing command: {}", commandLine);
+ if (log.isDebugEnabled()) {
+ log.debug("Executing command: {}", commandLine);
}
try {
command = factory.createCommand(commandLine);
} catch (RuntimeException iae) {
- log.warn("Failed (" + iae.getClass().getSimpleName() + ") to execute " + commandLine + ": " + iae.getMessage());
+ log.warn("Failed (" + iae.getClass().getSimpleName() + ") to create command for " + commandLine + ": " + iae.getMessage());
return false;
}
prepareCommand();
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/78d703fd/sshd-core/src/test/java/org/apache/sshd/PortForwardingTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/PortForwardingTest.java b/sshd-core/src/test/java/org/apache/sshd/PortForwardingTest.java
index c56fd40..0bbb489 100644
--- a/sshd-core/src/test/java/org/apache/sshd/PortForwardingTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/PortForwardingTest.java
@@ -153,11 +153,11 @@ public class PortForwardingTest extends BaseTestSupport {
try {
int forwardedPort = getFreePort();
session.setPortForwardingR(forwardedPort, "localhost", echoPort);
- Thread.sleep(150L);
+ Thread.sleep(155L);
session.delPortForwardingR("localhost", forwardedPort);
- Thread.sleep(150L);
+ Thread.sleep(155L);
session.setPortForwardingR(forwardedPort, "localhost", echoPort);
- Thread.sleep(150L);
+ Thread.sleep(155L);
try(Socket s = new Socket("localhost", forwardedPort);
OutputStream output = s.getOutputStream();
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/78d703fd/sshd-core/src/test/java/org/apache/sshd/client/scp/ScpTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/client/scp/ScpTest.java b/sshd-core/src/test/java/org/apache/sshd/client/scp/ScpTest.java
index a1ccb43..00f3d27 100644
--- a/sshd-core/src/test/java/org/apache/sshd/client/scp/ScpTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/client/scp/ScpTest.java
@@ -24,15 +24,16 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.channels.FileChannel;
+import java.nio.charset.StandardCharsets;
import java.nio.file.FileSystem;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
import java.nio.file.attribute.PosixFilePermission;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.EnumSet;
-import java.util.Properties;
import java.util.Set;
import java.util.concurrent.TimeUnit;
@@ -61,13 +62,14 @@ import org.junit.runners.MethodSorters;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import ch.ethz.ssh2.Connection;
-import ch.ethz.ssh2.SCPClient;
-
import com.jcraft.jsch.ChannelExec;
import com.jcraft.jsch.JSch;
import com.jcraft.jsch.JSchException;
+import ch.ethz.ssh2.Connection;
+import ch.ethz.ssh2.ConnectionInfo;
+import ch.ethz.ssh2.SCPClient;
+
/**
* Test for SCP support.
*
@@ -711,45 +713,53 @@ public class ScpTest extends BaseTestSupport {
@Test
public void testWithGanymede() throws Exception {
- // begin client config
+ Path targetPath = detectTargetFolder().toPath();
+ Path parentPath = targetPath.getParent();
+ Path scpRoot = Utils.resolve(targetPath, ScpHelper.SCP_COMMAND_PREFIX, getClass().getSimpleName(), getCurrentTestName());
+ Utils.deleteRecursive(scpRoot);
+
+ byte[] expected = (getClass().getName() + "#" + getCurrentTestName()).getBytes(StandardCharsets.UTF_8);
+ Path remoteDir = assertHierarchyTargetFolderExists(scpRoot.resolve("remote"));
+ String remotePath = Utils.resolveRelativeRemotePath(parentPath, remoteDir);
+ String fileName = getCurrentTestName() + ".txt";
+ Path remoteFile = remoteDir.resolve(fileName);
+ String mode = ScpHelper.getOctalPerms(EnumSet.of(
+ PosixFilePermission.OTHERS_READ, PosixFilePermission.OTHERS_WRITE,
+ PosixFilePermission.GROUP_READ, PosixFilePermission.GROUP_WRITE,
+ PosixFilePermission.OWNER_READ, PosixFilePermission.OWNER_WRITE
+ ));
+
final Connection conn = new Connection("localhost", port);
try {
- conn.connect(null, 5000, 0);
- conn.authenticateWithPassword("sshd", "sshd");
+ ConnectionInfo info = conn.connect(null, (int) TimeUnit.SECONDS.toMillis(5L), (int) TimeUnit.SECONDS.toMillis(11L));
+ System.out.println("Connected: kex=" + info.keyExchangeAlgorithm + ", key-type=" + info.serverHostKeyAlgorithm
+ + ", c2senc=" + info.clientToServerCryptoAlgorithm + ", s2cenc=" + info.serverToClientCryptoAlgorithm
+ + ", c2mac=" + info.clientToServerMACAlgorithm + ", s2cmac=" + info.serverToClientMACAlgorithm);
+ conn.authenticateWithPassword(getCurrentTestName(), getCurrentTestName());
+
final SCPClient scp_client = new SCPClient(conn);
- final Properties props = new Properties();
- props.setProperty("test", "test-passed");
- File f = new File("target/scp/gan");
- Utils.deleteRecursive(f);
- f.mkdirs();
- assertTrue(f.exists());
-
- String name = "test.properties";
- scp_client.put(toBytes(props, ""), name, "target/scp/gan");
- assertTrue(new File(f, name).exists());
- assertTrue(new File(f, name).delete());
-
- name = "test2.properties";
- scp_client.put(toBytes(props, ""), name, "target/scp/gan");
- assertTrue(new File(f, name).exists());
- assertTrue(new File(f, name).delete());
-
- assertTrue(f.delete());
+ try(OutputStream output = scp_client.put(fileName, expected.length, remotePath, mode)) {
+ output.write(expected);
+ }
+
+ assertTrue("Remote file not created: " + remoteFile, Files.exists(remoteFile));
+ byte[] remoteData = Files.readAllBytes(remoteFile);
+ assertArrayEquals("Mismatched remote put data", expected, remoteData);
+
+ Arrays.fill(remoteData, (byte) 0); // make sure we start with a clean slate
+ try(InputStream input = scp_client.get(remotePath + "/" + fileName)) {
+ int readLen = input.read(remoteData);
+ assertEquals("Mismatched remote get data size", expected.length, readLen);
+ // make sure we reached EOF
+ assertEquals("Unexpected extra data after read expected size", (-1), input.read());
+ }
+
+ assertArrayEquals("Mismatched remote get data", expected, remoteData);
} finally {
conn.close();
}
}
- private byte[] toBytes(final Properties properties, final String comments) {
- try(ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
- properties.store(baos, comments);
- baos.close();
- return baos.toByteArray();
- } catch(IOException cause) {
- throw new RuntimeException("Failed to output properties to byte[]", cause);
- }
- }
-
protected String readFile(String path, long expectedSize) throws Exception {
ChannelExec c = (ChannelExec) session.openChannel("exec");
c.setCommand("scp -f " + path);
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/78d703fd/sshd-core/src/test/java/org/apache/sshd/util/Utils.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/util/Utils.java b/sshd-core/src/test/java/org/apache/sshd/util/Utils.java
index 6c91836..99cd121 100644
--- a/sshd-core/src/test/java/org/apache/sshd/util/Utils.java
+++ b/sshd-core/src/test/java/org/apache/sshd/util/Utils.java
@@ -29,6 +29,7 @@ import java.net.URISyntaxException;
import java.net.URL;
import java.nio.file.DirectoryStream;
import java.nio.file.Files;
+import java.nio.file.LinkOption;
import java.nio.file.Path;
import java.security.CodeSource;
import java.security.KeyPair;
@@ -190,10 +191,11 @@ public class Utils {
* are deleted recursively and then the directory itself.
* @param path The file {@link Path} to be deleted - ignored if {@code null}
* or does not exist anymore
+ * @param options The {@link LinkOption}s to use
* @return The <tt>path</tt> argument
* @throws IOException If failed to access/remove some file(s)
*/
- public static Path deleteRecursive(Path path) throws IOException {
+ public static Path deleteRecursive(Path path, LinkOption ... options) throws IOException {
if ((path == null) || (!Files.exists(path))) {
return path;
}
@@ -201,7 +203,7 @@ public class Utils {
if (Files.isDirectory(path)) {
try(DirectoryStream<Path> ds = Files.newDirectoryStream(path)) {
for (Path child : ds) {
- deleteRecursive(child);
+ deleteRecursive(child, options);
}
}
}