24
24
import java .security .KeyPair ;
25
25
import java .security .KeyPairGenerator ;
26
26
import java .security .PublicKey ;
27
+ import java .util .EnumSet ;
27
28
import java .util .concurrent .atomic .AtomicBoolean ;
28
29
29
- import org .apache .sshd .client .ServerKeyVerifier ;
30
30
import org .apache .sshd .client .SshClient ;
31
31
import org .apache .sshd .client .channel .ClientChannel ;
32
+ import org .apache .sshd .client .future .AuthFuture ;
33
+ import org .apache .sshd .client .keyverifier .ServerKeyVerifier ;
32
34
import org .apache .sshd .client .session .ClientSession ;
33
35
import org .apache .sshd .common .util .SecurityUtils ;
34
36
import org .junit .After ;
@@ -112,9 +114,11 @@ protected String testSshCommand(String cmd) throws IOException, InterruptedExcep
112
114
113
115
protected String testSshCommand (String cmd , String stdin ) throws IOException , InterruptedException {
114
116
SshClient client = getClient ();
115
- ClientSession session = client .connect (username , "localhost" , GitBlitSuite .sshPort ).await ().getSession ();
117
+ ClientSession session = client .connect (username , "localhost" , GitBlitSuite .sshPort ).verify ().getSession ();
116
118
session .addPublicKeyIdentity (rwKeyPair );
117
- assertTrue (session .auth ().await ().isSuccess ());
119
+ AuthFuture authFuture = session .auth ();
120
+ assertTrue (authFuture .await ());
121
+ assertTrue (authFuture .isSuccess ());
118
122
119
123
ClientChannel channel = session .createChannel (ClientChannel .CHANNEL_EXEC , cmd );
120
124
ByteArrayOutputStream baos = new ByteArrayOutputStream ();
@@ -131,7 +135,7 @@ protected String testSshCommand(String cmd, String stdin) throws IOException, In
131
135
channel .setErr (err );
132
136
channel .open ();
133
137
134
- channel .waitFor (ClientChannel .CLOSED , 0 );
138
+ channel .waitFor (EnumSet . of ( ClientChannel .ClientChannelEvent . CLOSED ) , 0 );
135
139
136
140
String result = out .toString ().trim ();
137
141
channel .close (false );
0 commit comments