5
5
import static org .hamcrest .Matchers .hasItem ;
6
6
import static org .hamcrest .Matchers .is ;
7
7
import static org .hamcrest .io .FileMatchers .anExistingFile ;
8
+ import static org .jenkinsci .plugins .gitclient .verifier .KnownHostsTestUtil .runKnownHostsTests ;
8
9
import static org .mockito .Mockito .spy ;
9
10
import static org .mockito .Mockito .when ;
10
11
17
18
import java .util .Collections ;
18
19
import java .util .List ;
19
20
import org .awaitility .Awaitility ;
21
+ import org .junit .Assume ;
20
22
import org .junit .Ignore ;
21
23
import org .junit .Rule ;
22
24
import org .junit .Test ;
@@ -46,13 +48,15 @@ public class AcceptFirstConnectionVerifierTest {
46
48
47
49
@ Test
48
50
public void testVerifyHostKeyOption () throws IOException {
51
+ Assume .assumeTrue (runKnownHostsTests ());
49
52
assertThat (
50
53
new AcceptFirstConnectionVerifier ().forCliGit (TaskListener .NULL ).getVerifyHostKeyOption (null ),
51
54
is ("-o StrictHostKeyChecking=accept-new -o HashKnownHosts=yes" ));
52
55
}
53
56
54
57
@ Test
55
58
public void testVerifyServerHostKeyWhenFirstConnection () throws Exception {
59
+ Assume .assumeTrue (runKnownHostsTests ());
56
60
File file = new File (testFolder .getRoot () + "path/to/file" );
57
61
AcceptFirstConnectionVerifier acceptFirstConnectionVerifier = spy (new AcceptFirstConnectionVerifier ());
58
62
when (acceptFirstConnectionVerifier .getKnownHostsFile ()).thenReturn (file );
@@ -77,6 +81,7 @@ public void testVerifyServerHostKeyWhenFirstConnection() throws Exception {
77
81
78
82
@ Test
79
83
public void testVerifyServerHostKeyWhenSecondConnectionWithEqualKeys () throws Exception {
84
+ Assume .assumeTrue (runKnownHostsTests ());
80
85
String hostKeyEntry =
81
86
"|1|FJGXVAi7jMQIsl1J6uE6KnCiteM=|xlH92KQ91GuBgRxvRbU/sBo60Bo= ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBEmKSENjQEezOmxkZMy7opKgwFB9nkt5YRrYMjNuG5N87uRgg6CLrbo5wAdT/y6v0mKV0U2w0WZ2YB/++Tpockg=" ;
82
87
@@ -105,6 +110,7 @@ public void testVerifyServerHostKeyWhenSecondConnectionWithEqualKeys() throws Ex
105
110
106
111
@ Test
107
112
public void testVerifyServerHostKeyWhenHostnameWithoutPort () throws Exception {
113
+ Assume .assumeTrue (runKnownHostsTests ());
108
114
String hostKeyEntry =
109
115
"github.com ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBEmKSENjQEezOmxkZMy7opKgwFB9nkt5YRrYMjNuG5N87uRgg6CLrbo5wAdT/y6v0mKV0U2w0WZ2YB/++Tpockg=" ;
110
116
File mockedKnownHosts = knownHostsTestUtil .createFakeKnownHosts (hostKeyEntry );
@@ -128,6 +134,7 @@ public void testVerifyServerHostKeyWhenHostnameWithoutPort() throws Exception {
128
134
129
135
@ Test
130
136
public void testVerifyServerHostKeyWhenSecondConnectionWhenNotDefaultAlgorithm () throws Exception {
137
+ Assume .assumeTrue (runKnownHostsTests ());
131
138
String fileContent =
132
139
"""
133
140
github.com,140.82.121.4\
@@ -158,6 +165,7 @@ public void testVerifyServerHostKeyWhenSecondConnectionWhenNotDefaultAlgorithm()
158
165
@ Test
159
166
@ Ignore ("FIXME not sure what is the test here" )
160
167
public void testVerifyServerHostKeyWhenSecondConnectionWithNonEqualKeys () throws Exception {
168
+ Assume .assumeTrue (runKnownHostsTests ());
161
169
String fileContent =
162
170
"""
163
171
|1|f7esvmtaiBk+EMHjPzWbRYRpBPY=|T7Qe4QAksYPZPwYEx5QxQykSjfc=\
@@ -188,6 +196,7 @@ public void testVerifyServerHostKeyWhenSecondConnectionWithNonEqualKeys() throws
188
196
189
197
@ Test
190
198
public void testVerifyServerHostKeyWhenConnectionWithAnotherHost () throws Exception {
199
+ Assume .assumeTrue (runKnownHostsTests ());
191
200
String bitbucketFileContent =
192
201
"""
193
202
|1|HnmPCP38pBhCY0NUtBXSraOg9pM=|L6YZ9asEeb2xplTDEThGOxRq7ZY=\
@@ -220,6 +229,7 @@ public void testVerifyServerHostKeyWhenConnectionWithAnotherHost() throws Except
220
229
221
230
@ Test
222
231
public void testVerifyServerHostKeyWhenHostnamePortProvided () throws Exception {
232
+ Assume .assumeTrue (runKnownHostsTests ());
223
233
String fileContent =
224
234
"""
225
235
|1|6uMj3M7sLgZpn54vQbGqgPNTCVM=|OkV9Lu9REJZR5QCVrITAIY34I1M=\
0 commit comments