aboutsummaryrefslogtreecommitdiff
path: root/moaSig/moa-sig-lib/src/test/java/test/at/gv/egovernment/moa/spss/api
diff options
context:
space:
mode:
authorAndreas Fitzek <andreas.fitzek@iaik.tugraz.at>2015-11-03 14:38:34 +0100
committerAndreas Fitzek <andreas.fitzek@iaik.tugraz.at>2015-11-03 14:38:34 +0100
commit0872d2d8a64fd701776b272f49222428d8def07f (patch)
tree0954a523ad2cc7ad615dbbae5282dd56497e4c6e /moaSig/moa-sig-lib/src/test/java/test/at/gv/egovernment/moa/spss/api
parente635718b8d6a12e4e80207c8bdf30b02eed3f2ab (diff)
downloadmoa-sig-0872d2d8a64fd701776b272f49222428d8def07f.tar.gz
moa-sig-0872d2d8a64fd701776b272f49222428d8def07f.tar.bz2
moa-sig-0872d2d8a64fd701776b272f49222428d8def07f.zip
initial commit
Diffstat (limited to 'moaSig/moa-sig-lib/src/test/java/test/at/gv/egovernment/moa/spss/api')
-rw-r--r--moaSig/moa-sig-lib/src/test/java/test/at/gv/egovernment/moa/spss/api/xmlbind/AllTests.java48
-rw-r--r--moaSig/moa-sig-lib/src/test/java/test/at/gv/egovernment/moa/spss/api/xmlbind/CreateXMLSignatureRequestParserTest.java95
-rw-r--r--moaSig/moa-sig-lib/src/test/java/test/at/gv/egovernment/moa/spss/api/xmlbind/TransformParserTest.java137
-rw-r--r--moaSig/moa-sig-lib/src/test/java/test/at/gv/egovernment/moa/spss/api/xmlbind/VerifyCMSSignatureRequestParserTest.java85
-rw-r--r--moaSig/moa-sig-lib/src/test/java/test/at/gv/egovernment/moa/spss/api/xmlbind/VerifyXMLSignatureRequestParserTest.java105
5 files changed, 470 insertions, 0 deletions
diff --git a/moaSig/moa-sig-lib/src/test/java/test/at/gv/egovernment/moa/spss/api/xmlbind/AllTests.java b/moaSig/moa-sig-lib/src/test/java/test/at/gv/egovernment/moa/spss/api/xmlbind/AllTests.java
new file mode 100644
index 0000000..767327d
--- /dev/null
+++ b/moaSig/moa-sig-lib/src/test/java/test/at/gv/egovernment/moa/spss/api/xmlbind/AllTests.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2003 Federal Chancellery Austria
+ * MOA-SPSS has been developed in a cooperation between BRZ, the Federal
+ * Chancellery Austria - ICT staff unit, and Graz University of Technology.
+ *
+ * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
+ * the European Commission - subsequent versions of the EUPL (the "Licence");
+ * You may not use this work except in compliance with the Licence.
+ * You may obtain a copy of the Licence at:
+ * http://www.osor.eu/eupl/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the Licence is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the Licence for the specific language governing permissions and
+ * limitations under the Licence.
+ *
+ * This product combines work with different licenses. See the "NOTICE" text
+ * file for details on the various modules and licenses.
+ * The "NOTICE" text file is part of the distribution. Any derivative works
+ * that you distribute must include a readable copy of the "NOTICE" text file.
+ */
+
+
+package test.at.gv.egovernment.moa.spss.api.xmlbind;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * Runs all tests in this package.
+ *
+ * @author Patrick Peck
+ * @version $Id$
+ */
+public class AllTests {
+ public static Test suite() {
+ TestSuite suite = new TestSuite();
+
+ suite.addTestSuite(CreateXMLSignatureRequestParserTest.class);
+ suite.addTestSuite(TransformParserTest.class);
+ suite.addTestSuite(VerifyCMSSignatureRequestParserTest.class);
+ suite.addTestSuite(VerifyXMLSignatureRequestParserTest.class);
+
+ return suite;
+ }
+
+}
diff --git a/moaSig/moa-sig-lib/src/test/java/test/at/gv/egovernment/moa/spss/api/xmlbind/CreateXMLSignatureRequestParserTest.java b/moaSig/moa-sig-lib/src/test/java/test/at/gv/egovernment/moa/spss/api/xmlbind/CreateXMLSignatureRequestParserTest.java
new file mode 100644
index 0000000..dc67231
--- /dev/null
+++ b/moaSig/moa-sig-lib/src/test/java/test/at/gv/egovernment/moa/spss/api/xmlbind/CreateXMLSignatureRequestParserTest.java
@@ -0,0 +1,95 @@
+/*
+ * Copyright 2003 Federal Chancellery Austria
+ * MOA-SPSS has been developed in a cooperation between BRZ, the Federal
+ * Chancellery Austria - ICT staff unit, and Graz University of Technology.
+ *
+ * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
+ * the European Commission - subsequent versions of the EUPL (the "Licence");
+ * You may not use this work except in compliance with the Licence.
+ * You may obtain a copy of the Licence at:
+ * http://www.osor.eu/eupl/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the Licence is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the Licence for the specific language governing permissions and
+ * limitations under the Licence.
+ *
+ * This product combines work with different licenses. See the "NOTICE" text
+ * file for details on the various modules and licenses.
+ * The "NOTICE" text file is part of the distribution. Any derivative works
+ * that you distribute must include a readable copy of the "NOTICE" text file.
+ */
+
+
+package test.at.gv.egovernment.moa.spss.api.xmlbind;
+
+import org.w3c.dom.Element;
+
+import test.at.gv.egovernment.moa.spss.SPSSTestCase;
+
+import at.gv.egovernment.moa.spss.api.xmlbind.CreateXMLSignatureRequestParser;
+import at.gv.egovernment.moa.spss.api.xmlsign.CreateSignatureEnvironmentProfileExplicit;
+import at.gv.egovernment.moa.spss.api.xmlsign.CreateTransformsInfoProfileExplicit;
+import at.gv.egovernment.moa.spss.api.xmlsign.CreateXMLSignatureRequest;
+import at.gv.egovernment.moa.spss.api.xmlsign.DataObjectInfo;
+import at.gv.egovernment.moa.spss.api.xmlsign.SingleSignatureInfo;
+
+/**
+ * Test the <code>CreateXMLSignatureRequestParser</code>.
+ *
+ * @author Patrick Peck
+ * @version $Id$
+ */
+public class CreateXMLSignatureRequestParserTest extends SPSSTestCase {
+ private static final String TESTDATA_BASE =
+ TESTDATA_ROOT + "xml/CreateXMLSignature/";
+
+ private CreateXMLSignatureRequestParser requestParser;
+
+ public CreateXMLSignatureRequestParserTest(String name) {
+ super(name);
+ }
+
+ protected void setUp() throws Exception {
+ requestParser = new CreateXMLSignatureRequestParser();
+ }
+
+ public void testParse() throws Exception {
+ Element requestElem =
+ parseXml(TESTDATA_BASE + "TestGeneratorCX2.001.Req.xml")
+ .getDocumentElement();
+ CreateXMLSignatureRequest request = requestParser.parse(requestElem);
+ SingleSignatureInfo sigInfo;
+ DataObjectInfo dataObjInfo;
+ CreateTransformsInfoProfileExplicit transProfile;
+ CreateSignatureEnvironmentProfileExplicit envProfile;
+
+ assertNotNull(request);
+ assertEquals("PKCS12RSAKey1", request.getKeyIdentifier());
+ assertEquals(1, request.getSingleSignatureInfos().size());
+
+ sigInfo = (SingleSignatureInfo) request.getSingleSignatureInfos().get(0);
+ assertEquals(1, sigInfo.getDataObjectInfos().size());
+ assertFalse(sigInfo.isSecurityLayerConform());
+
+ dataObjInfo = (DataObjectInfo) sigInfo.getDataObjectInfos().get(0);
+ assertNotNull(dataObjInfo.getDataObject());
+
+ transProfile =
+ (CreateTransformsInfoProfileExplicit) dataObjInfo
+ .getCreateTransformsInfoProfile();
+ assertNotNull(
+ transProfile.getCreateTransformsInfo().getFinalDataMetaInfo());
+
+ envProfile =
+ (CreateSignatureEnvironmentProfileExplicit) sigInfo
+ .getCreateSignatureInfo()
+ .getCreateSignatureEnvironmentProfile();
+ assertEquals(
+ "//data:Document",
+ envProfile.getCreateSignatureLocation().getXPathExpression());
+ assertEquals(0, envProfile.getCreateSignatureLocation().getIndex());
+ }
+
+}
diff --git a/moaSig/moa-sig-lib/src/test/java/test/at/gv/egovernment/moa/spss/api/xmlbind/TransformParserTest.java b/moaSig/moa-sig-lib/src/test/java/test/at/gv/egovernment/moa/spss/api/xmlbind/TransformParserTest.java
new file mode 100644
index 0000000..be6a24d
--- /dev/null
+++ b/moaSig/moa-sig-lib/src/test/java/test/at/gv/egovernment/moa/spss/api/xmlbind/TransformParserTest.java
@@ -0,0 +1,137 @@
+/*
+ * Copyright 2003 Federal Chancellery Austria
+ * MOA-SPSS has been developed in a cooperation between BRZ, the Federal
+ * Chancellery Austria - ICT staff unit, and Graz University of Technology.
+ *
+ * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
+ * the European Commission - subsequent versions of the EUPL (the "Licence");
+ * You may not use this work except in compliance with the Licence.
+ * You may obtain a copy of the Licence at:
+ * http://www.osor.eu/eupl/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the Licence is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the Licence for the specific language governing permissions and
+ * limitations under the Licence.
+ *
+ * This product combines work with different licenses. See the "NOTICE" text
+ * file for details on the various modules and licenses.
+ * The "NOTICE" text file is part of the distribution. Any derivative works
+ * that you distribute must include a readable copy of the "NOTICE" text file.
+ */
+
+
+package test.at.gv.egovernment.moa.spss.api.xmlbind;
+
+import java.util.List;
+
+import org.w3c.dom.Element;
+
+import test.at.gv.egovernment.moa.spss.SPSSTestCase;
+
+import at.gv.egovernment.moa.spss.api.common.CanonicalizationTransform;
+import at.gv.egovernment.moa.spss.api.common.EnvelopedSignatureTransform;
+import at.gv.egovernment.moa.spss.api.common.ExclusiveCanonicalizationTransform;
+import at.gv.egovernment.moa.spss.api.common.XPathFilter2Transform;
+import at.gv.egovernment.moa.spss.api.common.XPathTransform;
+import at.gv.egovernment.moa.spss.api.common.XSLTTransform;
+import at.gv.egovernment.moa.spss.api.xmlbind.TransformParser;
+
+/**
+ * Test the <code>TransformParser</code>.
+ *
+ * @author Patrick Peck
+ * @version $Id$
+ */
+public class TransformParserTest extends SPSSTestCase {
+ private static String TESTDATA_BASE = TESTDATA_ROOT + "xml/dsigTransform/";
+
+ private TransformParser transformParser;
+
+ public TransformParserTest(String name) {
+ super(name);
+ }
+
+ protected void setUp() {
+ transformParser = new TransformParser();
+ }
+
+ public void testParseTransforms() throws Exception {
+ Element transformsElem =
+ parseXml(TESTDATA_BASE + "transforms.xml").getDocumentElement();
+ List transforms = transformParser.parseTransforms(transformsElem);
+
+ assertNotNull(transforms);
+ assertEquals(3, transforms.size());
+
+ }
+
+ public void testParseCanonicalizationTransform() throws Exception {
+ Element transformElem =
+ parseXml(TESTDATA_BASE + "canonicalization.xml").getDocumentElement();
+ CanonicalizationTransform transform =
+ (CanonicalizationTransform) transformParser.parseTransform(transformElem);
+
+ assertNotNull(transform);
+ assertEquals(
+ CanonicalizationTransform.CANONICAL_XML,
+ transform.getAlgorithmURI());
+ }
+
+ public void testParseExclCanonicalizationTransform() throws Exception {
+ Element transformElem =
+ parseXml(TESTDATA_BASE + "exclusiveCanonicalization.xml")
+ .getDocumentElement();
+ ExclusiveCanonicalizationTransform transform =
+ (ExclusiveCanonicalizationTransform) transformParser.parseTransform(
+ transformElem);
+
+ assertNotNull(transform);
+ assertEquals(
+ ExclusiveCanonicalizationTransform.EXCLUSIVE_CANONICAL_XML,
+ transform.getAlgorithmURI());
+ assertEquals(3, transform.getInclusiveNamespacePrefixes().size());
+ }
+
+ public void testParseEnvelopedTransform() throws Exception {
+ Element transformElem =
+ parseXml(TESTDATA_BASE + "enveloped.xml").getDocumentElement();
+ EnvelopedSignatureTransform transform =
+ (EnvelopedSignatureTransform) transformParser.parseTransform(
+ transformElem);
+
+ assertNotNull(transform);
+ }
+
+ public void testParseXPathTransform() throws Exception {
+ Element transformElem =
+ parseXml(TESTDATA_BASE + "xpath.xml").getDocumentElement();
+ XPathTransform transform =
+ (XPathTransform) transformParser.parseTransform(transformElem);
+
+ assertNotNull(transform);
+ assertEquals("//ToBeSigned/Data", transform.getXPathExpression());
+ assertEquals(1, transform.getNamespaceDeclarations().size());
+ }
+
+ public void testParseXPathFilter2Transform() throws Exception {
+ Element transformElem =
+ parseXml(TESTDATA_BASE + "xpath2.xml").getDocumentElement();
+ XPathFilter2Transform transform =
+ (XPathFilter2Transform) transformParser.parseTransform(transformElem);
+
+ assertNotNull(transform);
+ assertEquals(3, transform.getFilters().size());
+ }
+
+ public void testParseXSLTTransform() throws Exception {
+ Element transformElem =
+ parseXml(TESTDATA_BASE + "xslt.xml").getDocumentElement();
+ XSLTTransform transform =
+ (XSLTTransform) transformParser.parseTransform(transformElem);
+
+ assertNotNull(transform);
+ }
+
+}
diff --git a/moaSig/moa-sig-lib/src/test/java/test/at/gv/egovernment/moa/spss/api/xmlbind/VerifyCMSSignatureRequestParserTest.java b/moaSig/moa-sig-lib/src/test/java/test/at/gv/egovernment/moa/spss/api/xmlbind/VerifyCMSSignatureRequestParserTest.java
new file mode 100644
index 0000000..73bf54f
--- /dev/null
+++ b/moaSig/moa-sig-lib/src/test/java/test/at/gv/egovernment/moa/spss/api/xmlbind/VerifyCMSSignatureRequestParserTest.java
@@ -0,0 +1,85 @@
+/*
+ * Copyright 2003 Federal Chancellery Austria
+ * MOA-SPSS has been developed in a cooperation between BRZ, the Federal
+ * Chancellery Austria - ICT staff unit, and Graz University of Technology.
+ *
+ * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
+ * the European Commission - subsequent versions of the EUPL (the "Licence");
+ * You may not use this work except in compliance with the Licence.
+ * You may obtain a copy of the Licence at:
+ * http://www.osor.eu/eupl/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the Licence is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the Licence for the specific language governing permissions and
+ * limitations under the Licence.
+ *
+ * This product combines work with different licenses. See the "NOTICE" text
+ * file for details on the various modules and licenses.
+ * The "NOTICE" text file is part of the distribution. Any derivative works
+ * that you distribute must include a readable copy of the "NOTICE" text file.
+ */
+
+
+package test.at.gv.egovernment.moa.spss.api.xmlbind;
+
+import org.w3c.dom.Element;
+
+import at.gv.egovernment.moa.util.DateTimeUtils;
+
+import test.at.gv.egovernment.moa.spss.SPSSTestCase;
+
+import at.gv.egovernment.moa.spss.api.cmsverify.CMSContentExcplicit;
+import at.gv.egovernment.moa.spss.api.cmsverify.VerifyCMSSignatureRequest;
+import at.gv.egovernment.moa.spss.api.common.MetaInfo;
+import at.gv.egovernment.moa.spss.api.xmlbind.VerifyCMSSignatureRequestParser;
+
+/**
+ * Test the <code>VerifyCMSSignatureRequestParserTest</code>.
+ *
+ * @author Patrick Peck
+ * @version $Id$
+ */
+public class VerifyCMSSignatureRequestParserTest extends SPSSTestCase {
+ private static String TESTDATA_BASE =
+ TESTDATA_ROOT + "xml/VerifyCMSSignature/";
+
+ private VerifyCMSSignatureRequestParser requestParser;
+
+ public VerifyCMSSignatureRequestParserTest(String name) {
+ super(name);
+ }
+
+ protected void setUp() throws Exception {
+ requestParser = new VerifyCMSSignatureRequestParser();
+ }
+
+ public void testParse() throws Exception {
+ Element requestElem =
+ parseXml(TESTDATA_BASE + "TestGeneratorVC0.001.Req.xml")
+ .getDocumentElement();
+ VerifyCMSSignatureRequest request = requestParser.parse(requestElem);
+ MetaInfo metaInfo;
+ CMSContentExcplicit content;
+
+ assertNotNull(request);
+ assertEquals(1, request.getSignatories()[0]);
+ assertEquals(
+ DateTimeUtils.parseDateTime("2003-04-04T09:30:47-05:00"),
+ request.getDateTime());
+ assertNotNull(request.getCMSSignature());
+ assertNotNull(request.getDataObject());
+ assertEquals("TrustProfile1", request.getTrustProfileId());
+
+ metaInfo = request.getDataObject().getMetaInfo();
+ assertNotNull(metaInfo);
+ assertEquals("text/plain", metaInfo.getMimeType());
+ assertEquals("http://10.16.46.109/TestDatenGenerator/resources/testDaten.txt", metaInfo.getDescription());
+
+ content = (CMSContentExcplicit) request.getDataObject().getContent();
+ assertNotNull(content.getBinaryContent());
+
+ }
+
+}
diff --git a/moaSig/moa-sig-lib/src/test/java/test/at/gv/egovernment/moa/spss/api/xmlbind/VerifyXMLSignatureRequestParserTest.java b/moaSig/moa-sig-lib/src/test/java/test/at/gv/egovernment/moa/spss/api/xmlbind/VerifyXMLSignatureRequestParserTest.java
new file mode 100644
index 0000000..66d7efa
--- /dev/null
+++ b/moaSig/moa-sig-lib/src/test/java/test/at/gv/egovernment/moa/spss/api/xmlbind/VerifyXMLSignatureRequestParserTest.java
@@ -0,0 +1,105 @@
+/*
+ * Copyright 2003 Federal Chancellery Austria
+ * MOA-SPSS has been developed in a cooperation between BRZ, the Federal
+ * Chancellery Austria - ICT staff unit, and Graz University of Technology.
+ *
+ * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
+ * the European Commission - subsequent versions of the EUPL (the "Licence");
+ * You may not use this work except in compliance with the Licence.
+ * You may obtain a copy of the Licence at:
+ * http://www.osor.eu/eupl/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the Licence is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the Licence for the specific language governing permissions and
+ * limitations under the Licence.
+ *
+ * This product combines work with different licenses. See the "NOTICE" text
+ * file for details on the various modules and licenses.
+ * The "NOTICE" text file is part of the distribution. Any derivative works
+ * that you distribute must include a readable copy of the "NOTICE" text file.
+ */
+
+
+package test.at.gv.egovernment.moa.spss.api.xmlbind;
+
+import org.w3c.dom.Element;
+
+import test.at.gv.egovernment.moa.spss.SPSSTestCase;
+
+import at.gv.egovernment.moa.util.DateTimeUtils;
+
+import at.gv.egovernment.moa.spss.api.xmlbind.VerifyXMLSignatureRequestParser;
+import at.gv.egovernment.moa.spss.api.xmlverify.ReferenceInfo;
+import at.gv.egovernment.moa.spss.api.xmlverify.SignatureManifestCheckParams;
+import at.gv.egovernment.moa.spss.api.xmlverify.VerifySignatureInfo;
+import at.gv.egovernment.moa.spss.api.xmlverify.VerifySignatureLocation;
+import at.gv.egovernment.moa.spss.api.xmlverify.VerifyTransformsInfoProfileExplicit;
+import at.gv.egovernment.moa.spss.api.xmlverify.VerifyXMLSignatureRequest;
+
+/**
+ * Test the <code>VerifyXMLSignatureRequestParserTest</code>.
+ *
+ * @author Patrick Peck
+ * @version $Id$
+ */
+public class VerifyXMLSignatureRequestParserTest extends SPSSTestCase {
+ private static String TESTDATA_BASE =
+ TESTDATA_ROOT + "xml/VerifyXMLSignature/";
+
+ private VerifyXMLSignatureRequestParser parser;
+
+ public VerifyXMLSignatureRequestParserTest(String name) {
+ super(name);
+ }
+
+ protected void setUp() throws Exception {
+ parser = new VerifyXMLSignatureRequestParser();
+ }
+
+ public void testParse() throws Exception {
+ Element requestElem =
+ parseXml(TESTDATA_BASE + "TestGeneratorVX.201.Req.xml")
+ .getDocumentElement();
+ VerifyXMLSignatureRequest request = parser.parse(requestElem);
+ VerifySignatureInfo verifySignatureInfo;
+ VerifySignatureLocation verifyLocation;
+ SignatureManifestCheckParams checkParams;
+ ReferenceInfo refInfo;
+ VerifyTransformsInfoProfileExplicit transformsProfile;
+
+ assertNotNull(request);
+ assertEquals(
+ DateTimeUtils.parseDateTime("2003-04-01T12:53:57+01:00"),
+ request.getDateTime());
+ assertFalse(request.getReturnHashInputData());
+ assertEquals("TrustProfile1", request.getTrustProfileId());
+
+ verifySignatureInfo = request.getSignatureInfo();
+ assertNotNull(verifySignatureInfo);
+ assertNotNull(verifySignatureInfo.getVerifySignatureEnvironment());
+
+ verifyLocation = verifySignatureInfo.getVerifySignatureLocation();
+ assertNotNull(verifyLocation);
+ assertEquals("//dsig:Signature", verifyLocation.getXPathExpression());
+ assertEquals(3, verifyLocation.getNamespaceDeclarations().size());
+
+ checkParams = request.getSignatureManifestCheckParams();
+ assertNotNull(checkParams);
+ assertEquals(true, checkParams.getReturnReferenceInputData());
+ assertEquals(1, checkParams.getReferenceInfos().size());
+
+ refInfo = (ReferenceInfo) checkParams.getReferenceInfos().get(0);
+ assertEquals(1, refInfo.getVerifyTransformsInfoProfiles().size());
+
+ transformsProfile =
+ (VerifyTransformsInfoProfileExplicit) refInfo
+ .getVerifyTransformsInfoProfiles()
+ .get(0);
+ assertEquals(1, transformsProfile.getTransforms().size());
+ assertEquals(1, transformsProfile.getTransformParameters().size());
+
+ }
+
+}