1 | package com.github.dakusui.actionunit.actions.cmd.unix; | |
2 | ||
3 | import java.util.*; | |
4 | ||
5 | import static java.util.Collections.unmodifiableList; | |
6 | import static java.util.Objects.requireNonNull; | |
7 | ||
8 | /** | |
9 | * Models options common to both {@code ssh} and {@code scp} commands. (see below). | |
10 | * ---- | |
11 | * -4 : IPv4 | |
12 | * -6 : IPv6 | |
13 | * -C : compression | |
14 | * -c : cipher spec | |
15 | * -F : config file | |
16 | * -i : identity | |
17 | * -o : ssh option | |
18 | * -p (-P for scp) : port | |
19 | * -q : quiet | |
20 | * -v : verbose | |
21 | * ---- | |
22 | */ | |
23 | public interface SshOptions { | |
24 | static SshOptions emptySshOptions() { | |
25 |
1
1. emptySshOptions : replaced return value with null for com/github/dakusui/actionunit/actions/cmd/unix/SshOptions::emptySshOptions → SURVIVED |
return new Builder().build(); |
26 | } | |
27 | ||
28 | boolean authAgentConnectionForwardingEnabled(); | |
29 | ||
30 | boolean ipv4(); | |
31 | ||
32 | boolean ipv6(); | |
33 | ||
34 | boolean compression(); | |
35 | ||
36 | List<String> jumpHosts(); | |
37 | ||
38 | Optional<String> cipherSpec(); | |
39 | ||
40 | Optional<String> configFile(); | |
41 | ||
42 | Optional<String> identity(); | |
43 | ||
44 | List<String> options(); | |
45 | ||
46 | OptionalInt port(); | |
47 | ||
48 | boolean quiet(); | |
49 | ||
50 | boolean verbose(); | |
51 | ||
52 | default List<String> formatOptionsWith(Formatter formatter) { | |
53 |
1
1. formatOptionsWith : replaced return value with Collections.emptyList for com/github/dakusui/actionunit/actions/cmd/unix/SshOptions::formatOptionsWith → KILLED |
return requireNonNull(formatter).format(this); |
54 | } | |
55 | ||
56 | class Impl implements SshOptions { | |
57 | final boolean ipv4; | |
58 | final boolean ipv6; | |
59 | final boolean compression; | |
60 | final List<String> jumpHosts; | |
61 | final String cipherSpec; | |
62 | final String configFile; | |
63 | final String identity; | |
64 | final List<String> sshOptions; | |
65 | final Integer port; | |
66 | final boolean quiet; | |
67 | final boolean verbose; | |
68 | final boolean authAgentConnectionForwarding; | |
69 | ||
70 | public Impl(boolean authAgentConnectionForwardingEnabled, boolean ipv4, boolean ipv6, boolean compression, List<String> jumpHosts, String cipherSpec, String configFile, String identity, List<String> sshOptions, Integer port, boolean quiet, boolean verbose) { | |
71 | this.authAgentConnectionForwarding = authAgentConnectionForwardingEnabled; | |
72 | this.ipv4 = ipv4; | |
73 | this.ipv6 = ipv6; | |
74 | this.compression = compression; | |
75 | this.jumpHosts = unmodifiableList(new ArrayList<>(requireNonNull(jumpHosts))); | |
76 | this.cipherSpec = cipherSpec; | |
77 | this.configFile = configFile; | |
78 | this.identity = identity; | |
79 | this.sshOptions = unmodifiableList(new ArrayList<>(requireNonNull(sshOptions))); | |
80 | this.port = port; | |
81 | this.quiet = quiet; | |
82 | this.verbose = verbose; | |
83 | } | |
84 | ||
85 | ||
86 | @Override | |
87 | public boolean authAgentConnectionForwardingEnabled() { | |
88 |
2
1. authAgentConnectionForwardingEnabled : replaced boolean return with false for com/github/dakusui/actionunit/actions/cmd/unix/SshOptions$Impl::authAgentConnectionForwardingEnabled → KILLED 2. authAgentConnectionForwardingEnabled : replaced boolean return with true for com/github/dakusui/actionunit/actions/cmd/unix/SshOptions$Impl::authAgentConnectionForwardingEnabled → KILLED |
return authAgentConnectionForwarding; |
89 | } | |
90 | ||
91 | @Override | |
92 | public boolean ipv4() { | |
93 |
2
1. ipv4 : replaced boolean return with false for com/github/dakusui/actionunit/actions/cmd/unix/SshOptions$Impl::ipv4 → KILLED 2. ipv4 : replaced boolean return with true for com/github/dakusui/actionunit/actions/cmd/unix/SshOptions$Impl::ipv4 → KILLED |
return ipv4; |
94 | } | |
95 | ||
96 | @Override | |
97 | public boolean ipv6() { | |
98 |
2
1. ipv6 : replaced boolean return with false for com/github/dakusui/actionunit/actions/cmd/unix/SshOptions$Impl::ipv6 → KILLED 2. ipv6 : replaced boolean return with true for com/github/dakusui/actionunit/actions/cmd/unix/SshOptions$Impl::ipv6 → KILLED |
return ipv6; |
99 | } | |
100 | ||
101 | @Override | |
102 | public boolean compression() { | |
103 |
2
1. compression : replaced boolean return with false for com/github/dakusui/actionunit/actions/cmd/unix/SshOptions$Impl::compression → KILLED 2. compression : replaced boolean return with true for com/github/dakusui/actionunit/actions/cmd/unix/SshOptions$Impl::compression → KILLED |
return compression; |
104 | } | |
105 | ||
106 | @Override | |
107 | public List<String> jumpHosts() { | |
108 |
1
1. jumpHosts : replaced return value with Collections.emptyList for com/github/dakusui/actionunit/actions/cmd/unix/SshOptions$Impl::jumpHosts → KILLED |
return jumpHosts; |
109 | } | |
110 | ||
111 | @Override | |
112 | public Optional<String> cipherSpec() { | |
113 |
1
1. cipherSpec : replaced return value with Optional.empty for com/github/dakusui/actionunit/actions/cmd/unix/SshOptions$Impl::cipherSpec → KILLED |
return Optional.ofNullable(cipherSpec); |
114 | } | |
115 | ||
116 | @Override | |
117 | public Optional<String> configFile() { | |
118 |
1
1. configFile : replaced return value with Optional.empty for com/github/dakusui/actionunit/actions/cmd/unix/SshOptions$Impl::configFile → KILLED |
return Optional.ofNullable(configFile); |
119 | } | |
120 | ||
121 | @Override | |
122 | public Optional<String> identity() { | |
123 |
1
1. identity : replaced return value with Optional.empty for com/github/dakusui/actionunit/actions/cmd/unix/SshOptions$Impl::identity → KILLED |
return Optional.ofNullable(identity); |
124 | } | |
125 | ||
126 | @Override | |
127 | public List<String> options() { | |
128 |
1
1. options : replaced return value with Collections.emptyList for com/github/dakusui/actionunit/actions/cmd/unix/SshOptions$Impl::options → KILLED |
return sshOptions; |
129 | } | |
130 | ||
131 | @Override | |
132 | public OptionalInt port() { | |
133 |
2
1. port : negated conditional → KILLED 2. port : replaced return value with null for com/github/dakusui/actionunit/actions/cmd/unix/SshOptions$Impl::port → KILLED |
return port != null ? OptionalInt.of(port) : OptionalInt.empty(); |
134 | } | |
135 | ||
136 | @Override | |
137 | public boolean quiet() { | |
138 |
2
1. quiet : replaced boolean return with false for com/github/dakusui/actionunit/actions/cmd/unix/SshOptions$Impl::quiet → KILLED 2. quiet : replaced boolean return with true for com/github/dakusui/actionunit/actions/cmd/unix/SshOptions$Impl::quiet → KILLED |
return quiet; |
139 | } | |
140 | ||
141 | @Override | |
142 | public boolean verbose() { | |
143 |
2
1. verbose : replaced boolean return with false for com/github/dakusui/actionunit/actions/cmd/unix/SshOptions$Impl::verbose → KILLED 2. verbose : replaced boolean return with true for com/github/dakusui/actionunit/actions/cmd/unix/SshOptions$Impl::verbose → KILLED |
return verbose; |
144 | } | |
145 | } | |
146 | ||
147 | class Builder { | |
148 | private String identity; | |
149 | private final List<String> sshOptions = new LinkedList<>(); | |
150 | private final List<String> jumpHosts = new LinkedList<>(); | |
151 | private boolean ipv4; | |
152 | private boolean ipv6; | |
153 | private boolean compression; | |
154 | private String cipherSpec; | |
155 | private String configFile; | |
156 | private Integer port; | |
157 | private boolean quiet; | |
158 | private boolean verbose; | |
159 | private boolean authAgentConnectionForwarding; | |
160 | ||
161 | public Builder() { | |
162 | this.ipv4(false) | |
163 | .ipv6(false) | |
164 | .compression(false) | |
165 | .cipherSpec(null) | |
166 | .configFile(null) | |
167 | .identity(null) | |
168 | .port(null) | |
169 | .quiet(false) | |
170 | .verbose(false); | |
171 | } | |
172 | ||
173 | public Builder authAgentConnectionForwarding(boolean enable) { | |
174 | this.authAgentConnectionForwarding = enable; | |
175 |
1
1. authAgentConnectionForwarding : replaced return value with null for com/github/dakusui/actionunit/actions/cmd/unix/SshOptions$Builder::authAgentConnectionForwarding → KILLED |
return this; |
176 | } | |
177 | ||
178 | public Builder ipv4(boolean enable) { | |
179 | this.ipv4 = enable; | |
180 |
1
1. ipv4 : replaced return value with null for com/github/dakusui/actionunit/actions/cmd/unix/SshOptions$Builder::ipv4 → KILLED |
return this; |
181 | } | |
182 | ||
183 | public Builder ipv6(boolean enable) { | |
184 | this.ipv6 = enable; | |
185 |
1
1. ipv6 : replaced return value with null for com/github/dakusui/actionunit/actions/cmd/unix/SshOptions$Builder::ipv6 → KILLED |
return this; |
186 | } | |
187 | ||
188 | public Builder compression(boolean enable) { | |
189 | this.compression = enable; | |
190 |
1
1. compression : replaced return value with null for com/github/dakusui/actionunit/actions/cmd/unix/SshOptions$Builder::compression → KILLED |
return this; |
191 | } | |
192 | ||
193 | public Builder cipherSpec(String cipherSpec) { | |
194 | this.cipherSpec = cipherSpec; | |
195 |
1
1. cipherSpec : replaced return value with null for com/github/dakusui/actionunit/actions/cmd/unix/SshOptions$Builder::cipherSpec → KILLED |
return this; |
196 | } | |
197 | ||
198 | public Builder configFile(String configFile) { | |
199 | this.configFile = configFile; | |
200 |
1
1. configFile : replaced return value with null for com/github/dakusui/actionunit/actions/cmd/unix/SshOptions$Builder::configFile → KILLED |
return this; |
201 | } | |
202 | ||
203 | public Builder port(Integer port) { | |
204 | this.port = port; | |
205 |
1
1. port : replaced return value with null for com/github/dakusui/actionunit/actions/cmd/unix/SshOptions$Builder::port → KILLED |
return this; |
206 | } | |
207 | ||
208 | public Builder quiet(boolean quiet) { | |
209 | this.quiet = quiet; | |
210 |
1
1. quiet : replaced return value with null for com/github/dakusui/actionunit/actions/cmd/unix/SshOptions$Builder::quiet → KILLED |
return this; |
211 | } | |
212 | ||
213 | public Builder verbose(boolean verbose) { | |
214 | this.verbose = verbose; | |
215 |
1
1. verbose : replaced return value with null for com/github/dakusui/actionunit/actions/cmd/unix/SshOptions$Builder::verbose → KILLED |
return this; |
216 | } | |
217 | ||
218 | ||
219 | public Builder identity(String identity) { | |
220 | this.identity = identity; | |
221 |
1
1. identity : replaced return value with null for com/github/dakusui/actionunit/actions/cmd/unix/SshOptions$Builder::identity → KILLED |
return this; |
222 | } | |
223 | ||
224 | public Builder addJumpHost(String jumpHost) { | |
225 | this.jumpHosts.add(requireNonNull(jumpHost)); | |
226 |
1
1. addJumpHost : replaced return value with null for com/github/dakusui/actionunit/actions/cmd/unix/SshOptions$Builder::addJumpHost → KILLED |
return this; |
227 | } | |
228 | ||
229 | public Builder addSshOption(String option) { | |
230 | sshOptions.add(option); | |
231 |
1
1. addSshOption : replaced return value with null for com/github/dakusui/actionunit/actions/cmd/unix/SshOptions$Builder::addSshOption → KILLED |
return this; |
232 | } | |
233 | ||
234 | public Builder addSshOption(String option, String value) { | |
235 |
1
1. addSshOption : replaced return value with null for com/github/dakusui/actionunit/actions/cmd/unix/SshOptions$Builder::addSshOption → KILLED |
return this.addSshOption(String.format("%s=%s", option, value)); |
236 | } | |
237 | ||
238 | public Builder disablePasswordAuthentication() { | |
239 |
1
1. disablePasswordAuthentication : replaced return value with null for com/github/dakusui/actionunit/actions/cmd/unix/SshOptions$Builder::disablePasswordAuthentication → KILLED |
return this.addSshOption("PasswordAuthentication", "no"); |
240 | } | |
241 | ||
242 | public Builder disableStrictHostkeyChecking() { | |
243 |
1
1. disableStrictHostkeyChecking : replaced return value with null for com/github/dakusui/actionunit/actions/cmd/unix/SshOptions$Builder::disableStrictHostkeyChecking → KILLED |
return this.addSshOption("StrictHostkeyChecking", "no"); |
244 | } | |
245 | ||
246 | public SshOptions build() { | |
247 |
1
1. build : replaced return value with null for com/github/dakusui/actionunit/actions/cmd/unix/SshOptions$Builder::build → KILLED |
return new SshOptions.Impl( |
248 | authAgentConnectionForwarding, | |
249 | ipv4, | |
250 | ipv6, | |
251 | compression, | |
252 | jumpHosts, | |
253 | cipherSpec, | |
254 | configFile, | |
255 | identity, | |
256 | sshOptions, | |
257 | port, | |
258 | quiet, | |
259 | verbose); | |
260 | } | |
261 | } | |
262 | ||
263 | @FunctionalInterface | |
264 | interface Formatter { | |
265 | List<String> format(SshOptions sshOptions); | |
266 | ||
267 | static Formatter forSsh() { | |
268 |
2
1. forSsh : replaced return value with null for com/github/dakusui/actionunit/actions/cmd/unix/SshOptions$Formatter::forSsh → KILLED 2. lambda$forSsh$0 : replaced return value with Collections.emptyList for com/github/dakusui/actionunit/actions/cmd/unix/SshOptions$Formatter::lambda$forSsh$0 → KILLED |
return sshOptions -> new LinkedList<String>() {{ |
269 |
1
1. <init> : negated conditional → KILLED |
if (sshOptions.authAgentConnectionForwardingEnabled()) |
270 | add("-A"); | |
271 |
1
1. <init> : negated conditional → KILLED |
if (sshOptions.ipv4()) |
272 | add("-4"); | |
273 |
1
1. <init> : negated conditional → KILLED |
if (sshOptions.ipv6()) |
274 | add("-6"); | |
275 |
1
1. <init> : negated conditional → SURVIVED |
if (sshOptions.compression()) |
276 | add("-C"); | |
277 |
1
1. <init> : removed call to java/util/Optional::ifPresent → KILLED |
sshOptions.configFile().ifPresent(v -> { |
278 | add("-F"); | |
279 | add(v); | |
280 | }); | |
281 |
1
1. <init> : negated conditional → SURVIVED |
if (!sshOptions.jumpHosts().isEmpty()) |
282 | add("-J " + String.join(",", sshOptions.jumpHosts())); | |
283 |
1
1. <init> : removed call to java/util/Optional::ifPresent → KILLED |
sshOptions.cipherSpec().ifPresent(v -> { |
284 | add("-c"); | |
285 | add(v); | |
286 | }); | |
287 |
1
1. <init> : removed call to java/util/Optional::ifPresent → KILLED |
sshOptions.identity().ifPresent(v -> { |
288 | add("-i"); | |
289 | add(v); | |
290 | }); | |
291 |
1
1. <init> : removed call to java/util/List::forEach → KILLED |
sshOptions.options().forEach(v -> { |
292 | add("-o"); | |
293 | add(v); | |
294 | }); | |
295 |
1
1. <init> : removed call to java/util/OptionalInt::ifPresent → KILLED |
sshOptions.port().ifPresent(v -> { |
296 | add("-p"); | |
297 | add(Objects.toString(v)); | |
298 | }); | |
299 |
1
1. <init> : negated conditional → KILLED |
if (sshOptions.quiet()) |
300 | add("-q"); | |
301 |
1
1. <init> : negated conditional → KILLED |
if (sshOptions.verbose()) |
302 | add("-v"); | |
303 | }}; | |
304 | } | |
305 | ||
306 | static Formatter forScp() { | |
307 |
2
1. forScp : replaced return value with null for com/github/dakusui/actionunit/actions/cmd/unix/SshOptions$Formatter::forScp → KILLED 2. lambda$forScp$1 : replaced return value with Collections.emptyList for com/github/dakusui/actionunit/actions/cmd/unix/SshOptions$Formatter::lambda$forScp$1 → KILLED |
return sshOptions -> new LinkedList<String>() {{ |
308 |
1
1. <init> : negated conditional → KILLED |
if (sshOptions.authAgentConnectionForwardingEnabled()) |
309 | add("-A"); | |
310 |
1
1. <init> : negated conditional → KILLED |
if (sshOptions.ipv4()) |
311 | add("-4"); | |
312 |
1
1. <init> : negated conditional → KILLED |
if (sshOptions.ipv6()) |
313 | add("-6"); | |
314 |
1
1. <init> : negated conditional → KILLED |
if (sshOptions.compression()) |
315 | add("-C"); | |
316 |
1
1. <init> : removed call to java/util/Optional::ifPresent → KILLED |
sshOptions.configFile().ifPresent(v -> { |
317 | add("-F"); | |
318 | add(v); | |
319 | }); | |
320 |
1
1. <init> : negated conditional → KILLED |
if (!sshOptions.jumpHosts().isEmpty()) |
321 | add("-J " + String.join(",", sshOptions.jumpHosts())); | |
322 |
1
1. <init> : removed call to java/util/Optional::ifPresent → KILLED |
sshOptions.cipherSpec().ifPresent(v -> { |
323 | add("-c"); | |
324 | add(v); | |
325 | }); | |
326 |
1
1. <init> : removed call to java/util/Optional::ifPresent → KILLED |
sshOptions.identity().ifPresent(v -> { |
327 | add("-i"); | |
328 | add(v); | |
329 | }); | |
330 |
1
1. <init> : removed call to java/util/List::forEach → KILLED |
sshOptions.options().forEach(v -> { |
331 | add("-o"); | |
332 | add(v); | |
333 | }); | |
334 |
1
1. <init> : removed call to java/util/OptionalInt::ifPresent → KILLED |
sshOptions.port().ifPresent(v -> { |
335 | add("-P"); | |
336 | add(Objects.toString(v)); | |
337 | }); | |
338 |
1
1. <init> : negated conditional → KILLED |
if (sshOptions.quiet()) |
339 | add("-q"); | |
340 |
1
1. <init> : negated conditional → KILLED |
if (sshOptions.verbose()) |
341 | add("-v"); | |
342 | }}; | |
343 | } | |
344 | } | |
345 | } | |
Mutations | ||
25 |
1.1 |
|
53 |
1.1 |
|
88 |
1.1 2.2 |
|
93 |
1.1 2.2 |
|
98 |
1.1 2.2 |
|
103 |
1.1 2.2 |
|
108 |
1.1 |
|
113 |
1.1 |
|
118 |
1.1 |
|
123 |
1.1 |
|
128 |
1.1 |
|
133 |
1.1 2.2 |
|
138 |
1.1 2.2 |
|
143 |
1.1 2.2 |
|
175 |
1.1 |
|
180 |
1.1 |
|
185 |
1.1 |
|
190 |
1.1 |
|
195 |
1.1 |
|
200 |
1.1 |
|
205 |
1.1 |
|
210 |
1.1 |
|
215 |
1.1 |
|
221 |
1.1 |
|
226 |
1.1 |
|
231 |
1.1 |
|
235 |
1.1 |
|
239 |
1.1 |
|
243 |
1.1 |
|
247 |
1.1 |
|
268 |
1.1 2.2 |
|
269 |
1.1 |
|
271 |
1.1 |
|
273 |
1.1 |
|
275 |
1.1 |
|
277 |
1.1 |
|
281 |
1.1 |
|
283 |
1.1 |
|
287 |
1.1 |
|
291 |
1.1 |
|
295 |
1.1 |
|
299 |
1.1 |
|
301 |
1.1 |
|
307 |
1.1 2.2 |
|
308 |
1.1 |
|
310 |
1.1 |
|
312 |
1.1 |
|
314 |
1.1 |
|
316 |
1.1 |
|
320 |
1.1 |
|
322 |
1.1 |
|
326 |
1.1 |
|
330 |
1.1 |
|
334 |
1.1 |
|
338 |
1.1 |
|
340 |
1.1 |