diff options
author | Jim Hahn <jrh3@att.com> | 2019-06-05 11:00:21 -0400 |
---|---|---|
committer | Jim Hahn <jrh3@att.com> | 2019-06-05 12:00:42 -0400 |
commit | 9f41ede37c78dd5dcea1851e114b7bdf9a5df7a5 (patch) | |
tree | d5ae6c720dc9ead5f437a961ffcfc34bf7942cda /main/src/test/java | |
parent | ee3bea2552f89babf1b0e0ada286cc36bc6af105 (diff) |
Reject policy deployment with version mismatch
PAP should not allow multiple versions of a policy to be deployed
to the same PDP. Modified the code to reject deployment requests
where a different version of the policy is already deployed. This
impacts both the PDP-Group-Deploy and the Simple-Deploy REST APIs.
Change-Id: I586b764951c20228d0d80ec8326869215e970fdf
Issue-ID: POLICY-1785
Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'main/src/test/java')
-rw-r--r-- | main/src/test/java/org/onap/policy/pap/main/rest/depundep/TestPdpGroupDeployProvider.java | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/main/src/test/java/org/onap/policy/pap/main/rest/depundep/TestPdpGroupDeployProvider.java b/main/src/test/java/org/onap/policy/pap/main/rest/depundep/TestPdpGroupDeployProvider.java index 6d193fef..7590c645 100644 --- a/main/src/test/java/org/onap/policy/pap/main/rest/depundep/TestPdpGroupDeployProvider.java +++ b/main/src/test/java/org/onap/policy/pap/main/rest/depundep/TestPdpGroupDeployProvider.java @@ -522,6 +522,25 @@ public class TestPdpGroupDeployProvider extends ProviderSuper { } @Test + public void testUpdateSubGroup_PolicyVersionMismatch() throws Exception { + PdpGroups groups = loadPdpGroups("createGroups.json"); + PdpGroup newgrp = groups.getGroups().get(0); + PdpGroup dbgroup = new PdpGroup(newgrp); + when(dao.getPdpGroups(dbgroup.getName())).thenReturn(Arrays.asList(dbgroup)); + + // arrange for DB policy version to be different + PdpSubGroup dbsubgrp = dbgroup.getPdpSubgroups().get(0); + dbsubgrp.getPolicies().get(0).setVersion("9.9.9"); + + when(dao.getFilteredPolicyList(any())).thenReturn(loadPolicies("daoPolicyList.json")); + + assertThatThrownBy(() -> prov.createOrUpdateGroups(groups)).isInstanceOf(PfModelException.class) + .hasMessageContaining("different version already deployed"); + + assertNoGroupAction(); + } + + @Test public void testValidateSubGroup_PropertiesMismatch() throws Exception { PdpGroups groups = loadPdpGroups("createGroups.json"); PdpGroup newgrp = groups.getGroups().get(0); @@ -604,6 +623,20 @@ public class TestPdpGroupDeployProvider extends ProviderSuper { } @Test + public void testMakeUpdater_PolicyVersionMismatch() throws Exception { + + // subgroup has a different version of the Policy + when(dao.getFilteredPdpGroups(any())).thenReturn(loadGroups("upgradeGroupDao_DiffVers.json")); + + assertThatThrownBy(() -> prov.deployPolicies(loadRequest())).isInstanceOf(PfModelRuntimeException.class) + .hasMessageContaining("pdpTypeC").hasMessageContaining("different version already deployed"); + + verify(dao, never()).createPdpGroups(any()); + verify(dao, never()).updatePdpGroups(any()); + verify(reqmap, never()).addRequest(any(PdpUpdate.class)); + } + + @Test public void testMakeUpdater_NoPdps() throws Exception { // subgroup has no PDPs |