+
+ 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 {
+ AuthProvider mock = mock(AuthProvider.class);
+ doReturn(true).when(mock).authenticated(anyString(), anyString());
+ doReturn(PEMGenerator.generate().toCharArray()).when(mock).getPEMAsCharArray();
+ return mock;
+ }
+
+ 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;
+ }