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:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user