Merge "Excluding Loop components from SONAR"
diff --git a/gui-clamp/pom.xml b/gui-clamp/pom.xml
index 3658893..e5301d8 100644
--- a/gui-clamp/pom.xml
+++ b/gui-clamp/pom.xml
@@ -23,7 +23,7 @@
<parent>
<groupId>org.onap.policy.gui</groupId>
<artifactId>policy-gui</artifactId>
- <version>2.2.1-SNAPSHOT</version>
+ <version>2.2.2-SNAPSHOT</version>
</parent>
<artifactId>gui-clamp</artifactId>
<packaging>pom</packaging>
diff --git a/gui-common/pom.xml b/gui-common/pom.xml
index a24fef3..8c46c8b 100644
--- a/gui-common/pom.xml
+++ b/gui-common/pom.xml
@@ -23,7 +23,7 @@
<parent>
<groupId>org.onap.policy.gui</groupId>
<artifactId>policy-gui</artifactId>
- <version>2.2.1-SNAPSHOT</version>
+ <version>2.2.2-SNAPSHOT</version>
</parent>
<artifactId>gui-common</artifactId>
diff --git a/gui-editors/gui-editor-apex/pom.xml b/gui-editors/gui-editor-apex/pom.xml
index c0f3819..8c7f6c9 100644
--- a/gui-editors/gui-editor-apex/pom.xml
+++ b/gui-editors/gui-editor-apex/pom.xml
@@ -26,7 +26,7 @@
<parent>
<groupId>org.onap.policy.gui.editors</groupId>
<artifactId>editors</artifactId>
- <version>2.2.1-SNAPSHOT</version>
+ <version>2.2.2-SNAPSHOT</version>
</parent>
<artifactId>gui-editor-apex</artifactId>
diff --git a/gui-editors/pom.xml b/gui-editors/pom.xml
index cc303af..c426c5f 100644
--- a/gui-editors/pom.xml
+++ b/gui-editors/pom.xml
@@ -22,7 +22,7 @@
<parent>
<groupId>org.onap.policy.gui</groupId>
<artifactId>policy-gui</artifactId>
- <version>2.2.1-SNAPSHOT</version>
+ <version>2.2.2-SNAPSHOT</version>
</parent>
<groupId>org.onap.policy.gui.editors</groupId>
diff --git a/gui-server/pom.xml b/gui-server/pom.xml
index 79c60d2..9b465ed 100644
--- a/gui-server/pom.xml
+++ b/gui-server/pom.xml
@@ -24,7 +24,7 @@
<parent>
<artifactId>policy-gui</artifactId>
<groupId>org.onap.policy.gui</groupId>
- <version>2.2.1-SNAPSHOT</version>
+ <version>2.2.2-SNAPSHOT</version>
</parent>
<artifactId>gui-server</artifactId>
<name>${project.artifactId}</name>
diff --git a/gui-server/src/test/java/org/onap/policy/gui/server/GuiServerAppMainTest.java b/gui-server/src/test/java/org/onap/policy/gui/server/GuiServerAppMainTest.java
new file mode 100644
index 0000000..d0f6598
--- /dev/null
+++ b/gui-server/src/test/java/org/onap/policy/gui/server/GuiServerAppMainTest.java
@@ -0,0 +1,41 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2022 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.gui.server;
+
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+
+import org.junit.jupiter.api.Test;
+
+/**
+ * In this test, we check that application can start via main() method.
+ */
+class GuiServerAppMainTest {
+
+ @Test
+ void whenMainIsCalled_thenNoExceptions() {
+ String[] args = {
+ "--server.port=0", // use random available port
+ "--clamp.url=https://clamp-backend:8443/",
+ "--clamp.disable-ssl-validation=true"
+ };
+ assertDoesNotThrow(() -> GuiServerApplication.main(args));
+ }
+}
diff --git a/gui-server/src/test/java/org/onap/policy/gui/server/config/ClampRestTemplateConfig6Test.java b/gui-server/src/test/java/org/onap/policy/gui/server/config/ClampRestTemplateConfig6Test.java
new file mode 100644
index 0000000..d1d3072
--- /dev/null
+++ b/gui-server/src/test/java/org/onap/policy/gui/server/config/ClampRestTemplateConfig6Test.java
@@ -0,0 +1,57 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2022 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.gui.server.config;
+
+import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
+
+import org.junit.jupiter.api.Test;
+import org.onap.policy.gui.server.test.util.hello.HelloWorldApplication;
+import org.springframework.beans.factory.BeanCreationException;
+import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.ApplicationContext;
+import org.springframework.test.util.ReflectionTestUtils;
+
+/**
+ * In this test, server.ssl.trust-store is unset while SSL validation is enabled.
+ * An BeanCreationException should be thrown on application startup.
+ */
+@SpringBootTest(
+ classes = { HelloWorldApplication.class }
+)
+class ClampRestTemplateConfig6Test {
+
+ @Test
+ void expectExceptionWithNoTrustStore(ApplicationContext context) {
+ // Manually autowire the bean so we can test PostConstruct logic.
+ ClampRestTemplateConfig restTemplateConfig = new ClampRestTemplateConfig();
+ AutowireCapableBeanFactory factory = context.getAutowireCapableBeanFactory();
+ factory.autowireBean(restTemplateConfig);
+
+ // Enable SSL validation, but provide no trust store.
+ ReflectionTestUtils.setField(restTemplateConfig, "disableSslValidation", false);
+
+ // Expect exception when creating bean.
+ assertThatExceptionOfType(BeanCreationException.class)
+ .isThrownBy(() -> factory.initializeBean(restTemplateConfig, "clampRestTemplate"))
+ .withMessageContaining("server.ssl.trust-store must be set");
+ }
+}
diff --git a/gui-server/src/test/java/org/onap/policy/gui/server/filters/ClientSslHeaderFilterTest.java b/gui-server/src/test/java/org/onap/policy/gui/server/filters/ClientSslHeaderFilterTest.java
index 5fc026d..fb56fbc 100644
--- a/gui-server/src/test/java/org/onap/policy/gui/server/filters/ClientSslHeaderFilterTest.java
+++ b/gui-server/src/test/java/org/onap/policy/gui/server/filters/ClientSslHeaderFilterTest.java
@@ -27,12 +27,14 @@
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
import static org.onap.policy.gui.server.filters.ClientSslHeaderFilter.SSL_CERT_HEADER_NAME;
import static org.onap.policy.gui.server.filters.ClientSslHeaderFilter.X509_ATTRIBUTE_NAME;
import static org.onap.policy.gui.server.util.X509CertificateEncoder.urlDecodeCert;
import java.io.IOException;
+import java.security.cert.CertificateEncodingException;
import java.security.cert.X509Certificate;
import java.util.Collections;
import java.util.Enumeration;
@@ -118,6 +120,29 @@
}
/*
+ * If there is a CertificateEncodingException, the filter should not set
+ * the X-SSL-Cert header.
+ */
+ @Test
+ void testInvalidClientCert_noHeader() throws Exception {
+ // Create an invalid cert.
+ X509Certificate invalidCert = mock(X509Certificate.class);
+ doThrow(CertificateEncodingException.class).when(invalidCert).getEncoded();
+
+ // Create a request with an invalid client SSL cert.
+ MockHttpServletRequest inRequest = new MockHttpServletRequest();
+ inRequest.setAttribute(X509_ATTRIBUTE_NAME, new X509Certificate[] { invalidCert });
+
+ // Apply the filter.
+ HttpServletRequest outRequest = applyRequestFilter(inRequest);
+
+ // The modified request should not contain a cert header.
+ assertFalse(containsCertHeader(outRequest.getHeaderNames()));
+ assertNull(outRequest.getHeader(SSL_CERT_HEADER_NAME));
+ assertEquals(Collections.emptyEnumeration(), outRequest.getHeaders(SSL_CERT_HEADER_NAME));
+ }
+
+ /*
* This test is needed to prevent a security vulnerability where a
* malicious user does not authenticate using client cert, but defines the
* X-SSL-Cert header themselves, thus gaining access without having the
diff --git a/packages/policy-gui-docker/pom.xml b/packages/policy-gui-docker/pom.xml
index 7d56634..2fababc 100644
--- a/packages/policy-gui-docker/pom.xml
+++ b/packages/policy-gui-docker/pom.xml
@@ -26,7 +26,7 @@
<parent>
<groupId>org.onap.policy.gui</groupId>
<artifactId>gui-packages</artifactId>
- <version>2.2.1-SNAPSHOT</version>
+ <version>2.2.2-SNAPSHOT</version>
</parent>
<packaging>pom</packaging>
diff --git a/packages/pom.xml b/packages/pom.xml
index fa68935..3530c73 100644
--- a/packages/pom.xml
+++ b/packages/pom.xml
@@ -22,7 +22,7 @@
<parent>
<groupId>org.onap.policy.gui</groupId>
<artifactId>policy-gui</artifactId>
- <version>2.2.1-SNAPSHOT</version>
+ <version>2.2.2-SNAPSHOT</version>
</parent>
<artifactId>gui-packages</artifactId>
diff --git a/pom.xml b/pom.xml
index fbf65b0..af9047d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -26,13 +26,13 @@
<parent>
<groupId>org.onap.policy.parent</groupId>
<artifactId>integration</artifactId>
- <version>3.5.1</version>
+ <version>3.5.2-SNAPSHOT</version>
<relativePath />
</parent>
<groupId>org.onap.policy.gui</groupId>
<artifactId>policy-gui</artifactId>
- <version>2.2.1-SNAPSHOT</version>
+ <version>2.2.2-SNAPSHOT</version>
<packaging>pom</packaging>
@@ -40,9 +40,9 @@
<description>Code for all the Policy GUI's.</description>
<properties>
- <policy.apex-pdp.version>2.7.1</policy.apex-pdp.version>
- <policy.common.version>1.10.1</policy.common.version>
- <policy.models.version>2.6.1</policy.models.version>
+ <policy.apex-pdp.version>2.7.2-SNAPSHOT</policy.apex-pdp.version>
+ <policy.common.version>1.10.2-SNAPSHOT</policy.common.version>
+ <policy.models.version>2.6.2-SNAPSHOT</policy.models.version>
<jacoco.dataFile>${project.basedir}/../../target/code-coverage/jacoco-ut.exec</jacoco.dataFile>
<sonar.javascript.lcov.reportPaths>${project.basedir}/target/code-coverage/lcov.info</sonar.javascript.lcov.reportPaths>
</properties>
diff --git a/version.properties b/version.properties
index 71e8e44..76584ab 100644
--- a/version.properties
+++ b/version.properties
@@ -4,7 +4,7 @@
major=2
minor=2
-patch=1
+patch=2
base_version=${major}.${minor}.${patch}