Skip to content

Commit 17a87f3

Browse files
committed
Enabled Ftp test
1 parent ef42772 commit 17a87f3

2 files changed

Lines changed: 25 additions & 21 deletions

File tree

src/test/java/nl/altindag/crip/client/ftp/FtpClientRunnableIT.java

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import nl.altindag.crip.CertificateRipper;
2020
import nl.altindag.crip.request.Request;
2121
import org.awaitility.Awaitility;
22-
import org.junit.jupiter.api.Disabled;
2322
import org.junit.jupiter.api.Test;
2423

2524
import java.io.IOException;
@@ -29,13 +28,12 @@
2928

3029
import static org.assertj.core.api.Assertions.assertThat;
3130

32-
@Disabled
3331
class FtpClientRunnableIT {
3432

3533
private static final Pattern CAPTURED_CERTIFICATES = Pattern.compile("\\* [1-9]+: ftps://localhost:2231");
3634

3735
@Test
38-
void shouldPrintCertificates() throws IOException {
36+
void shouldPrintCertificates() throws IOException, InterruptedException {
3937
URL dockerComposeFile = FtpClientRunnableIT.class.getClassLoader().getResource("docker-compose/ftp/docker-compose.yaml");
4038
assertThat(dockerComposeFile).isNotNull();
4139

@@ -44,28 +42,31 @@ void shouldPrintCertificates() throws IOException {
4442
"docker",
4543
"compose",
4644
"--file=" + dockerComposeFile.getPath(),
47-
"up"
45+
"up",
46+
"-d"
4847
).start();
4948

50-
Request request = CertificateRipper.print("ftps://localhost:2231").build();
49+
try {
50+
Request request = CertificateRipper.print("ftps://localhost:2231").build();
5151

52-
Awaitility.await()
53-
.atMost(2, TimeUnit.MINUTES)
54-
.pollInterval(1, TimeUnit.SECONDS)
55-
.untilAsserted(() -> {
56-
request.run();
57-
String standardOutput = String.join(System.lineSeparator(), consoleCaptor.getStandardOutput());
58-
assertThat(CAPTURED_CERTIFICATES.matcher(standardOutput).find()).isTrue();
59-
});
52+
Awaitility.await()
53+
.atMost(2, TimeUnit.MINUTES)
54+
.pollInterval(1, TimeUnit.SECONDS)
55+
.untilAsserted(() -> {
56+
request.run();
57+
String standardOutput = String.join(System.lineSeparator(), consoleCaptor.getStandardOutput());
58+
assertThat(CAPTURED_CERTIFICATES.matcher(standardOutput).find()).isTrue();
59+
});
60+
} finally {
61+
new ProcessBuilder(
62+
"docker",
63+
"compose",
64+
"--file=" + dockerComposeFile.getPath(),
65+
"down"
66+
).start().waitFor();
6067

61-
new ProcessBuilder(
62-
"docker",
63-
"compose",
64-
"--file=" + dockerComposeFile.getPath(),
65-
"down"
66-
).start();
67-
68-
consoleCaptor.close();
68+
consoleCaptor.close();
69+
}
6970
}
7071

7172
}

src/test/resources/docker-compose/ftp/docker-compose.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ services:
1515
ports:
1616
- "2231:21"
1717
- "22000-22010:22000-22010"
18+
depends_on:
19+
cert-gen:
20+
condition: service_completed_successfully
1821

1922
cert-gen:
2023
image: alpine

0 commit comments

Comments
 (0)