aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/GuardTranslator.java4
-rw-r--r--applications/guard/src/test/java/org/onap/policy/xacml/pdp/application/guard/GuardPdpApplicationTest.java9
-rw-r--r--applications/guard/src/test/java/org/onap/policy/xacml/pdp/application/guard/GuardTranslatorTest.java2
3 files changed, 12 insertions, 3 deletions
diff --git a/applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/GuardTranslator.java b/applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/GuardTranslator.java
index 854f3260..8699fec0 100644
--- a/applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/GuardTranslator.java
+++ b/applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/GuardTranslator.java
@@ -492,13 +492,13 @@ public class GuardTranslator implements ToscaPolicyTranslator {
// treated as an OR.
//
TargetType target = new TargetType();
+ AnyOfType anyOf = new AnyOfType();
for (Object blacklisted : ((Collection<?>) arrayBlacklisted)) {
AllOfType allOf = new AllOfType();
this.addMatch(allOf, blacklisted, ToscaDictionary.ID_RESOURCE_GUARD_TARGETID);
- AnyOfType anyOf = new AnyOfType();
anyOf.getAllOf().add(allOf);
- target.getAnyOf().add(anyOf);
}
+ target.getAnyOf().add(anyOf);
//
// Create our rule and add the target
//
diff --git a/applications/guard/src/test/java/org/onap/policy/xacml/pdp/application/guard/GuardPdpApplicationTest.java b/applications/guard/src/test/java/org/onap/policy/xacml/pdp/application/guard/GuardPdpApplicationTest.java
index ac45cf39..f5392cfa 100644
--- a/applications/guard/src/test/java/org/onap/policy/xacml/pdp/application/guard/GuardPdpApplicationTest.java
+++ b/applications/guard/src/test/java/org/onap/policy/xacml/pdp/application/guard/GuardPdpApplicationTest.java
@@ -341,6 +341,15 @@ public class GuardPdpApplicationTest {
// vfcount=0 below min of 1: should get a Deny because target IS blacklisted
//
requestAndCheckDecision(requestVfCount, DENY);
+ //
+ // vfcount=1 between min of 1 and max of 2: change the
+ //
+ ((Map<String, Object>) requestVfCount.getResource().get("guard")).put("target",
+ "another-vfmodule-where-root-is-true");
+ //
+ // vfcount=0 below min of 1: should get a Deny because target IS blacklisted
+ //
+ requestAndCheckDecision(requestVfCount, DENY);
}
@SuppressWarnings("unchecked")
diff --git a/applications/guard/src/test/java/org/onap/policy/xacml/pdp/application/guard/GuardTranslatorTest.java b/applications/guard/src/test/java/org/onap/policy/xacml/pdp/application/guard/GuardTranslatorTest.java
index a48e3c93..d5dd16bf 100644
--- a/applications/guard/src/test/java/org/onap/policy/xacml/pdp/application/guard/GuardTranslatorTest.java
+++ b/applications/guard/src/test/java/org/onap/policy/xacml/pdp/application/guard/GuardTranslatorTest.java
@@ -301,7 +301,7 @@ public class GuardTranslatorTest {
continue;
}
assertThat(((RuleType) rule).getTarget()).isNotNull();
- assertThat(((RuleType) rule).getTarget().getAnyOf()).hasSize(2);
+ assertThat(((RuleType) rule).getTarget().getAnyOf()).hasSize(1);
for (AnyOfType anyOf : ((RuleType)rule).getTarget().getAnyOf()) {
assertThat(anyOf.getAllOf()).isNotEmpty();
for (AllOfType allOf : anyOf.getAllOf()) {