X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fnetconf%2Fnetconf-it%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Fit%2FNetconfITSecureTest.java;h=fdc9a020065be13d5de4268abcfe65c35117a206;hb=ee0877c07ff700157dd9fc2e445df095c88f79bc;hp=f96f55761939bdd5e7eb05eca5a6b8b645572208;hpb=139937c2e646894af6a9b2b8a8a1047c6ef82485;p=controller.git diff --git a/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/NetconfITSecureTest.java b/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/NetconfITSecureTest.java index f96f557619..fdc9a02006 100644 --- a/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/NetconfITSecureTest.java +++ b/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/NetconfITSecureTest.java @@ -25,6 +25,7 @@ import io.netty.channel.EventLoopGroup; import io.netty.channel.local.LocalAddress; import io.netty.channel.nio.NioEventLoopGroup; import io.netty.util.concurrent.GlobalEventExecutor; +import java.io.File; import java.io.IOException; import java.net.InetSocketAddress; import java.nio.file.Files; @@ -55,6 +56,7 @@ import org.opendaylight.controller.netconf.client.conf.NetconfClientConfiguratio import org.opendaylight.controller.netconf.nettyutil.handler.ssh.authentication.AuthenticationHandler; import org.opendaylight.controller.netconf.nettyutil.handler.ssh.authentication.LoginPassword; import org.opendaylight.controller.netconf.ssh.SshProxyServer; +import org.opendaylight.controller.netconf.ssh.SshProxyServerConfigurationBuilder; import org.opendaylight.controller.netconf.util.messages.NetconfMessageUtil; import org.opendaylight.controller.netconf.util.osgi.NetconfConfigUtil; import org.opendaylight.controller.netconf.util.xml.XmlUtil; @@ -76,6 +78,7 @@ public class NetconfITSecureTest extends AbstractNetconfConfigTest { public static final String USERNAME = "user"; public static final String PASSWORD = "pwd"; + private File sshKeyPair; private SshProxyServer sshProxyServer; private ExecutorService nioExec; @@ -84,16 +87,25 @@ public class NetconfITSecureTest extends AbstractNetconfConfigTest { @Before public void setUp() throws Exception { + sshKeyPair = Files.createTempFile("sshKeyPair", ".pem").toFile(); + sshKeyPair.deleteOnExit(); nioExec = Executors.newFixedThreadPool(1); clientGroup = new NioEventLoopGroup(); minaTimerEx = Executors.newScheduledThreadPool(1); sshProxyServer = new SshProxyServer(minaTimerEx, clientGroup, nioExec); - sshProxyServer.bind(TLS_ADDRESS, NetconfConfigUtil.getNetconfLocalAddress(), new PasswordAuthenticator() { + sshProxyServer.bind( + new SshProxyServerConfigurationBuilder() + .setBindingAddress(TLS_ADDRESS) + .setLocalAddress(NetconfConfigUtil.getNetconfLocalAddress()) + .setAuthenticator(new PasswordAuthenticator() { @Override public boolean authenticate(final String username, final String password, final ServerSession session) { return true; } - }, new PEMGeneratorHostKeyProvider(Files.createTempFile("prefix", "suffix").toAbsolutePath().toString())); + }) + .setKeyPairProvider(new PEMGeneratorHostKeyProvider(sshKeyPair.toPath().toAbsolutePath().toString())) + .setIdleTimeout(Integer.MAX_VALUE) + .createSshProxyServerConfiguration()); } @After