Cherry picks from master 31/8931/2 1.3.1
authorPatrikBuhr <patrik.buhr@est.tech>
Fri, 5 Aug 2022 06:43:51 +0000 (08:43 +0200)
committerPatrikBuhr <patrik.buhr@est.tech>
Thu, 25 Aug 2022 05:54:46 +0000 (07:54 +0200)
Missing app.auth-token-file in application.yaml would not default to an empty string.
Formatting

Signed-off-by: PatrikBuhr <patrik.buhr@est.tech>
Issue-ID: NONRTRIC-743
Change-Id: I25ad0e65a829f6245f69548d0dfce7d06f287e79

22 files changed:
.readthedocs.yaml
config/README
config/application.yaml
config/keystore.jks
config/truststore.jks
docs/conf.py
pom.xml
src/main/java/org/oransc/ics/clients/SecurityContext.java
src/main/java/org/oransc/ics/configuration/ApplicationConfig.java
src/main/java/org/oransc/ics/controllers/VoidResponse.java
src/main/java/org/oransc/ics/controllers/a1e/A1eEiJobStatus.java
src/main/java/org/oransc/ics/controllers/a1e/A1eEiTypeInfo.java
src/main/java/org/oransc/ics/controllers/r1consumer/ConsumerInfoTypeInfo.java
src/main/java/org/oransc/ics/controllers/r1consumer/ConsumerJobInfo.java
src/main/java/org/oransc/ics/controllers/r1consumer/ConsumerJobStatus.java
src/main/java/org/oransc/ics/controllers/r1consumer/ConsumerTypeRegistrationInfo.java
src/main/java/org/oransc/ics/controllers/r1consumer/ConsumerTypeSubscriptionInfo.java
src/main/java/org/oransc/ics/controllers/r1producer/ProducerInfoTypeInfo.java
src/main/java/org/oransc/ics/controllers/r1producer/ProducerRegistrationInfo.java
src/main/java/org/oransc/ics/controllers/r1producer/ProducerStatusInfo.java
src/test/java/org/oransc/ics/ApplicationTest.java
src/test/java/org/oransc/ics/MockInformationService.java

index 095222a..30f3f56 100644 (file)
@@ -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
 
index 140927f..cfde02e 100644 (file)
@@ -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
index e61bfea..fcfc672 100644 (file)
@@ -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
index 122997a..563c67b 100644 (file)
Binary files a/config/keystore.jks and b/config/keystore.jks differ
index 60d6288..50a0f9e 100644 (file)
Binary files a/config/truststore.jks and b/config/truststore.jks differ
index 62a64db..0fbe4a6 100644 (file)
@@ -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 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -31,7 +31,7 @@
     </parent>
     <groupId>org.o-ran-sc.nonrtric.plt</groupId>
     <artifactId>informationcoordinatorservice</artifactId>
-    <version>1.3.0-SNAPSHOT</version>
+    <version>1.3.1-SNAPSHOT</version>
     <licenses>
         <license>
             <name>The Apache Software License, Version 2.0</name>
         <jacoco-maven-plugin.version>0.8.5</jacoco-maven-plugin.version>
         <exec.skip>true</exec.skip>
     </properties>
-    <dependencies>
-        <dependency>
-            <groupId>org.springdoc</groupId>
-            <artifactId>springdoc-openapi-ui</artifactId>
-            <version>1.6.6</version>
-        </dependency>
+    <dependencies>        
         <dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-web</artifactId>
             <optional>true</optional>
         </dependency>
         <!-- TEST -->
+        <dependency>
+            <groupId>org.springdoc</groupId>
+            <artifactId>springdoc-openapi-ui</artifactId>
+            <version>1.6.6</version>
+            <scope>test</scope>
+        </dependency>
         <dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-test</artifactId>
         <system>JIRA</system>
         <url>https://jira.o-ran-sc.org/</url>
     </issueManagement>
-</project>
\ No newline at end of file
+</project>
index aadc1bf..f11b669 100644 (file)
@@ -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;
             }
index f076789..50c6daa 100644 (file)
@@ -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}")
index 4f69a7a..e369acd 100644 (file)
@@ -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() {
index 1f22e9a..e635f2e 100644 (file)
@@ -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 {
 
index eac18f3..edf7297 100644 (file)
@@ -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 {
 
index cce345c..1f11c15 100644 (file)
@@ -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 {
 
index 696e827..7babf87 100644 (file)
@@ -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 {
 
index 715f88f..78657fd 100644 (file)
@@ -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 {
 
index f3010c9..fa4ea99 100644 (file)
@@ -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 {
 
index fc8fc24..84e8e9d 100644 (file)
@@ -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 {
index beca34a..45c5a93 100644 (file)
@@ -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 {
 
index 3493bad..ee82546 100644 (file)
@@ -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 {
 
index c29af8f..9a04023 100644 (file)
@@ -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 {
 
index 4ac4283..b08c455 100644 (file)
@@ -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");
index 65c19a8..fc21315 100644 (file)
 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 = { //