1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.syncope.sra;
20
21 import javax.net.ssl.SSLException;
22 import org.junit.jupiter.api.Test;
23 import org.springframework.beans.factory.annotation.Autowired;
24 import org.springframework.boot.actuate.endpoint.ApiVersion;
25 import org.springframework.http.HttpHeaders;
26 import org.springframework.test.web.reactive.server.WebTestClient;
27
28 public class ActuatorTest extends AbstractTest {
29
30 @Autowired
31 private WebTestClient webClient;
32
33 @Test
34 public void health() throws SSLException {
35 webClient.get().uri("/actuator/health").
36 exchange().expectStatus().isUnauthorized();
37
38 webClient.get().uri("/actuator/health").
39 header(HttpHeaders.AUTHORIZATION, basicAuthHeader()).
40 exchange().
41 expectStatus().isOk().
42 expectHeader().valueEquals(HttpHeaders.CONTENT_TYPE, ApiVersion.V3.getProducedMimeType().toString());
43 }
44
45 @Test
46 public void routes() throws SSLException {
47 webClient.get().uri("/actuator/gateway/routes").
48 exchange().expectStatus().isUnauthorized();
49
50 webClient.get().uri("/actuator/gateway/routes").
51 header(HttpHeaders.AUTHORIZATION, basicAuthHeader()).
52 exchange().expectStatus().isOk();
53 }
54
55 @Test
56 public void requests() throws SSLException {
57 webClient.get().uri("/actuator/metrics/gateway.requests").
58 exchange().expectStatus().isUnauthorized();
59
60 webClient.get().uri("/actuator/metrics/gateway.requests").
61 header(HttpHeaders.AUTHORIZATION, basicAuthHeader()).
62 exchange().expectStatus().isNotFound();
63 }
64 }