summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--controlloop/common/simulators/pom.xml6
-rw-r--r--controlloop/common/simulators/src/test/java/org/onap/policy/simulators/GuardSimulatorTest.java39
-rw-r--r--controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl26
3 files changed, 22 insertions, 49 deletions
diff --git a/controlloop/common/simulators/pom.xml b/controlloop/common/simulators/pom.xml
index 89b62cf05..61cffb440 100644
--- a/controlloop/common/simulators/pom.xml
+++ b/controlloop/common/simulators/pom.xml
@@ -57,12 +57,6 @@
<scope>provided</scope>
</dependency>
<dependency>
- <groupId>org.onap.policy.drools-applications</groupId>
- <artifactId>guard</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>org.onap.policy.drools-applications</groupId>
<artifactId>vfc</artifactId>
<version>${project.version}</version>
diff --git a/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/GuardSimulatorTest.java b/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/GuardSimulatorTest.java
index 696e2a60d..86e2c8cf9 100644
--- a/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/GuardSimulatorTest.java
+++ b/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/GuardSimulatorTest.java
@@ -24,12 +24,11 @@ import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.onap.policy.drools.http.server.HttpServletServer;
-import org.onap.policy.drools.system.PolicyEngine;
import org.onap.policy.drools.utils.LoggerUtil;
-import org.onap.policy.guard.PolicyGuardXacmlHelper;
-import org.onap.policy.guard.PolicyGuardXacmlRequestAttributes;
-import org.onap.policy.guard.Util;
+import org.onap.policy.rest.RESTManager;
+import org.onap.policy.rest.RESTManager.Pair;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
@@ -44,16 +43,6 @@ public class GuardSimulatorTest {
} catch (Exception e) {
fail(e.getMessage());
}
- //
- // Set guard properties
- //
- org.onap.policy.guard.Util.setGuardEnvProps("http://localhost:6669/pdp/api/getDecision",
- "python",
- "test",
- "python",
- "test",
- "TEST");
-
}
@AfterClass
@@ -63,8 +52,24 @@ public class GuardSimulatorTest {
@Test
public void testGuard() {
- PolicyGuardXacmlRequestAttributes request = new PolicyGuardXacmlRequestAttributes("clname_id", "actor_id", "operation_id", "target_id", "request_id");
- String xacmlResponse = new PolicyGuardXacmlHelper().callPDP(request);
- assertNotNull(xacmlResponse);
+ String request = makeRequest("test_actor_id", "test_op_id", "test_target", "test_clName");
+ String url = "http://localhost:" + Util.GUARDSIM_SERVER_PORT + "/pdp/api/getDecision";
+ Pair<Integer, String> response = RESTManager.post(url, "testUname", "testPass", null, "application/json", request);
+ assertNotNull(response);
+ assertNotNull(response.a);
+ assertNotNull(response.b);
+ assertEquals("{\"decision\": \"PERMIT\", \"details\": \"Decision Permit. OK!\"}", response.b);
+
+ request = makeRequest("test_actor_id", "test_op_id", "test_target", "denyGuard");
+ response = RESTManager.post(url, "testUname", "testPass", null, "application/json", request);
+ assertNotNull(response);
+ assertNotNull(response.a);
+ assertNotNull(response.b);
+ assertEquals("{\"decision\": \"DENY\", \"details\": \"Decision Deny. You asked for it\"}", response.b);
+ }
+
+ private static String makeRequest (String actor, String recipe, String target, String clName) {
+ return "{\"decisionAttributes\": {\"actor\": \"" + actor + "\", \"recipe\": \"" + recipe + "\""
+ + ", \"target\": \"" + target + "\", \"clname\": \"" + clName + "\"}, \"onapName\": \"PDPD\"}";
}
}
diff --git a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl b/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl
index 07c7e2086..6d7ecdb89 100644
--- a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl
+++ b/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl
@@ -135,32 +135,6 @@ rule "${policyName}.SETUP"
Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
logger.info("{}: {} : YAML=[{}]", params.getClosedLoopControlName(), drools.getRule().getName(), params.getControlLoopYaml());
-
- String sqlDbUsername = PolicyEngine.manager.getEnvironmentProperty("sql.db.username");
-
- String aaiUrl = PolicyEngine.manager.getEnvironmentProperty("aai.url");
- String aaiUsername = PolicyEngine.manager.getEnvironmentProperty("aai.username");
- String aaiPassword = PolicyEngine.manager.getEnvironmentProperty("aai.password");
-
- String soUrl =PolicyEngine.manager.getEnvironmentProperty("so.url");
- String soUsername = PolicyEngine.manager.getEnvironmentProperty("so.username");
- String soPassword = PolicyEngine.manager.getEnvironmentProperty("so.password");
-
- String vfcUrl =PolicyEngine.manager.getEnvironmentProperty("vfc.url");
- String vfcUsername = PolicyEngine.manager.getEnvironmentProperty("vfc.username");
- String vfcPassword = PolicyEngine.manager.getEnvironmentProperty("vfc.password");
-
- String guardUrl = PolicyEngine.manager.getEnvironmentProperty("guard.url");
- String guardUsername = PolicyEngine.manager.getEnvironmentProperty("pdpx.username");
- String guardPassword = PolicyEngine.manager.getEnvironmentProperty("pdpx.password");
- String guardJdbcUrl = PolicyEngine.manager.getEnvironmentProperty("guard.jdbc.url");
- String guardDisabled = PolicyEngine.manager.getEnvironmentProperty("guard.disabled");
-
- logger.info("{}: {} : AAI=[{}:{}]", params.getClosedLoopControlName(), drools.getRule().getName(), aaiUrl, aaiUsername);
- logger.info("{}: {} : SO=[{}:{}]", params.getClosedLoopControlName(), drools.getRule().getName(), soUrl, soUsername);
- logger.info("{}: {} : VFC=[{}:{}]", params.getClosedLoopControlName(), drools.getRule().getName(), vfcUrl, vfcUsername);
- logger.info("{}: {} : GUARD=[{}:{}:{}:{}]", params.getClosedLoopControlName(), drools.getRule().getName(), guardUrl, guardUsername, guardJdbcUrl, guardDisabled);
- logger.info("{}: {} : DB=[{}]", params.getClosedLoopControlName(), drools.getRule().getName(), sqlDbUsername);
end
/*