提交 f1689367 编写于 作者: J Jesse Glick

Test failure on Windows, perhaps specific to filesystem type of TemporaryFolder.

java.nio.file.FileSystemException: …\.ssh\known_hosts: Incorrect function.
        at sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:86)
        at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:90)
        at sun.nio.fs.WindowsAclFileAttributeView.getFileSecurity(WindowsAclFileAttributeView.java:88)
        at sun.nio.fs.WindowsAclFileAttributeView.getOwner(WindowsAclFileAttributeView.java:121)
        at sun.nio.fs.FileOwnerAttributeViewImpl.getOwner(FileOwnerAttributeViewImpl.java:91)
        at java.nio.file.Files.getOwner(Files.java:2079)
        at org.apache.sshd.common.util.io.IoUtils.getFileOwner(IoUtils.java:272)
        at org.apache.sshd.common.util.io.ModifiableFileWatcher.validateStrictConfigFilePermissions(ModifiableFileWatcher.java:240)
        at org.apache.sshd.client.keyverifier.DefaultKnownHostsServerKeyVerifier.reloadKnownHosts(DefaultKnownHostsServerKeyVerifier.java:79)
        at org.apache.sshd.client.keyverifier.KnownHostsServerKeyVerifier.verifyServerKey(KnownHostsServerKeyVerifier.java:161)
        at …
Interactive testing of known_hosts on XP works as expected.
上级 466d74d1
......@@ -541,7 +541,7 @@ public class CLI implements AutoCloseable {
Level level = parse(args.get(1));
ConsoleHandler h = new ConsoleHandler();
h.setLevel(level);
for (Logger logger : new Logger[] {LOGGER, PlainCLIProtocol.LOGGER}) { // perhaps also Channel
for (Logger logger : new Logger[] {LOGGER, PlainCLIProtocol.LOGGER, Logger.getLogger("org.apache.sshd")}) { // perhaps also Channel
logger.setLevel(level);
logger.addHandler(h);
}
......
......@@ -29,6 +29,8 @@ import hudson.model.User;
import hudson.util.StreamTaskListener;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import jenkins.model.Jenkins;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
......@@ -36,6 +38,7 @@ import static org.hamcrest.Matchers.containsString;
import org.jenkinsci.main.modules.cli.auth.ssh.UserPropertyImpl;
import org.jenkinsci.main.modules.sshd.SSHD;
import static org.junit.Assert.*;
import static org.junit.Assume.*;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
......@@ -57,10 +60,15 @@ public class CLITest {
File home = tmp.newFolder();
// Seems it gets created automatically but with inappropriate permissions:
File known_hosts = new File(new File(home, ".ssh"), "known_hosts");
assertTrue(known_hosts.getParentFile().mkdir());
assertTrue(known_hosts.createNewFile());
assertTrue(known_hosts.setWritable(false, false));
assertTrue(known_hosts.setWritable(true, true));
assumeTrue(known_hosts.getParentFile().mkdir());
assumeTrue(known_hosts.createNewFile());
assumeTrue(known_hosts.setWritable(false, false));
assumeTrue(known_hosts.setWritable(true, true));
try {
Files.getOwner(known_hosts.toPath());
} catch (IOException x) {
assumeNoException("Sometimes on Windows KnownHostsServerKeyVerifier.acceptIncompleteHostKeys says WARNING: Failed (FileSystemException) to reload server keys from …\\\\.ssh\\\\known_hosts: … Incorrect function.", x);
}
r.jenkins.setSecurityRealm(r.createDummySecurityRealm());
r.jenkins.setAuthorizationStrategy(new MockAuthorizationStrategy().grant(Jenkins.ADMINISTER).everywhere().to("admin"));
SSHD.get().setPort(0);
......@@ -74,7 +82,7 @@ public class CLITest {
).stdout(System.out).stderr(System.err).join());
ByteArrayOutputStream baos = new ByteArrayOutputStream();
assertEquals(0, new Launcher.LocalLauncher(StreamTaskListener.fromStderr()).launch().cmds(
"java", "-Duser.home=" + home, "-jar", jar.getAbsolutePath(), "-s", r.getURL().toString(), "-ssh", "-user", "admin", "-i", privkey.getAbsolutePath(), "who-am-i"
"java", "-Duser.home=" + home, "-jar", jar.getAbsolutePath(), "-s", r.getURL().toString(), "-ssh", "-user", "admin", "-i", privkey.getAbsolutePath(), "-logger", "FINEST", "who-am-i"
).stdout(baos).stderr(System.err).join());
assertThat(baos.toString(), containsString("Authenticated as: admin"));
baos = new ByteArrayOutputStream();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册