Commit 82228ef3 authored by cdanger's avatar cdanger

Fixed XACML/JSON processing unit tests

parent c837d1d7
......@@ -132,7 +132,6 @@
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<dependencies>
<dependency>
<groupId>net.sourceforge.saxon</groupId>
......
......@@ -21,7 +21,7 @@ import java.io.IOException;
import java.net.URISyntaxException;
import java.util.Iterator;
import org.testng.annotations.BeforeTest;
import org.ow2.authzforce.core.pdp.io.xacml.json.MultipleDecisionXacmlJsonRequestPreprocessor;
import org.testng.annotations.DataProvider;
/**
......@@ -40,13 +40,7 @@ public class JsonProfileConformanceMultipleDecisionProfileTest extends JsonProfi
@DataProvider
public static Iterator<Object[]> getTestDirectories() throws URISyntaxException, IOException
{
return params(TEST_RESOURCES_ROOT_DIRECTORY_LOCATION).iterator();
}
@BeforeTest
public void setUpTest()
{
this.setMdpEnabled(true);
return params(TEST_RESOURCES_ROOT_DIRECTORY_LOCATION, MultipleDecisionXacmlJsonRequestPreprocessor.LaxVariantFactory.ID).iterator();
}
}
\ No newline at end of file
......@@ -21,6 +21,7 @@ import java.io.IOException;
import java.net.URISyntaxException;
import java.util.Iterator;
import org.ow2.authzforce.core.pdp.io.xacml.json.SingleDecisionXacmlJsonRequestPreprocessor;
import org.testng.annotations.DataProvider;
/**
......@@ -38,7 +39,7 @@ public class JsonProfileConformanceV3MandatoryTest extends JsonProfileConformanc
@DataProvider
public static Iterator<Object[]> getTestDirectories() throws URISyntaxException, IOException
{
return params(TEST_RESOURCES_ROOT_DIRECTORY_LOCATION).iterator();
return params(TEST_RESOURCES_ROOT_DIRECTORY_LOCATION, SingleDecisionXacmlJsonRequestPreprocessor.LaxVariantFactory.ID).iterator();
}
}
\ No newline at end of file
......@@ -39,8 +39,8 @@ import org.json.JSONObject;
import org.json.JSONTokener;
import org.ow2.authzforce.core.pdp.api.io.PdpEngineInoutAdapter;
import org.ow2.authzforce.core.pdp.impl.PdpEngineConfiguration;
import org.ow2.authzforce.core.pdp.impl.io.SingleDecisionXacmlJaxbRequestPreprocessor;
import org.ow2.authzforce.core.pdp.io.xacml.json.BaseXacmlJsonResultPostprocessor;
import org.ow2.authzforce.core.pdp.io.xacml.json.SingleDecisionXacmlJsonRequestPreprocessor;
import org.ow2.authzforce.core.pdp.testutil.TestUtils;
import org.ow2.authzforce.xacml.json.model.LimitsCheckingJSONObject;
import org.ow2.authzforce.xacml.json.model.XacmlJsonUtils;
......@@ -139,7 +139,7 @@ public class JsonProfileConformanceV3Test
+ normalizedActualResponse + ">");
}
public static Collection<Object[]> params(final String testResourcesRootDirectory) throws URISyntaxException, IOException
public static Collection<Object[]> params(final String testResourcesRootDirectory, final String requestFilterId) throws URISyntaxException, IOException
{
final Collection<Object[]> testParams = new ArrayList<>();
/*
......@@ -154,7 +154,7 @@ public class JsonProfileConformanceV3Test
if (Files.isDirectory(path))
{
// specific test's resources directory location, used as parameter to PdpTest(String)
testParams.add(new Object[] { path });
testParams.add(new Object[] { path, requestFilterId });
}
}
}
......@@ -168,7 +168,7 @@ public class JsonProfileConformanceV3Test
}
@Test(dataProvider = "getTestDirectories")
public void test(final Path testDirectoryPath) throws Exception
public void test(final Path testDirectoryPath, final String requestFilterId) throws Exception
{
LOGGER.debug("******************************");
LOGGER.debug("Starting PDP test of directory '{}'", testDirectoryPath);
......@@ -212,9 +212,9 @@ public class JsonProfileConformanceV3Test
* policies) at the moment. If some day, JSON Profile addresses policy format too, then we should do like in ConformanceV3fromV2 class from pdp-testutils package (policy syntax validation).
*/
final PdpEngineConfiguration pdpEngineConf = Files.exists(policiesDir)
? TestUtils.newPdpEngineConfiguration(TestUtils.getPolicyRef(rootPolicyFile), policiesDir, ENABLE_XPATH, optAttProviderConfFile, null, null)
: TestUtils.newPdpEngineConfiguration(rootPolicyFile, ENABLE_XPATH, optAttProviderConfFile, SingleDecisionXacmlJsonRequestPreprocessor.LaxVariantFactory.ID,
BaseXacmlJsonResultPostprocessor.DefaultFactory.ID);
? TestUtils.newPdpEngineConfiguration(TestUtils.getPolicyRef(rootPolicyFile), policiesDir, ENABLE_XPATH, optAttProviderConfFile, requestFilterId,
BaseXacmlJsonResultPostprocessor.DefaultFactory.ID)
: TestUtils.newPdpEngineConfiguration(rootPolicyFile, ENABLE_XPATH, optAttProviderConfFile, requestFilterId, BaseXacmlJsonResultPostprocessor.DefaultFactory.ID);
try (final PdpEngineInoutAdapter<JSONObject, JSONObject> pdp = PdpEngineXacmlJsonAdapters.newXacmlJsonInoutAdapter(pdpEngineConf))
{
......@@ -237,6 +237,6 @@ public class JsonProfileConformanceV3Test
*/
final URL testDir = ResourceUtils.getURL("target/generated-test-resources/conformance/xacml-3.0-core/mandatory/IIIA004");
final Path testDirPath = Paths.get(testDir.toURI());
new JsonProfileConformanceV3Test().test(testDirPath);
new JsonProfileConformanceV3Test().test(testDirPath, SingleDecisionXacmlJaxbRequestPreprocessor.LaxVariantFactory.ID);
}
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment