Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Commit ea3be2a4 authored by Markus Quaritsch's avatar Markus Quaritsch
Browse files

adding testcase for checking hashes in reports

parent 8dea4fb5
No related branches found
No related tags found
No related merge requests found
......@@ -37,6 +37,7 @@ using System.Xml.Linq;
using System.Xml.XPath;
using Ninject;
using NUnit.Framework;
using TUGraz.VectoCommon.InputData;
using TUGraz.VectoCommon.Models;
using TUGraz.VectoCommon.Resources;
using TUGraz.VectoCommon.Utils;
......@@ -49,6 +50,7 @@ using TUGraz.VectoCore.OutputData.FileIO;
using TUGraz.VectoCore.OutputData.XML;
using TUGraz.VectoCore.Tests.XML;
using TUGraz.VectoCore.Utils;
using TUGraz.VectoHashing;
using XmlDocumentType = TUGraz.VectoCore.Utils.XmlDocumentType;
......@@ -235,5 +237,52 @@ namespace TUGraz.VectoCore.Tests.Integration
}
}
}
[TestCase]
public void TestXMLReportCorrectHashes()
{
var jobfile = @"Testdata\XML\XMLReaderDeclaration\vecto_vehicle-sample.xml";
var dataProvider = xmlInputReader.CreateDeclaration(jobfile);
var writer = new FileOutputWriter(jobfile);
var xmlReport = new XMLDeclarationReport(writer);
var sumData = new SummaryDataContainer(writer);
var jobContainer = new JobContainer(sumData);
if (File.Exists(writer.SumFileName)) {
File.Delete(writer.SumFileName);
}
var runsFactory = new SimulatorFactory(ExecutionMode.Declaration, dataProvider, writer, xmlReport) {
WriteModalResults = false,
Validate = false,
};
jobContainer.AddRuns(runsFactory);
// no need to run the simulation, we only check whether the meta-data is correct, no results are considered
//jobContainer.Execute();
//jobContainer.WaitFinished();
xmlReport.DoWriteReport();
var inputHash = VectoHash.Load(jobfile);
var mrfDigestData = new DigestData(xmlReport.FullReport.Document.XPathSelectElement("//*[local-name()='InputDataSignature']"));
var mrfInputDigest = inputHash.ComputeHash(mrfDigestData.CanonicalizationMethods, mrfDigestData.DigestMethod);
Assert.AreEqual(mrfInputDigest, mrfDigestData.DigestValue);
var cifDigestData = new DigestData(xmlReport.CustomerReport.Document.XPathSelectElement("//*[local-name()='InputDataSignature']"));
var cifInputDigest = inputHash.ComputeHash(cifDigestData.CanonicalizationMethods, cifDigestData.DigestMethod);
Assert.AreEqual(cifInputDigest, cifDigestData.DigestValue);
var mrfHash = VectoHash.Load(writer.XMLFullReportName);
var mrfCifDigestData = new DigestData(xmlReport.CustomerReport.Document.XPathSelectElement("//*[local-name()='ResultDataSignature']"));
var mrfCifDigest = mrfHash.ComputeHash(mrfCifDigestData.CanonicalizationMethods, mrfCifDigestData.DigestMethod);
Assert.AreEqual(mrfCifDigest, mrfCifDigestData.DigestValue);
}
}
}
......@@ -209,6 +209,10 @@
<Project>{79a066ad-69a9-4223-90f6-6ed5d2d084f4}</Project>
<Name>VectoCommon</Name>
</ProjectReference>
<ProjectReference Include="..\..\VectoCommon\VectoHashing\VectoHashing.csproj">
<Project>{B673E12F-D323-4C4C-8805-9915B2C72D3D}</Project>
<Name>VectoHashing</Name>
</ProjectReference>
<ProjectReference Include="..\..\VECTO\VECTO.vbproj">
<Project>{AAC0F132-0A9F-45B3-B682-77AC9B24B352}</Project>
<Name>VECTO</Name>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment