9588e0c530d9e599843846cd2830ed7ae15f5c12
[ccsdk/oran.git] /
1 /*-
2  * ========================LICENSE_START=================================
3  * ONAP : ccsdk oran
4  * ======================================================================
5  * Copyright (C) 2025 OpenInfra Foundation Europe. All rights reserved.
6  * ======================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ========================LICENSE_END===================================
19  */
20
21 package org.onap.ccsdk.oran.a1policymanagementservice.utils.v3;
22
23 import org.junit.jupiter.api.BeforeEach;
24 import org.junit.jupiter.api.DisplayName;
25 import org.junit.jupiter.api.Test;
26 import org.junit.jupiter.api.extension.ExtendWith;
27 import org.onap.ccsdk.oran.a1policymanagementservice.configuration.ApplicationConfig;
28 import org.onap.ccsdk.oran.a1policymanagementservice.controllers.OpenPolicyAgentSimulatorController;
29 import org.springframework.beans.factory.annotation.Autowired;
30 import org.springframework.boot.test.context.SpringBootTest;
31 import org.springframework.boot.test.system.CapturedOutput;
32 import org.springframework.boot.test.system.OutputCaptureExtension;
33 import org.springframework.boot.test.web.server.LocalServerPort;
34 import org.springframework.http.HttpStatus;
35 import org.springframework.http.ResponseEntity;
36 import org.springframework.test.context.TestPropertySource;
37 import reactor.core.publisher.Mono;
38
39
40 import static org.junit.jupiter.api.Assertions.assertFalse;
41
42 @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
43 @ExtendWith({OutputCaptureExtension.class})
44 @TestPropertySource(properties = {
45         "server.ssl.key-store=./config/keystore.jks",
46         "app.webclient.trust-store=./config/truststore.jks",
47         "app.vardata-directory=./target",
48         "app.config-file-schema-path=/application_configuration_schema.json",
49         "logging.reactive-entry-exit-filter-enabled=true",
50         "logging.level.org.onap.ccsdk.oran.a1policymanagementservice=TRACE",
51         "logging.reactive-entry-exit-filter-exclude-paths=/actuator/**"
52 })
53 class ReactiveEntryExitFilterExcludePathTest {
54
55     @Autowired
56     private ApplicationConfig applicationConfig;
57
58     @Autowired
59     private TestHelperTest testHelperTest;
60
61     @LocalServerPort
62     private int port;
63
64     @BeforeEach
65     void init() {
66         testHelperTest.port = port;
67         this.applicationConfig.setAuthProviderUrl(testHelperTest.baseUrl() + OpenPolicyAgentSimulatorController.ACCESS_CONTROL_URL);
68     }
69
70     @Test
71     @DisplayName("test verify entry exit log for health actuator is absent")
72     void testHealthActuatorFilterOmitted(CapturedOutput capturedOutput) throws Exception {
73         String url = "/actuator/health";
74         Mono<ResponseEntity<String>> responseGetHealthMono =
75                 testHelperTest.restClient(testHelperTest.baseUrl(), false).getForEntity(url);
76         testHelperTest.testSuccessResponse(responseGetHealthMono, HttpStatus.OK, responseBody -> responseBody.contains("UP"));
77         assertFalse(capturedOutput.getOut().contains("Request received with path: /actuator/health"));
78         assertFalse(capturedOutput.getOut().contains("the response is:"));
79     }
80 }