From: PatrikBuhr Date: Fri, 5 Aug 2022 06:43:51 +0000 (+0200) Subject: Cherry picks from master X-Git-Tag: 1.3.1^0 X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F31%2F8931%2F2;p=nonrtric%2Fplt%2Finformationcoordinatorservice.git Cherry picks from master Missing app.auth-token-file in application.yaml would not default to an empty string. Formatting Signed-off-by: PatrikBuhr Issue-ID: NONRTRIC-743 Change-Id: I25ad0e65a829f6245f69548d0dfce7d06f287e79 --- diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 095222a..30f3f56 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -1,3 +1,20 @@ +# ============LICENSE_START=============================================== +# Copyright (C) 2019-2022 Nordix Foundation. All rights reserved. +# ======================================================================== +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END================================================= +# + --- version: 2 diff --git a/config/README b/config/README index 140927f..cfde02e 100644 --- a/config/README +++ b/config/README @@ -3,13 +3,15 @@ The keystore.jks and truststore.jks files are created by using the following com 1) Create a CA certificate and a private key: openssl genrsa -des3 -out CA-key.pem 2048 -openssl req -new -key CA-key.pem -x509 -days 1000 -out CA-cert.pem +openssl req -new -key CA-key.pem -x509 -days 3600 -out CA-cert.pem 2) Create a keystore with a private key entry that is signed by the CA: +Note: your name must be "localhost" + keytool -genkeypair -alias policy_agent -keyalg RSA -keysize 2048 -keystore keystore.jks -validity 3650 -storepass policy_agent keytool -certreq -alias policy_agent -file request.csr -keystore keystore.jks -ext san=dns:your.domain.com -storepass policy_agent -openssl x509 -req -days 365 -in request.csr -CA CA-cert.pem -CAkey CA-key.pem -CAcreateserial -out ca_signed-cert.pem +openssl x509 -req -days 3650 -in request.csr -CA CA-cert.pem -CAkey CA-key.pem -CAcreateserial -out ca_signed-cert.pem keytool -importcert -alias ca_cert -file CA-cert.pem -keystore keystore.jks -trustcacerts -storepass policy_agent keytool -importcert -alias policy_agent -file ca_signed-cert.pem -keystore keystore.jks -trustcacerts -storepass policy_agent @@ -26,7 +28,7 @@ keytool -list -v -keystore truststore.jks -storepass policy_agent ## License -Copyright (C) 2020 Nordix Foundation. All rights reserved. +Copyright (C) 2022 Nordix Foundation. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at diff --git a/config/application.yaml b/config/application.yaml index e61bfea..fcfc672 100644 --- a/config/application.yaml +++ b/config/application.yaml @@ -1,3 +1,20 @@ +# ============LICENSE_START=============================================== +# Copyright (C) 2019-2022 Nordix Foundation. All rights reserved. +# ======================================================================== +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END================================================= +# + spring: profiles: active: prod diff --git a/config/keystore.jks b/config/keystore.jks index 122997a..563c67b 100644 Binary files a/config/keystore.jks and b/config/keystore.jks differ diff --git a/config/truststore.jks b/config/truststore.jks index 60d6288..50a0f9e 100644 Binary files a/config/truststore.jks and b/config/truststore.jks differ diff --git a/docs/conf.py b/docs/conf.py index 62a64db..0fbe4a6 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,3 +1,20 @@ +# ============LICENSE_START=============================================== +# Copyright (C) 2020-2022 Nordix Foundation. All rights reserved. +# ======================================================================== +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END================================================= +# + from docs_conf.conf import * #branch configuration diff --git a/pom.xml b/pom.xml index d9fe5b7..470f98a 100644 --- a/pom.xml +++ b/pom.xml @@ -31,7 +31,7 @@ org.o-ran-sc.nonrtric.plt informationcoordinatorservice - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT The Apache Software License, Version 2.0 @@ -60,12 +60,7 @@ 0.8.5 true - - - org.springdoc - springdoc-openapi-ui - 1.6.6 - + org.springframework.boot spring-boot-starter-web @@ -141,6 +136,12 @@ true + + org.springdoc + springdoc-openapi-ui + 1.6.6 + test + org.springframework.boot spring-boot-starter-test @@ -345,4 +346,4 @@ JIRA https://jira.o-ran-sc.org/ - \ No newline at end of file + diff --git a/src/main/java/org/oransc/ics/clients/SecurityContext.java b/src/main/java/org/oransc/ics/clients/SecurityContext.java index aadc1bf..f11b669 100644 --- a/src/main/java/org/oransc/ics/clients/SecurityContext.java +++ b/src/main/java/org/oransc/ics/clients/SecurityContext.java @@ -47,7 +47,7 @@ public class SecurityContext { @Setter private Path authTokenFilePath; - public SecurityContext(@Value("${app.auth-token-file:\"\"}") String authTokenFilename) { + public SecurityContext(@Value("${app.auth-token-file:}") String authTokenFilename) { if (!authTokenFilename.isEmpty()) { this.authTokenFilePath = Path.of(authTokenFilename); } @@ -63,7 +63,7 @@ public class SecurityContext { } try { long lastModified = authTokenFilePath.toFile().lastModified(); - if (lastModified != this.tokenTimestamp) { + if (tokenTimestamp == 0 || lastModified != this.tokenTimestamp) { this.authToken = Files.readString(authTokenFilePath); this.tokenTimestamp = lastModified; } diff --git a/src/main/java/org/oransc/ics/configuration/ApplicationConfig.java b/src/main/java/org/oransc/ics/configuration/ApplicationConfig.java index f076789..50c6daa 100644 --- a/src/main/java/org/oransc/ics/configuration/ApplicationConfig.java +++ b/src/main/java/org/oransc/ics/configuration/ApplicationConfig.java @@ -60,7 +60,7 @@ public class ApplicationConfig { @Value("${app.webclient.trust-store}") private String sslTrustStore = ""; - @Value("${app.webclient.http.proxy-host:\"\"}") + @Value("${app.webclient.http.proxy-host:}") private String httpProxyHost = ""; @Value("${app.webclient.http.proxy-port:0}") diff --git a/src/main/java/org/oransc/ics/controllers/VoidResponse.java b/src/main/java/org/oransc/ics/controllers/VoidResponse.java index 4f69a7a..e369acd 100644 --- a/src/main/java/org/oransc/ics/controllers/VoidResponse.java +++ b/src/main/java/org/oransc/ics/controllers/VoidResponse.java @@ -22,7 +22,6 @@ package org.oransc.ics.controllers; import io.swagger.v3.oas.annotations.media.Schema; - @Schema(name = "Void", description = "Void/empty ") public class VoidResponse { private VoidResponse() { diff --git a/src/main/java/org/oransc/ics/controllers/a1e/A1eEiJobStatus.java b/src/main/java/org/oransc/ics/controllers/a1e/A1eEiJobStatus.java index 1f22e9a..e635f2e 100644 --- a/src/main/java/org/oransc/ics/controllers/a1e/A1eEiJobStatus.java +++ b/src/main/java/org/oransc/ics/controllers/a1e/A1eEiJobStatus.java @@ -25,7 +25,6 @@ import com.google.gson.annotations.SerializedName; import io.swagger.v3.oas.annotations.media.Schema; - @Schema(name = "EiJobStatusObject", description = "Status for an EI job") public class A1eEiJobStatus { diff --git a/src/main/java/org/oransc/ics/controllers/a1e/A1eEiTypeInfo.java b/src/main/java/org/oransc/ics/controllers/a1e/A1eEiTypeInfo.java index eac18f3..edf7297 100644 --- a/src/main/java/org/oransc/ics/controllers/a1e/A1eEiTypeInfo.java +++ b/src/main/java/org/oransc/ics/controllers/a1e/A1eEiTypeInfo.java @@ -22,7 +22,6 @@ package org.oransc.ics.controllers.a1e; import io.swagger.v3.oas.annotations.media.Schema; - @Schema(name = "EiTypeObject", description = "Information for an EI type") public class A1eEiTypeInfo { diff --git a/src/main/java/org/oransc/ics/controllers/r1consumer/ConsumerInfoTypeInfo.java b/src/main/java/org/oransc/ics/controllers/r1consumer/ConsumerInfoTypeInfo.java index cce345c..1f11c15 100644 --- a/src/main/java/org/oransc/ics/controllers/r1consumer/ConsumerInfoTypeInfo.java +++ b/src/main/java/org/oransc/ics/controllers/r1consumer/ConsumerInfoTypeInfo.java @@ -25,7 +25,6 @@ import com.google.gson.annotations.SerializedName; import io.swagger.v3.oas.annotations.media.Schema; - @Schema(name = "consumer_information_type", description = "Information for an Information type") public class ConsumerInfoTypeInfo { diff --git a/src/main/java/org/oransc/ics/controllers/r1consumer/ConsumerJobInfo.java b/src/main/java/org/oransc/ics/controllers/r1consumer/ConsumerJobInfo.java index 696e827..7babf87 100644 --- a/src/main/java/org/oransc/ics/controllers/r1consumer/ConsumerJobInfo.java +++ b/src/main/java/org/oransc/ics/controllers/r1consumer/ConsumerJobInfo.java @@ -25,7 +25,6 @@ import com.google.gson.annotations.SerializedName; import io.swagger.v3.oas.annotations.media.Schema; - @Schema(name = "consumer_job", description = "Information for an Information Job") public class ConsumerJobInfo { diff --git a/src/main/java/org/oransc/ics/controllers/r1consumer/ConsumerJobStatus.java b/src/main/java/org/oransc/ics/controllers/r1consumer/ConsumerJobStatus.java index 715f88f..78657fd 100644 --- a/src/main/java/org/oransc/ics/controllers/r1consumer/ConsumerJobStatus.java +++ b/src/main/java/org/oransc/ics/controllers/r1consumer/ConsumerJobStatus.java @@ -27,7 +27,6 @@ import io.swagger.v3.oas.annotations.media.Schema; import java.util.Collection; - @Schema(name = "consumer_job_status", description = "Status for an Information Job") public class ConsumerJobStatus { diff --git a/src/main/java/org/oransc/ics/controllers/r1consumer/ConsumerTypeRegistrationInfo.java b/src/main/java/org/oransc/ics/controllers/r1consumer/ConsumerTypeRegistrationInfo.java index f3010c9..fa4ea99 100644 --- a/src/main/java/org/oransc/ics/controllers/r1consumer/ConsumerTypeRegistrationInfo.java +++ b/src/main/java/org/oransc/ics/controllers/r1consumer/ConsumerTypeRegistrationInfo.java @@ -25,7 +25,6 @@ import com.google.gson.annotations.SerializedName; import io.swagger.v3.oas.annotations.media.Schema; - @Schema(name = "consumer_type_registration_info", description = "Information for an Information type") public class ConsumerTypeRegistrationInfo { diff --git a/src/main/java/org/oransc/ics/controllers/r1consumer/ConsumerTypeSubscriptionInfo.java b/src/main/java/org/oransc/ics/controllers/r1consumer/ConsumerTypeSubscriptionInfo.java index fc8fc24..84e8e9d 100644 --- a/src/main/java/org/oransc/ics/controllers/r1consumer/ConsumerTypeSubscriptionInfo.java +++ b/src/main/java/org/oransc/ics/controllers/r1consumer/ConsumerTypeSubscriptionInfo.java @@ -26,7 +26,6 @@ import com.google.gson.annotations.SerializedName; import io.swagger.v3.oas.annotations.media.Schema; import lombok.EqualsAndHashCode; - @EqualsAndHashCode @Schema(name = "consumer_type_subscription_info", description = "Information for an information type subscription") public class ConsumerTypeSubscriptionInfo { diff --git a/src/main/java/org/oransc/ics/controllers/r1producer/ProducerInfoTypeInfo.java b/src/main/java/org/oransc/ics/controllers/r1producer/ProducerInfoTypeInfo.java index beca34a..45c5a93 100644 --- a/src/main/java/org/oransc/ics/controllers/r1producer/ProducerInfoTypeInfo.java +++ b/src/main/java/org/oransc/ics/controllers/r1producer/ProducerInfoTypeInfo.java @@ -25,7 +25,6 @@ import com.google.gson.annotations.SerializedName; import io.swagger.v3.oas.annotations.media.Schema; - @Schema(name = "producer_info_type_info", description = "Information for an Information Type") public class ProducerInfoTypeInfo { diff --git a/src/main/java/org/oransc/ics/controllers/r1producer/ProducerRegistrationInfo.java b/src/main/java/org/oransc/ics/controllers/r1producer/ProducerRegistrationInfo.java index 3493bad..ee82546 100644 --- a/src/main/java/org/oransc/ics/controllers/r1producer/ProducerRegistrationInfo.java +++ b/src/main/java/org/oransc/ics/controllers/r1producer/ProducerRegistrationInfo.java @@ -27,7 +27,6 @@ import io.swagger.v3.oas.annotations.media.Schema; import java.util.Collection; - @Schema(name = "producer_registration_info", description = "Information for an Information Producer") public class ProducerRegistrationInfo { diff --git a/src/main/java/org/oransc/ics/controllers/r1producer/ProducerStatusInfo.java b/src/main/java/org/oransc/ics/controllers/r1producer/ProducerStatusInfo.java index c29af8f..9a04023 100644 --- a/src/main/java/org/oransc/ics/controllers/r1producer/ProducerStatusInfo.java +++ b/src/main/java/org/oransc/ics/controllers/r1producer/ProducerStatusInfo.java @@ -25,7 +25,6 @@ import com.google.gson.annotations.SerializedName; import io.swagger.v3.oas.annotations.media.Schema; - @Schema(name = "producer_status", description = "Status for an Info Producer") public class ProducerStatusInfo { diff --git a/src/test/java/org/oransc/ics/ApplicationTest.java b/src/test/java/org/oransc/ics/ApplicationTest.java index 4ac4283..b08c455 100644 --- a/src/test/java/org/oransc/ics/ApplicationTest.java +++ b/src/test/java/org/oransc/ics/ApplicationTest.java @@ -43,7 +43,6 @@ import org.json.JSONObject; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; import org.oransc.ics.clients.AsyncRestClient; import org.oransc.ics.clients.AsyncRestClientFactory; import org.oransc.ics.clients.SecurityContext; @@ -93,18 +92,17 @@ import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.web.reactive.function.client.WebClientResponseException; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; -@ExtendWith(SpringExtension.class) @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) @TestPropertySource( properties = { // "server.ssl.key-store=./config/keystore.jks", // "app.webclient.trust-store=./config/truststore.jks", // + "app.webclient.trust-store-used=true", // "app.vardata-directory=./target"}) class ApplicationTest { private final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); @@ -206,6 +204,14 @@ class ApplicationTest { assertThat(rsp).isEqualTo("[\"test\"]"); } + @Test + void testTrustValidation() throws Exception { + putInfoProducerWithOneType(PRODUCER_ID, "test"); + String url = A1eConsts.API_ROOT + "/eitypes"; + String rsp = restClient(true).get(url).block(); + assertThat(rsp).isEqualTo("[\"test\"]"); + } + @Test void consumerGetInfoTypes() throws Exception { putInfoProducerWithOneType(PRODUCER_ID, "test"); diff --git a/src/test/java/org/oransc/ics/MockInformationService.java b/src/test/java/org/oransc/ics/MockInformationService.java index 65c19a8..fc21315 100644 --- a/src/test/java/org/oransc/ics/MockInformationService.java +++ b/src/test/java/org/oransc/ics/MockInformationService.java @@ -21,16 +21,13 @@ package org.oransc.ics; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.boot.web.server.LocalServerPort; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit.jupiter.SpringExtension; -@ExtendWith(SpringExtension.class) @SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT) @TestPropertySource( properties = { //