Skip to content

Commit cd1cfaf

Browse files
committed
Extract method "createSessionWithCredentials"
This is a preparatory refactoring for a new feature that supports authentication with user defined credentials.
1 parent 7b5bd1c commit cd1cfaf

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/test/java/com/github/stefanbirkner/fakesftpserver/rule/FakeSftpServerRuleTest.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -895,10 +895,9 @@ private static Session connectToServer(
895895
private static Session connectToServerAtPort(
896896
int port
897897
) throws JSchException {
898-
Session session = JSCH.getSession(
899-
"dummy user", "127.0.0.1", port);
900-
session.setConfig("StrictHostKeyChecking", "no");
901-
session.setPassword("dummy password");
898+
Session session = createSessionWithCredentials(
899+
"dummy user", "dummy password", port
900+
);
902901
session.connect(TIMEOUT);
903902
return session;
904903
}
@@ -920,6 +919,17 @@ private static void connectAndDisconnect(
920919
session.disconnect();
921920
}
922921

922+
private static Session createSessionWithCredentials(
923+
String username,
924+
String password,
925+
int port
926+
) throws JSchException {
927+
Session session = JSCH.getSession(username, "127.0.0.1", port);
928+
session.setConfig("StrictHostKeyChecking", "no");
929+
session.setPassword(password);
930+
return session;
931+
}
932+
923933
private static byte[] downloadFile(
924934
FakeSftpServerRule server,
925935
String path

0 commit comments

Comments
 (0)