+
+ public NetconfClientConfiguration getClientConfiguration() throws IOException {
+ final NetconfClientConfigurationBuilder b = NetconfClientConfigurationBuilder.create();
+ b.withAddress(tlsAddress);
+ b.withSessionListener(new SimpleNetconfClientSessionListener());
+ b.withReconnectStrategy(new NeverReconnectStrategy(GlobalEventExecutor.INSTANCE, 5000));
+ b.withProtocol(NetconfClientConfiguration.NetconfClientProtocol.SSH);
+ b.withConnectionTimeoutMillis(5000);
+ b.withAuthHandler(getAuthHandler());
+ return b.build();
+ }
+
+ public AuthProvider getAuthProvider() throws Exception {
+ final IUserManager userManager = mock(IUserManager.class);
+ doReturn(AuthResultEnum.AUTH_ACCEPT).when(userManager).authenticate(anyString(), anyString());
+
+ final File privateKeyFile = Files.createTempFile("tmp-netconf-test", "pk").toFile();
+ privateKeyFile.deleteOnExit();
+ String privateKeyPEMString = PEMGenerator.generateTo(privateKeyFile);
+ return new AuthProvider(userManager, privateKeyPEMString);
+ }
+
+ public AuthenticationHandler getAuthHandler() throws IOException {
+ final AuthenticationHandler authHandler = mock(AuthenticationHandler.class);
+ doAnswer(new Answer() {
+ @Override
+ public Object answer(final InvocationOnMock invocation) throws Throwable {
+ Connection conn = (Connection) invocation.getArguments()[0];
+ conn.authenticateWithPassword("user", "pwd");
+ return null;
+ }
+ }).when(authHandler).authenticate(any(Connection.class));
+ doReturn("auth handler").when(authHandler).toString();
+ return authHandler;
+ }