summaryrefslogtreecommitdiffstats
path: root/ECOMP-XACML
diff options
context:
space:
mode:
Diffstat (limited to 'ECOMP-XACML')
-rw-r--r--ECOMP-XACML/pom.xml2
-rw-r--r--ECOMP-XACML/src/main/java/org/openecomp/policy/xacml/std/pap/StdPDPGroup.java4
-rw-r--r--ECOMP-XACML/src/test/java/org/openecomp/policy/xacml/test/TestAnnotation.java2
-rw-r--r--ECOMP-XACML/src/test/java/org/openecomp/policy/xacml/test/TestBase.java2
-rw-r--r--ECOMP-XACML/src/test/java/org/openecomp/policy/xacml/test/TestPolicy.java4
-rw-r--r--ECOMP-XACML/src/test/java/org/openecomp/policy/xacml/test/json/ResponseConformanceTest.java113
-rw-r--r--ECOMP-XACML/testsets/conformance/xacml3.0-ct-v.0.4/IIA001Response.xml14
7 files changed, 73 insertions, 68 deletions
diff --git a/ECOMP-XACML/pom.xml b/ECOMP-XACML/pom.xml
index 1694f6860..30720e9fc 100644
--- a/ECOMP-XACML/pom.xml
+++ b/ECOMP-XACML/pom.xml
@@ -61,7 +61,7 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
- <version>2.6.9</version>
+ <version>2.7.22</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
diff --git a/ECOMP-XACML/src/main/java/org/openecomp/policy/xacml/std/pap/StdPDPGroup.java b/ECOMP-XACML/src/main/java/org/openecomp/policy/xacml/std/pap/StdPDPGroup.java
index 46bb73b16..1a52dcb73 100644
--- a/ECOMP-XACML/src/main/java/org/openecomp/policy/xacml/std/pap/StdPDPGroup.java
+++ b/ECOMP-XACML/src/main/java/org/openecomp/policy/xacml/std/pap/StdPDPGroup.java
@@ -642,6 +642,10 @@ public class StdPDPGroup extends StdPDPItemSetChangeNotifier implements EcompPDP
}
public boolean removePolicyFromGroup(PDPPolicy policy) {
+ PolicyLogger.info("policy: " + policy.getId());
+ PolicyLogger.info("Policy ID:" + policy.getPolicyId());
+ PolicyLogger.info("Policy Version: " + policy.getVersion());
+ PolicyLogger.info("StdPDPPolicy Class cast: " + this.getPolicy(policy.getId()).toString());
StdPDPPolicy currentPolicy = (StdPDPPolicy) this.getPolicy(policy.getId());
if (currentPolicy == null) {
PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE + "Policy " + policy.getId() + " does not exist.");
diff --git a/ECOMP-XACML/src/test/java/org/openecomp/policy/xacml/test/TestAnnotation.java b/ECOMP-XACML/src/test/java/org/openecomp/policy/xacml/test/TestAnnotation.java
index c5dda8a91..7b45fb7bf 100644
--- a/ECOMP-XACML/src/test/java/org/openecomp/policy/xacml/test/TestAnnotation.java
+++ b/ECOMP-XACML/src/test/java/org/openecomp/policy/xacml/test/TestAnnotation.java
@@ -220,7 +220,7 @@ public class TestAnnotation extends TestBase {
}
} catch (IllegalArgumentException | IllegalAccessException | DataTypeException | IOException e) {
logger.error(e);
- e.printStackTrace();
+ logger.error("Exception Occured"+e);
}
}
diff --git a/ECOMP-XACML/src/test/java/org/openecomp/policy/xacml/test/TestBase.java b/ECOMP-XACML/src/test/java/org/openecomp/policy/xacml/test/TestBase.java
index 8f757ab59..ef87b6796 100644
--- a/ECOMP-XACML/src/test/java/org/openecomp/policy/xacml/test/TestBase.java
+++ b/ECOMP-XACML/src/test/java/org/openecomp/policy/xacml/test/TestBase.java
@@ -494,7 +494,7 @@ public class TestBase extends SimpleFileVisitor<Path> {
this.sendRequest(file, group);
} catch (Exception e) {
logger.error(e);
- e.printStackTrace();
+ logger.error("Exception Occured"+e);
}
}
return super.visitFile(file, attrs);
diff --git a/ECOMP-XACML/src/test/java/org/openecomp/policy/xacml/test/TestPolicy.java b/ECOMP-XACML/src/test/java/org/openecomp/policy/xacml/test/TestPolicy.java
index 983855900..11601f278 100644
--- a/ECOMP-XACML/src/test/java/org/openecomp/policy/xacml/test/TestPolicy.java
+++ b/ECOMP-XACML/src/test/java/org/openecomp/policy/xacml/test/TestPolicy.java
@@ -529,7 +529,7 @@ public class TestPolicy extends TestBase {
}
} catch (Exception e) {
logger.error(e);
- e.printStackTrace();
+ logger.error("Exception Occured"+e);
}
}
return super.visitFile(file, attrs);
@@ -738,7 +738,7 @@ public class TestPolicy extends TestBase {
}
// }
} catch (Exception e) {
- e.printStackTrace();
+ logger.error("Exception Occured"+e);
}
count++;
diff --git a/ECOMP-XACML/src/test/java/org/openecomp/policy/xacml/test/json/ResponseConformanceTest.java b/ECOMP-XACML/src/test/java/org/openecomp/policy/xacml/test/json/ResponseConformanceTest.java
index 601a4629b..e3c3b218a 100644
--- a/ECOMP-XACML/src/test/java/org/openecomp/policy/xacml/test/json/ResponseConformanceTest.java
+++ b/ECOMP-XACML/src/test/java/org/openecomp/policy/xacml/test/json/ResponseConformanceTest.java
@@ -53,35 +53,31 @@ import com.att.research.xacml.util.ListUtil;
*
*/
public class ResponseConformanceTest {
-
+
// where to find the conformance test XML files
private final String CONFORMANCE_DIRECTORY_PATH = "testsets/conformance/xacml3.0-ct-v.0.4";
-
+
// The request object output from each test conversion from JSON string
Response response;
-
-
-
-
// test just one of each top-level element.
// For simple elements also test for incorrect type
@Test
public void testConformanceResponses() {
-
+
List<File> filesInDirectory = null;
-
+
File conformanceDirectory = null;
-
+
File currentFile = null;
-
+
try {
conformanceDirectory = new File(CONFORMANCE_DIRECTORY_PATH);
filesInDirectory = getRequestsInDirectory(conformanceDirectory);
} catch (Exception e) {
fail("Unable to set up Conformance tests for dir '" + conformanceDirectory.getAbsolutePath()+"' e="+ e);
}
-
+
// run through each XML file
// - load the file from XML into an internal Response object
// - generate the JSON representation of that Response object
@@ -93,12 +89,12 @@ public class ResponseConformanceTest {
for (File f : filesInDirectory) {
currentFile = f;
-//// This is a simple way to select just one file for debugging - comment out when not being used
-//if ( ! f.getName().equals("IIIA030Response.xml") && ! f.getName().equals("IIIA330Response.xml")) { continue; }
+ //// This is a simple way to select just one file for debugging - comment out when not being used
+ //if ( ! f.getName().equals("IIIA030Response.xml") && ! f.getName().equals("IIIA330Response.xml")) { continue; }
+
+ // during debugging it is helpful to know what file it is starting to work on
+ // System.out.println("starting file="+currentFile.getName());
-// during debugging it is helpful to know what file it is starting to work on
-// System.out.println("starting file="+currentFile.getName());
-
try {
// load XML into a Response object
xmlResponse = DOMResponse.load(f);
@@ -107,40 +103,40 @@ public class ResponseConformanceTest {
System.out.println("XML file did not load: '" + f.getName() + " e=" + e);
continue;
}
-
+
// some tests have JSON response files to load, most do not
String jsonFileName = f.getName().replace(".xml", ".json");
File jsonFile = new File(conformanceDirectory, jsonFileName);
-
+
if (jsonFile.exists()) {
-//System.out.println("found file "+jsonFile.getName());
+ //System.out.println("found file "+jsonFile.getName());
// json version exists in file, so load it
jsonResponse = JSONResponse.load(jsonFile);
} else {
// json does not exist in file, so create it from the XML response using a String intermediate version
String jsonResponseString = JSONResponse.toString(xmlResponse, false);
-//System.out.println(jsonResponseString);
-//System.out.println(JSONResponse.toString(xmlResponse, true));
-
+ //System.out.println(jsonResponseString);
+ //System.out.println(JSONResponse.toString(xmlResponse, true));
+
jsonResponse = JSONResponse.load(jsonResponseString);
}
-
-
-//System.out.println(JSONResponse.toString(xmlResponse, true));
+
+
+ //System.out.println(JSONResponse.toString(xmlResponse, true));
+
-
// compare the two Response objects
-
+
// compare results
assertEquals(xmlResponse.getResults().size(), jsonResponse.getResults().size());
-
+
if (xmlResponse.getResults().size() == 0) {
fail("neither XML nor JSON response have any Results");
}
-
-
+
+
// Results are an un-ordered Collection.
// There is no identifying information that is unique to a specific Result.
// If there are more than one we cannot be sure which one corresponds with which.
@@ -168,16 +164,16 @@ public class ResponseConformanceTest {
// we've done the best we can for multiple decisions, so go to next file
continue;
}
-
+
// single Result in each
Result xmlResult = xmlResponse.getResults().iterator().next();
Result jsonResult = jsonResponse.getResults().iterator().next();
-
+
// The following sections have not given us trouble, so checking is very high-level.
// If we see a problem in one of these elements, the single line will need to be replaced with detailed examination of the objects.
assertEquals(f.getName() + " Decision", xmlResult.getDecision(), jsonResult.getDecision());
assertEquals(f.getName() + " Status", xmlResult.getStatus(), jsonResult.getStatus());
-
+
// Obligations
if (xmlResult.getObligations() != jsonResult.getObligations()) {
Collection<Obligation> xmlObligations = xmlResult.getObligations();
@@ -188,10 +184,10 @@ public class ResponseConformanceTest {
}
if (ListUtil.equalsAllowNulls(xmlObligations, jsonObligations) == false) {
// collections are not equal, so need to examine further
-fail(f.getName() + " Obligation collections not equal\nXML="+xmlObligations + "\nJSON="+jsonObligations);
+ fail(f.getName() + " Obligation collections not equal\nXML="+xmlObligations + "\nJSON="+jsonObligations);
}
}
-
+
// AssociatedAdvice
if (xmlResult.getAssociatedAdvice() != jsonResult.getAssociatedAdvice()) {
Collection<Advice> xmlAdvice = xmlResult.getAssociatedAdvice();
@@ -202,12 +198,12 @@ fail(f.getName() + " Obligation collections not equal\nXML="+xmlObligations + "\
}
if (ListUtil.equalsAllowNulls(xmlAdvice, jsonAdvice) == false) {
// collections are not equal, so need to examine further
-fail(f.getName() + " Advice collections not equal\nXML="+xmlAdvice + "\nJSON="+jsonAdvice);
+ fail(f.getName() + " Advice collections not equal\nXML="+xmlAdvice + "\nJSON="+jsonAdvice);
}
}
-
-
-
+
+
+
// check Attributes in more detail
Collection<AttributeCategory> xmlAttributes = xmlResult.getAttributes();
Collection<AttributeCategory> jsonAttributes = jsonResult.getAttributes();
@@ -228,7 +224,7 @@ fail(f.getName() + " Advice collections not equal\nXML="+xmlAdvice + "\nJSON="+j
}
fail(f.getName() + " XML and JSON have different number of Category elements: " + xmlAttributesString + ", " + jsonAttributesString);
}
-
+
// Attribute collections are the same size but may be in different orders.
// for each XML category try to find the corresponding JSON category.
// ASSUME that each category only shows up once!!!!
@@ -268,7 +264,7 @@ fail(f.getName() + " Advice collections not equal\nXML="+xmlAdvice + "\nJSON="+j
"/nXML Attribute="+xmlAttr+
"\nJSON Category Attributes="+jsonAttributeCategory.toString());
}
-
+
}
@@ -278,9 +274,9 @@ fail(f.getName() + " Advice collections not equal\nXML="+xmlAdvice + "\nJSON="+j
}
fail("XML Category not found in JSON; xml="+xmlAttributeCategory.toString());
}
-
+
}
-
+
// PolicyIdentifiers
if (xmlResult.getPolicyIdentifiers() != jsonResult.getPolicyIdentifiers()) {
Collection<IdReference> xmlIdReferences = xmlResult.getPolicyIdentifiers();
@@ -291,10 +287,10 @@ fail(f.getName() + " Advice collections not equal\nXML="+xmlAdvice + "\nJSON="+j
}
if (ListUtil.equalsAllowNulls(xmlIdReferences, jsonIdReferences) == false) {
// collections are not equal, so need to examine further
-fail(f.getName() + " PolicyIdentifiers collections not equal\nXML="+xmlIdReferences+ "\nJSON="+jsonIdReferences);
+ fail(f.getName() + " PolicyIdentifiers collections not equal\nXML="+xmlIdReferences+ "\nJSON="+jsonIdReferences);
}
}
-
+
// PolicySetIdentifiers
if (xmlResult.getPolicySetIdentifiers() != jsonResult.getPolicySetIdentifiers()) {
Collection<IdReference> xmlIdReferences = xmlResult.getPolicySetIdentifiers();
@@ -305,10 +301,10 @@ fail(f.getName() + " PolicyIdentifiers collections not equal\nXML="+xmlIdReferen
}
if (ListUtil.equalsAllowNulls(xmlIdReferences, jsonIdReferences) == false) {
// collections are not equal, so need to examine further
-fail(f.getName() + " PolicySetIdentifiers collections not equal\nXML="+xmlIdReferences + "\nJSON="+jsonIdReferences);
+ fail(f.getName() + " PolicySetIdentifiers collections not equal\nXML="+xmlIdReferences + "\nJSON="+jsonIdReferences);
}
}
-
+
}
@@ -316,16 +312,16 @@ fail(f.getName() + " PolicySetIdentifiers collections not equal\nXML="+xmlIdRefe
fail ("Failed test with '" + currentFile.getName() + "', e=" + e);
}
-
+
}
-
+
//
// HELPER to get list of all Request files in the given directory
//
-
+
private List<File> getRequestsInDirectory(File directory) {
List<File> fileList = new ArrayList<File>();
-
+
File[] fileArray = directory.listFiles();
for (File f : fileArray) {
if (f.isDirectory()) {
@@ -337,13 +333,10 @@ fail(f.getName() + " PolicySetIdentifiers collections not equal\nXML="+xmlIdRefe
}
}
return fileList;
-
- }
-
-}
-
+ }
+}
/*
@@ -351,7 +344,6 @@ fail(f.getName() + " PolicySetIdentifiers collections not equal\nXML="+xmlIdRefe
This is a place to copy the really long output from test rigs that need to be manually edited for readability....
-
{"Response":[{"Status":{"StatusCode":{"Value":"urn:oasis:names:tc:xacml:1.0:status:ok"}},"Obligations":[{"Id":"urn:oasis:names:tc:xacml:2.0:conformance-test:IIIA030:obligation-1","AttributeAssignment":[
{"Value":"assignment1","DataType":"string","AttributeId":"urn:oasis:names:tc:xacml:2.0:conformance-test:IIIA030:assignment1"},
{"Value":{"Namespaces":[{"Namespace":"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17"},{"Namespace":"http://www.w3.org/2001/XMLSchema-instance","Prefix":"xsi"}],
@@ -362,9 +354,4 @@ This is a place to copy the really long output from test rigs that need to be ma
-*/
-
-
-
-
-
+ */ \ No newline at end of file
diff --git a/ECOMP-XACML/testsets/conformance/xacml3.0-ct-v.0.4/IIA001Response.xml b/ECOMP-XACML/testsets/conformance/xacml3.0-ct-v.0.4/IIA001Response.xml
new file mode 100644
index 000000000..8c484e0a9
--- /dev/null
+++ b/ECOMP-XACML/testsets/conformance/xacml3.0-ct-v.0.4/IIA001Response.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Response
+ xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17
+ http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd">
+ <Result>
+ <Decision>Permit</Decision>
+ <Status>
+ <StatusCode
+ Value="urn:oasis:names:tc:xacml:1.0:status:ok"/>
+ </Status>
+ </Result>
+</Response> \ No newline at end of file