@Test public void testSyncAuthFailed() throws Exception { startServer(); authenticator = new PasswordAuthenticator() { @Override public boolean authenticate(String username, String password, ServerSession session) throws PasswordChangeRequiredException { return false; } }; assertFalse(authenticate()); }
@Test public void testSyncAuthSucceeded() throws Exception { startServer(); authenticator = new PasswordAuthenticator() { @Override public boolean authenticate(String username, String password, ServerSession session) throws PasswordChangeRequiredException { return true; } }; assertTrue(authenticate()); }
@Test public void testSyncAuthSucceeded() throws Exception { startServer(); authenticator = (username, password, sess) -> true; assertTrue(authenticate()); }
@Test public void testSyncAuthFailed() throws Exception { startServer(); authenticator = (username, password, sess) -> false; assertFalse(authenticate()); }
@Test public void testSyncAuthSucceeded() throws Exception { startServer(); authenticator = (username, password, sess) -> true; assertTrue(authenticate()); }
@Test public void testSyncAuthFailed() throws Exception { startServer(); authenticator = (username, password, sess) -> false; assertFalse(authenticate()); }
@Test public void testAsyncAuthFailed() throws Exception { startServer(); authenticator = new PasswordAuthenticator() { @Override public boolean authenticate(String username, String password, ServerSession session) throws PasswordChangeRequiredException { final AsyncAuth auth = new AsyncAuth(); new Thread() { @Override public void run() { try { Thread.sleep(200); } catch (InterruptedException ignore) { } finally { auth.setAuthed(false); } } }.start(); throw auth; } }; assertFalse(authenticate()); }
@Test public void testAsyncAuthTimeout() throws Exception { startServer(500); authenticator = new PasswordAuthenticator() { @Override public boolean authenticate(String username, String password, ServerSession session) throws PasswordChangeRequiredException { throw new AsyncAuth(); } }; try { authenticate(); } catch (JSchException e) { assertTrue("Unexpected failure " + e.getMessage(), e.getMessage().startsWith("SSH_MSG_DISCONNECT")); } }
@Test public void testAsyncAuthSucceeded() throws Exception { startServer(); authenticator = new PasswordAuthenticator() { @Override public boolean authenticate(String username, String password, ServerSession session) throws PasswordChangeRequiredException { final AsyncAuth auth = new AsyncAuth(); new Thread() { @Override public void run() { try { Thread.sleep(200); } catch (InterruptedException ignore) { } finally { auth.setAuthed(true); } } }.start(); throw auth; } }; assertTrue(authenticate()); }
@Test public void testAsyncAuthTimeout() throws Exception { startServer(500); authenticator = (username, password, sess) -> { throw new AsyncAuth(); }; try { authenticate(); } catch (JSchException e) { assertTrue("Unexpected failure " + e.getMessage(), e.getMessage().startsWith("SSH_MSG_DISCONNECT")); } }
@Test public void testAsyncAuthTimeout() throws Exception { startServer(500); authenticator = (username, password, sess) -> { throw new AsyncAuth(); }; try { authenticate(); } catch (JSchException e) { assertTrue("Unexpected failure " + e.getMessage(), e.getMessage().startsWith("SSH_MSG_DISCONNECT")); } }
@Test public void testAsyncAuthSucceededAfterTimeout() throws Exception { startServer(500); authenticator = new PasswordAuthenticator() { @Override public boolean authenticate(String username, String password, ServerSession session) throws PasswordChangeRequiredException { final AsyncAuth auth = new AsyncAuth(); new Thread() { @Override public void run() { try { Thread.sleep(1000); } catch (InterruptedException ignore) { } finally { auth.setAuthed(true); } } }.start(); throw auth; } }; try { authenticate(); } catch (JSchException e) { assertTrue("Unexpected failure " + e.getMessage(), e.getMessage().startsWith("SSH_MSG_DISCONNECT")); } }
@Test public void testAsyncAuthSucceeded() throws Exception { startServer(); authenticator = (username, password, sess) -> { AsyncAuth auth = new AsyncAuth(); new Thread() { @Override public void run() { try { Thread.sleep(200); } catch (InterruptedException ignore) { } finally { auth.setAuthed(true); } } }.start(); throw auth; }; assertTrue(authenticate()); }
@Test public void testAsyncAuthSucceeded() throws Exception { startServer(); authenticator = (username, password, sess) -> { AsyncAuth auth = new AsyncAuth(); new Thread() { @Override public void run() { try { Thread.sleep(200); } catch (InterruptedException ignore) { } finally { auth.setAuthed(true); } } }.start(); throw auth; }; assertTrue(authenticate()); }
@Test public void testAsyncAuthFailed() throws Exception { startServer(); authenticator = (username, password, sess) -> { AsyncAuth auth = new AsyncAuth(); new Thread() { @Override public void run() { try { Thread.sleep(200); } catch (InterruptedException ignore) { } finally { auth.setAuthed(false); } } }.start(); throw auth; }; assertFalse(authenticate()); }
@Test public void testAsyncAuthFailed() throws Exception { startServer(); authenticator = (username, password, sess) -> { AsyncAuth auth = new AsyncAuth(); new Thread() { @Override public void run() { try { Thread.sleep(200); } catch (InterruptedException ignore) { } finally { auth.setAuthed(false); } } }.start(); throw auth; }; assertFalse(authenticate()); }
@Test public void testAsyncAuthSucceededAfterTimeout() throws Exception { startServer(500); authenticator = (username, password, sess) -> { AsyncAuth auth = new AsyncAuth(); new Thread() { @Override public void run() { try { Thread.sleep(1000); } catch (InterruptedException ignore) { } finally { auth.setAuthed(true); } } }.start(); throw auth; }; try { authenticate(); } catch (JSchException e) { assertTrue("Unexpected failure " + e.getMessage(), e.getMessage().startsWith("SSH_MSG_DISCONNECT")); } }
@Test public void testAsyncAuthSucceededAfterTimeout() throws Exception { startServer(500); authenticator = (username, password, sess) -> { AsyncAuth auth = new AsyncAuth(); new Thread() { @Override public void run() { try { Thread.sleep(1000); } catch (InterruptedException ignore) { } finally { auth.setAuthed(true); } } }.start(); throw auth; }; try { authenticate(); } catch (JSchException e) { assertTrue("Unexpected failure " + e.getMessage(), e.getMessage().startsWith("SSH_MSG_DISCONNECT")); } }