2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.controller.netconf;
11 import org.junit.After;
12 import org.junit.Before;
13 import org.junit.Ignore;
14 import org.junit.Test;
15 import org.mockito.Mock;
16 import org.mockito.MockitoAnnotations;
17 import org.opendaylight.controller.netconf.ssh.NetconfSSHServer;
18 import org.opendaylight.controller.netconf.ssh.authentication.AuthProvider;
19 import org.opendaylight.controller.netconf.ssh.authentication.PEMGenerator;
20 import org.opendaylight.controller.usermanager.IUserManager;
21 import org.opendaylight.controller.usermanager.UserConfig;
24 import java.io.IOException;
25 import java.net.Inet4Address;
26 import java.net.InetSocketAddress;
28 import static org.junit.Assert.assertTrue;
29 import static org.mockito.Matchers.any;
30 import static org.mockito.Mockito.doReturn;
32 // This test is intended to be verified using ssh
34 public class KeyGeneratorTest {
37 private IUserManager iUserManager;
41 public void setUp() throws IOException {
42 MockitoAnnotations.initMocks(this);
43 doReturn(null).when(iUserManager).addLocalUser(any(UserConfig.class));
44 tempFile = File.createTempFile("odltest", ".tmp");
45 tempFile.deleteOnExit();
49 public void tearDown() {
50 assertTrue(tempFile.delete());
54 public void test() throws Exception {
55 String pem = PEMGenerator.generateTo(tempFile);
57 AuthProvider authProvider = new AuthProvider(iUserManager, pem);
58 InetSocketAddress inetSocketAddress = new InetSocketAddress(Inet4Address.getLoopbackAddress().getHostAddress(), 8383);
59 NetconfSSHServer server = NetconfSSHServer.start(1830, inetSocketAddress, authProvider);
61 Thread serverThread = new Thread(server,"netconf SSH server thread");