feat(outbound): admin test action for reachability + TLS summary

POST /{id}/test issues a synthetic probe against the connection URL.
TLS protocol/cipher/peer-cert details stubbed for now (Plan 02 follow-up).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
hsiegeln
2026-04-19 16:47:36 +02:00
parent ea4c56e7f6
commit 87b8a71205
2 changed files with 82 additions and 1 deletions

View File

@@ -24,6 +24,12 @@ class OutboundConnectionAdminControllerIT extends AbstractPostgresIT {
private String adminJwt;
private String operatorJwt;
private String viewerJwt;
private com.github.tomakehurst.wiremock.WireMockServer wireMock;
@org.junit.jupiter.api.AfterEach
void tearDownWireMock() {
if (wireMock != null) wireMock.stop();
}
@BeforeEach
void setUp() {
@@ -132,4 +138,36 @@ class OutboundConnectionAdminControllerIT extends AbstractPostgresIT {
String.class);
assertThat(get.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND);
}
@Test
void testActionReturnsStatusAndLatency() throws Exception {
wireMock = new com.github.tomakehurst.wiremock.WireMockServer(
com.github.tomakehurst.wiremock.core.WireMockConfiguration.options()
.httpDisabled(true).dynamicHttpsPort());
wireMock.start();
wireMock.stubFor(com.github.tomakehurst.wiremock.client.WireMock.post("/probe")
.willReturn(com.github.tomakehurst.wiremock.client.WireMock.ok("pong")));
String createBody = """
{"name":"probe-target","url":"https://localhost:%d/probe","method":"POST",
"tlsTrustMode":"TRUST_ALL","auth":{}}""".formatted(wireMock.httpsPort());
ResponseEntity<String> create = restTemplate.exchange(
"/api/v1/admin/outbound-connections", HttpMethod.POST,
new HttpEntity<>(createBody, securityHelper.authHeaders(adminJwt)),
String.class);
assertThat(create.getStatusCode()).isEqualTo(HttpStatus.CREATED);
String id = objectMapper.readTree(create.getBody()).path("id").asText();
ResponseEntity<String> test = restTemplate.exchange(
"/api/v1/admin/outbound-connections/" + id + "/test", HttpMethod.POST,
new HttpEntity<>(securityHelper.authHeaders(adminJwt)),
String.class);
assertThat(test.getStatusCode()).isEqualTo(HttpStatus.OK);
JsonNode body = objectMapper.readTree(test.getBody());
assertThat(body.path("status").asInt()).isEqualTo(200);
assertThat(body.path("latencyMs").asLong()).isGreaterThanOrEqualTo(0);
assertThat(body.path("tlsProtocol").asText()).isEqualTo("TLS");
assertThat(body.path("error").isNull()).isTrue();
}
}