summaryrefslogtreecommitdiffstats
path: root/tutorials/tutorial-xacml-application/src/test
diff options
context:
space:
mode:
authorPamela Dragosh <pd1248@att.com>2021-07-21 10:58:13 -0400
committerPamela Dragosh <pd1248@att.com>2021-07-21 11:37:19 -0400
commitfe80c60ca766af048d7eb6f9bc073d40ee033046 (patch)
treec55029034b36c0e502a20c7d903f6b75af01b1cc /tutorials/tutorial-xacml-application/src/test
parentf01fce93c17db824d772240b9c68c07d15c6869a (diff)
Add attribute return example into Tutorial
Used the tutorial to demonstrate returning of attributes back into the Decision response. Needed to update the docker compose for both tutorials to ensure they are using the master branch versions of api and pap. Issue-ID: POLICY-2865 Change-Id: Ia568dfae27d659d940217ddf8d9295dd8409f0e3 Signed-off-by: Pamela Dragosh <pd1248@att.com>
Diffstat (limited to 'tutorials/tutorial-xacml-application/src/test')
-rw-r--r--tutorials/tutorial-xacml-application/src/test/java/org/onap/policy/tutorial/tutorial/TutorialApplicationTest.java18
1 files changed, 16 insertions, 2 deletions
diff --git a/tutorials/tutorial-xacml-application/src/test/java/org/onap/policy/tutorial/tutorial/TutorialApplicationTest.java b/tutorials/tutorial-xacml-application/src/test/java/org/onap/policy/tutorial/tutorial/TutorialApplicationTest.java
index 4fda0983..66001260 100644
--- a/tutorials/tutorial-xacml-application/src/test/java/org/onap/policy/tutorial/tutorial/TutorialApplicationTest.java
+++ b/tutorials/tutorial-xacml-application/src/test/java/org/onap/policy/tutorial/tutorial/TutorialApplicationTest.java
@@ -18,9 +18,11 @@
package org.onap.policy.tutorial.tutorial;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
import com.att.research.xacml.api.Response;
+import com.att.research.xacml.api.XACML3;
import java.io.File;
import java.io.IOException;
import java.util.Properties;
@@ -101,19 +103,31 @@ public class TutorialApplicationTest {
TextFileUtils
.getTextFileAsString("src/test/resources/tutorial-decision-request.json"),
DecisionRequest.class);
+ LOGGER.info("{}", gson.encode(decisionRequest, true));
//
// Test a decision - should start with a permit
//
Pair<DecisionResponse, Response> decision = service.makeDecision(decisionRequest, null);
- LOGGER.info(decision.getLeft().toString());
+ LOGGER.info("{}", gson.encode(decision.getLeft(), true));
assertEquals("Permit", decision.getLeft().getStatus());
//
+ // Check that there are attributes
+ //
+ assertThat(decision.getLeft().getAttributes()).isNotNull().hasSize(1)
+ .containsKey(XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE.stringValue());
+ //
// This should be a deny
//
decisionRequest.getResource().put("user", "audit");
+ LOGGER.info("{}", gson.encode(decisionRequest, true));
decision = service.makeDecision(decisionRequest, null);
- LOGGER.info(decision.getLeft().toString());
+ LOGGER.info("{}", gson.encode(decision.getLeft(), true));
assertEquals("Deny", decision.getLeft().getStatus());
+ //
+ // Check that there are attributes
+ //
+ assertThat(decision.getLeft().getAttributes()).isNotNull().hasSize(1)
+ .containsKey(XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE.stringValue());
}
}