2 * ========================LICENSE_START=================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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===================================
21 package org.onap.ccsdk.oran.a1policymanagementservice.utils.v3;
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;
39 import java.io.IOException;
41 import static org.junit.jupiter.api.Assertions.assertFalse;
43 @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
44 @ExtendWith({OutputCaptureExtension.class})
45 @TestPropertySource(properties = {
46 "server.ssl.key-store=./config/keystore.jks",
47 "app.webclient.trust-store=./config/truststore.jks",
48 "app.vardata-directory=./target",
49 "app.config-file-schema-path=/application_configuration_schema.json",
50 "logging.reactive-entry-exit-filter-enabled=true",
51 "logging.level.org.onap.ccsdk.oran.a1policymanagementservice=TRACE",
52 "logging.reactive-entry-exit-filter-exclude-paths=/actuator/**,/a1-policy-management/v1/rics/**"
54 class ReactiveEntryExitFilterExcludeMultiPathTest {
57 private ApplicationConfig applicationConfig;
60 private TestHelperTest testHelperTest;
67 testHelperTest.port = port;
68 this.applicationConfig.setAuthProviderUrl(testHelperTest.baseUrl() + OpenPolicyAgentSimulatorController.ACCESS_CONTROL_URL);
72 @DisplayName("test verify entry exit log for health actuator is absent")
73 void testHealthActuatorFilterOmitted(CapturedOutput capturedOutput) throws Exception {
74 String url = "/actuator/health";
75 Mono<ResponseEntity<String>> responseGetHealthMono =
76 testHelperTest.restClient(testHelperTest.baseUrl(), false).getForEntity(url);
77 testHelperTest.testSuccessResponse(responseGetHealthMono, HttpStatus.OK, responseBody -> responseBody.contains("UP"));
78 assertFalse(capturedOutput.getOut().contains("Request received with path: /actuator/health"));
79 assertFalse(capturedOutput.getOut().contains("the response is:"));
83 @DisplayName("test verify entry exit log for the rics endpoint is absent")
84 void testGetRicsFilterOmitted(CapturedOutput capturedOutput) throws Exception {
86 Mono<ResponseEntity<String>> responseEntityMono = testHelperTest.restClientV3().getForEntity(url);
87 testHelperTest.testSuccessResponse(responseEntityMono, HttpStatus.OK, responseBody -> responseBody
88 .contains("{\"rics\":[]}"));
89 assertFalse(capturedOutput.getOut().contains("Request received with path: /rics"));
90 assertFalse(capturedOutput.getOut().contains("the response is:"));