summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--BRMSGateway/pom.xml16
-rw-r--r--ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/components/MicroServicePolicyTest.java64
-rw-r--r--ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/handler/DeleteHandlerTest.java114
-rw-r--r--ONAP-SDK-APP/pom.xml14
-rw-r--r--ONAP-SDK-APP/src/test/java/org/onap/portalapp/login/LoginStrategyImplTest.java39
-rw-r--r--ONAP-SDK-APP/src/test/java/org/onap/portalapp/scheduler/RegisterTest.java57
-rw-r--r--ONAP-SDK-APP/src/test/java/org/onap/portalapp/scheduler/RegistryAdapterTest.java68
-rw-r--r--packages/docker/src/main/docker/Dockerfile31
-rw-r--r--pom.xml27
9 files changed, 394 insertions, 36 deletions
diff --git a/BRMSGateway/pom.xml b/BRMSGateway/pom.xml
index 39e943be1..0d9ebfba2 100644
--- a/BRMSGateway/pom.xml
+++ b/BRMSGateway/pom.xml
@@ -66,10 +66,26 @@
<artifactId>integrity-monitor</artifactId>
<version>${project.version}</version>
</dependency>
+ <!--
+ CLM security fix - force use of commons-collections 3.2.2.
+ Remove this if a new version of nexus-rest-client-java is upgraded
+ to not use velocity (and then subsequently commons-collections v3.1
+ -->
+ <dependency>
+ <groupId>commons-collections</groupId>
+ <artifactId>commons-collections</artifactId>
+ <version>3.2.2</version>
+ </dependency>
<dependency>
<groupId>org.sonatype.nexus</groupId>
<artifactId>nexus-rest-client-java</artifactId>
<version>2.3.1-01</version>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-collections</groupId>
+ <artifactId>commons-collections</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>com.thoughtworks.xstream</groupId>
diff --git a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/components/MicroServicePolicyTest.java b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/components/MicroServicePolicyTest.java
index e99debd1e..fa4bd20f5 100644
--- a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/components/MicroServicePolicyTest.java
+++ b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/components/MicroServicePolicyTest.java
@@ -19,15 +19,28 @@
*/
package org.onap.policy.pap.xacml.rest.components;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.fail;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.when;
+import static org.mockito.Matchers.any;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.fail;
-import org.junit.Ignore;
+import org.junit.runner.RunWith;
+import org.mockito.Mockito;
+import org.onap.policy.pap.xacml.rest.daoimpl.CommonClassDaoImpl;
import org.onap.policy.rest.adapter.PolicyRestAdapter;
-import com.att.research.xacml.api.pap.PAPException;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+import java.io.File;
+import java.util.Collections;
+@RunWith(PowerMockRunner.class)
+@PrepareForTest({MicroServiceConfigPolicy.class, CreateNewMicroServiceModel.class})
public class MicroServicePolicyTest {
@Rule
public ExpectedException thrown = ExpectedException.none();
@@ -47,10 +60,13 @@ public class MicroServicePolicyTest {
assertNull(policy.getCorrectPolicyDataObject());
}
- @Ignore
@Test
- public void testPrepareToSave() throws PAPException {
- thrown.expect(NullPointerException.class);
+ public void testPrepareToSave() throws Exception {
+ // Need to mock internal dictionary retrieval
+ CommonClassDaoImpl impl = Mockito.mock(CommonClassDaoImpl.class);
+ PowerMockito.whenNew(CommonClassDaoImpl.class).withNoArguments().thenReturn(impl);
+ when(impl.getDataById(any(), anyString(), anyString())).thenReturn(null);
+
PolicyRestAdapter policyAdapter = new PolicyRestAdapter();
MicroServiceConfigPolicy policy = new MicroServiceConfigPolicy(policyAdapter);
policyAdapter.setHighestVersion(1);
@@ -59,6 +75,36 @@ public class MicroServicePolicyTest {
policyAdapter.setJsonBody("{ \"version\": \"1.0\"}");
policyAdapter.setServiceType("foo");
policy.prepareToSave();
- fail("Expected an exception");
+ assertEquals(policy.isPreparedToSave(), true);
+ }
+
+ @Test
+ public void testCreateConstructor1() {
+ CreateNewMicroServiceModel model = new CreateNewMicroServiceModel(null, null, null, null);
+ assertNotNull(model);
+ }
+
+ @Test
+ public void testCreateModel() throws Exception {
+ // Mock file retrieval
+ File testFile = new File("testFile");
+ File[] testList = new File[1];
+ testList[0] = testFile;
+ File impl = Mockito.mock(File.class);
+ PowerMockito.whenNew(File.class).withAnyArguments().thenReturn(impl);
+ when(impl.listFiles()).thenReturn(testList);
+ when(impl.isFile()).thenReturn(true);
+
+ // Mock internal dictionary retrieval
+ CommonClassDaoImpl daoImpl = Mockito.mock(CommonClassDaoImpl.class);
+ PowerMockito.whenNew(CommonClassDaoImpl.class).withNoArguments().thenReturn(daoImpl);
+ when(daoImpl.getDataById(any(), anyString(), anyString())).thenReturn(Collections.emptyList());
+
+ // Test create methods
+ String testFileName = "testFile.zip";
+ String testVal = "testVal";
+ CreateNewMicroServiceModel model = new CreateNewMicroServiceModel(testFileName, testVal, testVal, testVal, testVal);
+ model.addValuesToNewModel();
+ model.saveImportService();
}
-} \ No newline at end of file
+}
diff --git a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/handler/DeleteHandlerTest.java b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/handler/DeleteHandlerTest.java
new file mode 100644
index 000000000..9e9da17a5
--- /dev/null
+++ b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/handler/DeleteHandlerTest.java
@@ -0,0 +1,114 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP-PAP-REST
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. 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=========================================================
+ */
+
+package org.onap.policy.pap.xacml.rest.handler;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.fail;
+import static org.mockito.Mockito.when;
+import static org.mockito.Matchers.any;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mockito;
+import org.onap.policy.common.logging.ONAPLoggingContext;
+import org.onap.policy.pap.xacml.rest.XACMLPapServlet;
+import org.onap.policy.pap.xacml.rest.elk.client.PolicyElasticSearchController;
+import org.onap.policy.rest.jpa.PolicyEntity;
+import org.onap.policy.xacml.api.pap.PAPPolicyEngine;
+import org.onap.policy.xacml.std.pap.StdEngine;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+import com.mockrunner.mock.web.MockHttpServletRequest;
+import com.mockrunner.mock.web.MockHttpServletResponse;
+import java.sql.Connection;
+import java.util.Collections;
+import java.util.List;
+import javax.persistence.EntityManager;
+
+@RunWith(PowerMockRunner.class)
+@PrepareForTest({DeleteHandler.class, XACMLPapServlet.class})
+public class DeleteHandlerTest {
+ @Test
+ public void testGets() {
+ DeleteHandler handler = new DeleteHandler();
+ assertNotNull(handler);
+ assertEquals(handler.preSafetyCheck(null), true);
+ assertNull(handler.getDeletedGroup());
+ }
+
+ @Test
+ public void testGetInstance() {
+ DeleteHandler handler = DeleteHandler.getInstance();
+ assertNotNull(handler);
+ }
+
+ @Test
+ public void testDeletes() throws Exception {
+ // Mock request
+ DeleteHandler handler = new DeleteHandler();
+ MockHttpServletRequest request = new MockHttpServletRequest();
+ request.setBodyContent("{\n\"PAPPolicyType\": \"StdPAPPolicy\"\n}\n");
+
+ // Mock servlet
+ PAPPolicyEngine engine = Mockito.mock(StdEngine.class);
+ PowerMockito.mockStatic(XACMLPapServlet.class);
+ when(XACMLPapServlet.getPAPEngine()).thenReturn(engine);
+ when(engine.getGroup(any())).thenReturn(null);
+
+ // Mock elastic search
+ PolicyElasticSearchController controller = Mockito.mock(PolicyElasticSearchController.class);
+ PowerMockito.whenNew(PolicyElasticSearchController.class).withNoArguments().thenReturn(controller);
+
+ // Mock entity manager
+ EntityManager em = Mockito.mock(EntityManager.class);
+
+ // Test deletion from PAP
+ MockHttpServletResponse response = new MockHttpServletResponse();
+ try {
+ handler.doAPIDeleteFromPAP(request, response);
+ }
+ catch (Exception ex) {
+ fail("Not expecting an exception: " + ex);
+ }
+
+ // Test deletion from PDP
+ ONAPLoggingContext loggingContext = Mockito.mock(ONAPLoggingContext.class);
+ try {
+ handler.doAPIDeleteFromPDP(request, response, loggingContext);
+ }
+ catch (Exception ex) {
+ fail("Not expecting an exception: " + ex);
+ }
+
+ // Test delete entity
+ PolicyEntity policyEntity = new PolicyEntity();
+ policyEntity.setPolicyName("testVal");
+ String result = DeleteHandler.deletePolicyEntityData(em, policyEntity);
+ assertEquals(result, "success");
+
+ // Test check entity
+ Connection con = null;
+ List<?> peResult = Collections.emptyList();
+ assertEquals(DeleteHandler.checkPolicyGroupEntity(con, peResult), false);
+ }
+}
diff --git a/ONAP-SDK-APP/pom.xml b/ONAP-SDK-APP/pom.xml
index c1ce21e4f..687e5b3a2 100644
--- a/ONAP-SDK-APP/pom.xml
+++ b/ONAP-SDK-APP/pom.xml
@@ -238,6 +238,16 @@
<type>jar</type>
</dependency>
<!-- SDK components -->
+ <!--
+ CLM security fix - force use of commons-collections 3.2.2.
+ Remove this if a new version of epsdk-core is upgraded
+ to not use esapi (and then subsequently commons-collections v3.2
+ -->
+ <dependency>
+ <groupId>commons-collections</groupId>
+ <artifactId>commons-collections</artifactId>
+ <version>3.2.2</version>
+ </dependency>
<dependency>
<groupId>org.onap.portal.sdk</groupId>
<artifactId>epsdk-core</artifactId>
@@ -247,6 +257,10 @@
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</exclusion>
+ <exclusion>
+ <groupId>commons-collections</groupId>
+ <artifactId>commons-collections</artifactId>
+ </exclusion>
</exclusions>
</dependency>
<dependency>
diff --git a/ONAP-SDK-APP/src/test/java/org/onap/portalapp/login/LoginStrategyImplTest.java b/ONAP-SDK-APP/src/test/java/org/onap/portalapp/login/LoginStrategyImplTest.java
new file mode 100644
index 000000000..25b677988
--- /dev/null
+++ b/ONAP-SDK-APP/src/test/java/org/onap/portalapp/login/LoginStrategyImplTest.java
@@ -0,0 +1,39 @@
+/*-
+ * ================================================================================
+ * ONAP Portal SDK
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property
+ * ================================================================================
+ * 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.
+ * ================================================================================
+ */
+
+package org.onap.portalapp.login;
+
+import static org.junit.Assert.assertNull;
+import javax.servlet.http.Cookie;
+import org.junit.Test;
+import org.onap.portalsdk.core.onboarding.exception.PortalAPIException;
+import org.springframework.mock.web.MockHttpServletRequest;
+
+public class LoginStrategyImplTest {
+ @Test
+ public void testLoginStrategyImpl() throws PortalAPIException {
+ LoginStrategyImpl impl = new LoginStrategyImpl();
+ MockHttpServletRequest request = new MockHttpServletRequest();
+ Cookie cookie1 = new Cookie("EPService", "serviceName");
+ Cookie cookie2 = new Cookie("UserId", "userName");
+ request.setCookies(cookie1, cookie2);
+ assertNull(impl.getUserId(request));
+ }
+}
diff --git a/ONAP-SDK-APP/src/test/java/org/onap/portalapp/scheduler/RegisterTest.java b/ONAP-SDK-APP/src/test/java/org/onap/portalapp/scheduler/RegisterTest.java
new file mode 100644
index 000000000..ec7724c07
--- /dev/null
+++ b/ONAP-SDK-APP/src/test/java/org/onap/portalapp/scheduler/RegisterTest.java
@@ -0,0 +1,57 @@
+/*-
+ * ================================================================================
+ * ONAP Portal SDK
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property
+ * ================================================================================
+ * 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.
+ * ================================================================================
+ */
+
+package org.onap.portalapp.scheduler;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+import java.util.ArrayList;
+import java.util.List;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.quartz.Trigger;
+import org.quartz.TriggerBuilder;
+
+public class RegisterTest {
+ @Rule
+ public final ExpectedException thrown = ExpectedException.none();
+
+ @Test
+ public void testRegister() {
+ Register register = new Register();
+ TriggerBuilder<Trigger> triggerBuilder = TriggerBuilder.newTrigger();
+ Trigger trigger = triggerBuilder.build();
+ List<Trigger> triggers = new ArrayList<Trigger>();
+ triggers.add(trigger);
+
+ register.setScheduleTriggers(triggers);
+ assertEquals(register.getScheduleTriggers(), triggers);
+ assertEquals(register.getTriggers().length, 1);
+ }
+
+ @Test
+ public void testRegisterNegativeCase() {
+ thrown.expect(NullPointerException.class);
+ Register register = new Register();
+ register.registerTriggers();
+ fail("Expecting an exception.");
+ }
+}
diff --git a/ONAP-SDK-APP/src/test/java/org/onap/portalapp/scheduler/RegistryAdapterTest.java b/ONAP-SDK-APP/src/test/java/org/onap/portalapp/scheduler/RegistryAdapterTest.java
new file mode 100644
index 000000000..b49ad6a6d
--- /dev/null
+++ b/ONAP-SDK-APP/src/test/java/org/onap/portalapp/scheduler/RegistryAdapterTest.java
@@ -0,0 +1,68 @@
+/*-
+ * ================================================================================
+ * ONAP Portal SDK
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property
+ * ================================================================================
+ * 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.
+ * ================================================================================
+ */
+
+package org.onap.portalapp.scheduler;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.onap.portalsdk.core.scheduler.Registerable;
+import org.onap.portalsdk.workflow.services.WorkflowScheduleService;
+import org.springframework.scheduling.quartz.SchedulerFactoryBean;
+
+public class RegistryAdapterTest {
+ @Rule
+ public final ExpectedException thrown = ExpectedException.none();
+
+ @Test
+ public void testRegistryAdapter() {
+ RegistryAdapter adapter = new RegistryAdapter();
+ SchedulerFactoryBean schedulerBean = new SchedulerFactoryBean();
+ Registerable registry = null;
+ WorkflowScheduleService workflowScheduleService = null;
+
+ adapter.setSchedulerBean(schedulerBean);
+ assertEquals(adapter.getSchedulerBean(), schedulerBean);
+ adapter.setRegistry(registry);
+ assertEquals(adapter.getRegistry(), registry);
+ adapter.setWorkflowScheduleService(workflowScheduleService);
+ assertEquals(adapter.getWorkflowScheduleService(), workflowScheduleService);
+ }
+
+ @Test
+ public void testRegistryAdapterNegCase1() {
+ thrown.expect(NullPointerException.class);
+
+ RegistryAdapter adapter = new RegistryAdapter();
+ adapter.getTriggers();
+ fail("Expecting an exception.");
+ }
+
+ @Test
+ public void testRegistryAdapterNegCase2() {
+ thrown.expect(NullPointerException.class);
+
+ RegistryAdapter adapter = new RegistryAdapter();
+ adapter.addCoreTriggers();
+ fail("Expecting an exception.");
+ }
+}
diff --git a/packages/docker/src/main/docker/Dockerfile b/packages/docker/src/main/docker/Dockerfile
index fe568082d..b0e8205a6 100644
--- a/packages/docker/src/main/docker/Dockerfile
+++ b/packages/docker/src/main/docker/Dockerfile
@@ -1,4 +1,33 @@
-FROM onap/policy/policy-base
+FROM ubuntu:14.04
+
+ARG HTTP_PROXY=${HTTP_PROXY}
+ARG HTTPS_PROXY=${HTTPS_PROXY}
+
+ENV http_proxy $HTTP_PROXY
+ENV https_proxy $HTTPS_PROXY
+
+RUN \
+ apt-get clean && \
+ apt-get update && \
+ apt-get install -y zip unzip curl wget ssh telnet maven && \
+ apt-get install -y software-properties-common && \
+ apt-get install -y jq httpie && \
+ apt-get install -y python-pip && \
+ add-apt-repository ppa:openjdk-r/ppa && \
+ apt-get clean && \
+ apt-get update && \
+ apt-get install -y openjdk-8-jdk
+
+RUN useradd --create-home --shell /bin/bash policy
+
+# install MariaDB client
+RUN \
+ apt-get install -y apt-transport-https && \
+ apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xcbcb082a1bb943db && \
+ add-apt-repository 'deb [arch=amd64,i386,ppc64el] http://ftp.osuosl.org/pub/mariadb/repo/10.0/ubuntu trusty main' && \
+ apt-get clean && \
+ apt-get update && \
+ apt-get install -y mariadb-client
RUN mkdir -p /opt/app/policy /tmp/policy-install && chown policy /opt/app/policy /tmp/policy-install
diff --git a/pom.xml b/pom.xml
index eba1c0471..53388550a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -67,7 +67,7 @@
<!-- Project common dependency versions -->
<jetty.plugin.version>9.2.3.v20140905</jetty.plugin.version>
- <dmaap.version>1.0.0</dmaap.version>
+ <dmaap.version>1.1.3-SNAPSHOT</dmaap.version>
<httpclient.version>4.5.5</httpclient.version>
<jackson.version>2.9.4</jackson.version>
<commons.fileupload.version>1.3.3</commons.fileupload.version>
@@ -107,31 +107,6 @@
</site>
</distributionManagement>
- <repositories>
- <!-- LF repositories -->
- <repository>
- <id>ecomp-releases</id>
- <name>Release Repository</name>
- <url>${nexusproxy}/content/repositories/releases/</url>
- </repository>
- <repository>
- <id>ecomp-staging</id>
- <name>Staging Repository</name>
- <url>${nexusproxy}/content/repositories/staging/</url>
- </repository>
- <repository>
- <id>ecomp-snapshots</id>
- <name>Snapshots Repository</name>
- <url>${nexusproxy}/content/repositories/snapshots/</url>
- </repository>
- <repository>
- <id>ecomp-public</id>
- <name>Public Repository</name>
- <url>${nexusproxy}/content/repositories/public/</url>
- </repository>
- <!-- LF repositories END-->
- </repositories>
-
<reporting>
<plugins>
<plugin>