From aeb376ae6c8fb2c586cf9a50ad62965dad2598b1 Mon Sep 17 00:00:00 2001
From: Markus Quaritsch <markus.quaritsch@tugraz.at>
Date: Fri, 3 Apr 2020 11:28:45 +0200
Subject: [PATCH] adding testcase to show how xsi:type attribute invalidates
 existing hashes

---
 .../vecto_engine_valid-typeAttr.xml           | 165 ++++++++++++++++++
 VectoCommon/VectoHashingTest/VectoHashTest.cs |   8 +
 .../VectoHashingTest/VectoHashingTest.csproj  |   3 +
 3 files changed, 176 insertions(+)
 create mode 100644 VectoCommon/VectoHashingTest/Testdata/XML/Validation/vecto_engine_valid-typeAttr.xml

diff --git a/VectoCommon/VectoHashingTest/Testdata/XML/Validation/vecto_engine_valid-typeAttr.xml b/VectoCommon/VectoHashingTest/Testdata/XML/Validation/vecto_engine_valid-typeAttr.xml
new file mode 100644
index 0000000000..965510b1ee
--- /dev/null
+++ b/VectoCommon/VectoHashingTest/Testdata/XML/Validation/vecto_engine_valid-typeAttr.xml
@@ -0,0 +1,165 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<tns:VectoInputDeclaration xmlns="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:v1.0"
+													xmlns:tns="urn:tugraz:ivt:VectoAPI:DeclarationComponent:v1.0"
+													xmlns:di="http://www.w3.org/2000/09/xmldsig#" schemaVersion="1.0"
+													xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+													xsi:schemaLocation="urn:tugraz:ivt:VectoAPI:DeclarationComponent:v1.0 https://webgate.ec.europa.eu/CITnet/svn/VECTO/trunk/Share/XML/XSD/VectoComponent.xsd">
+	<tns:Engine>
+		<Data id="ENG-c481b13b8dba4d3682c4" xsi:type="EngineDataDeclarationType">
+			<Manufacturer>Generic Engine Manufacturer</Manufacturer>
+			<Model>Generic 40t Long Haul Truck Engine</Model>
+			<CertificationNumber xsi:type="CertificationNumberType">ENG-gooZah3D</CertificationNumber>
+			<Date>2017-02-15T11:00:00Z</Date>
+			<AppVersion>VectoEngine x.y</AppVersion>
+			<Displacement>12730</Displacement>
+			<IdlingSpeed>560</IdlingSpeed>
+			<RatedSpeed>2200</RatedSpeed>
+			<RatedPower>380000</RatedPower>
+			<MaxEngineTorque>2300</MaxEngineTorque>
+			<WHTCUrban>1.0097</WHTCUrban>
+			<WHTCRural>1.0035</WHTCRural>
+			<WHTCMotorway>1.0200</WHTCMotorway>
+			<BFColdHot>1.0000</BFColdHot>
+			<CFRegPer>1.0000</CFRegPer>
+			<CFNCV>1.0000</CFNCV>
+			<FuelType>Diesel CI</FuelType>
+			<FuelConsumptionMap>
+				<Entry engineSpeed="560.00" torque="-149.00" fuelConsumption="0.00" />
+				<Entry engineSpeed="560.00" torque="0.00" fuelConsumption="1256.00" />
+				<Entry engineSpeed="560.00" torque="200.00" fuelConsumption="3197.00" />
+				<Entry engineSpeed="560.00" torque="400.00" fuelConsumption="5295.00" />
+				<Entry engineSpeed="560.00" torque="600.00" fuelConsumption="7615.00" />
+				<Entry engineSpeed="560.00" torque="800.00" fuelConsumption="9375.00" />
+				<Entry engineSpeed="560.00" torque="1000.00" fuelConsumption="11239.00" />
+				<Entry engineSpeed="560.00" torque="1180.00" fuelConsumption="12869.00" />
+				<Entry engineSpeed="600.00" torque="-148.00" fuelConsumption="0.00" />
+				<Entry engineSpeed="600.00" torque="0.00" fuelConsumption="1459.00" />
+				<Entry engineSpeed="600.00" torque="200.00" fuelConsumption="3358.00" />
+				<Entry engineSpeed="600.00" torque="400.00" fuelConsumption="5498.00" />
+				<Entry engineSpeed="600.00" torque="600.00" fuelConsumption="8101.00" />
+				<Entry engineSpeed="600.00" torque="800.00" fuelConsumption="10014.00" />
+				<Entry engineSpeed="600.00" torque="1000.00" fuelConsumption="12071.00" />
+				<Entry engineSpeed="600.00" torque="1200.00" fuelConsumption="14201.00" />
+				<Entry engineSpeed="600.00" torque="1282.00" fuelConsumption="15304.00" />
+				<Entry engineSpeed="800.00" torque="-149.00" fuelConsumption="0.00" />
+				<Entry engineSpeed="800.00" torque="0.00" fuelConsumption="1879.00" />
+				<Entry engineSpeed="800.00" torque="200.00" fuelConsumption="4286.00" />
+				<Entry engineSpeed="800.00" torque="400.00" fuelConsumption="7021.00" />
+				<Entry engineSpeed="800.00" torque="600.00" fuelConsumption="10059.00" />
+				<Entry engineSpeed="800.00" torque="800.00" fuelConsumption="13086.00" />
+				<Entry engineSpeed="800.00" torque="1000.00" fuelConsumption="16015.00" />
+				<Entry engineSpeed="800.00" torque="1200.00" fuelConsumption="19239.00" />
+				<Entry engineSpeed="800.00" torque="1400.00" fuelConsumption="22426.00" />
+				<Entry engineSpeed="800.00" torque="1600.00" fuelConsumption="25483.00" />
+				<Entry engineSpeed="800.00" torque="1791.00" fuelConsumption="28905.00" />
+				<Entry engineSpeed="1000.00" torque="-160.00" fuelConsumption="0.00" />
+				<Entry engineSpeed="1000.00" torque="0.00" fuelConsumption="2865.00" />
+				<Entry engineSpeed="1000.00" torque="200.00" fuelConsumption="5963.00" />
+				<Entry engineSpeed="1000.00" torque="400.00" fuelConsumption="9198.00" />
+				<Entry engineSpeed="1000.00" torque="600.00" fuelConsumption="12354.00" />
+				<Entry engineSpeed="1000.00" torque="800.00" fuelConsumption="15965.00" />
+				<Entry engineSpeed="1000.00" torque="1000.00" fuelConsumption="19864.00" />
+				<Entry engineSpeed="1000.00" torque="1200.00" fuelConsumption="23530.00" />
+				<Entry engineSpeed="1000.00" torque="1400.00" fuelConsumption="27202.00" />
+				<Entry engineSpeed="1000.00" torque="1600.00" fuelConsumption="31165.00" />
+				<Entry engineSpeed="1000.00" torque="1800.00" fuelConsumption="35103.00" />
+				<Entry engineSpeed="1000.00" torque="2000.00" fuelConsumption="39360.00" />
+				<Entry engineSpeed="1000.00" torque="2200.00" fuelConsumption="44120.00" />
+				<Entry engineSpeed="1000.00" torque="2300.00" fuelConsumption="46836.00" />
+				<Entry engineSpeed="1200.00" torque="-179.00" fuelConsumption="0.00" />
+				<Entry engineSpeed="1200.00" torque="0.00" fuelConsumption="3307.00" />
+				<Entry engineSpeed="1200.00" torque="200.00" fuelConsumption="6897.00" />
+				<Entry engineSpeed="1200.00" torque="400.00" fuelConsumption="10651.00" />
+				<Entry engineSpeed="1200.00" torque="600.00" fuelConsumption="14645.00" />
+				<Entry engineSpeed="1200.00" torque="800.00" fuelConsumption="19115.00" />
+				<Entry engineSpeed="1200.00" torque="1000.00" fuelConsumption="23677.00" />
+				<Entry engineSpeed="1200.00" torque="1200.00" fuelConsumption="28180.00" />
+				<Entry engineSpeed="1200.00" torque="1400.00" fuelConsumption="32431.00" />
+				<Entry engineSpeed="1200.00" torque="1600.00" fuelConsumption="36698.00" />
+				<Entry engineSpeed="1200.00" torque="1800.00" fuelConsumption="41691.00" />
+				<Entry engineSpeed="1200.00" torque="2000.00" fuelConsumption="46915.00" />
+				<Entry engineSpeed="1200.00" torque="2200.00" fuelConsumption="51783.00" />
+				<Entry engineSpeed="1200.00" torque="2300.00" fuelConsumption="54932.00" />
+				<Entry engineSpeed="1400.00" torque="-203.00" fuelConsumption="0.00" />
+				<Entry engineSpeed="1400.00" torque="0.00" fuelConsumption="4306.00" />
+				<Entry engineSpeed="1400.00" torque="200.00" fuelConsumption="8143.00" />
+				<Entry engineSpeed="1400.00" torque="400.00" fuelConsumption="12723.00" />
+				<Entry engineSpeed="1400.00" torque="600.00" fuelConsumption="17523.00" />
+				<Entry engineSpeed="1400.00" torque="800.00" fuelConsumption="22288.00" />
+				<Entry engineSpeed="1400.00" torque="1000.00" fuelConsumption="27093.00" />
+				<Entry engineSpeed="1400.00" torque="1200.00" fuelConsumption="32536.00" />
+				<Entry engineSpeed="1400.00" torque="1400.00" fuelConsumption="37746.00" />
+				<Entry engineSpeed="1400.00" torque="1600.00" fuelConsumption="43194.00" />
+				<Entry engineSpeed="1400.00" torque="1800.00" fuelConsumption="49453.00" />
+				<Entry engineSpeed="1400.00" torque="2000.00" fuelConsumption="55830.00" />
+				<Entry engineSpeed="1400.00" torque="2200.00" fuelConsumption="61072.00" />
+				<Entry engineSpeed="1400.00" torque="2300.00" fuelConsumption="64377.00" />
+				<Entry engineSpeed="1600.00" torque="-235.00" fuelConsumption="0.00" />
+				<Entry engineSpeed="1600.00" torque="0.00" fuelConsumption="5209.00" />
+				<Entry engineSpeed="1600.00" torque="200.00" fuelConsumption="9669.00" />
+				<Entry engineSpeed="1600.00" torque="400.00" fuelConsumption="14838.00" />
+				<Entry engineSpeed="1600.00" torque="600.00" fuelConsumption="20127.00" />
+				<Entry engineSpeed="1600.00" torque="800.00" fuelConsumption="25894.00" />
+				<Entry engineSpeed="1600.00" torque="1000.00" fuelConsumption="31631.00" />
+				<Entry engineSpeed="1600.00" torque="1200.00" fuelConsumption="37248.00" />
+				<Entry engineSpeed="1600.00" torque="1400.00" fuelConsumption="42826.00" />
+				<Entry engineSpeed="1600.00" torque="1600.00" fuelConsumption="49752.00" />
+				<Entry engineSpeed="1600.00" torque="1800.00" fuelConsumption="57020.00" />
+				<Entry engineSpeed="1600.00" torque="2000.00" fuelConsumption="63914.00" />
+				<Entry engineSpeed="1600.00" torque="2079.00" fuelConsumption="66520.00" />
+				<Entry engineSpeed="1800.00" torque="-264.00" fuelConsumption="0.00" />
+				<Entry engineSpeed="1800.00" torque="0.00" fuelConsumption="6409.00" />
+				<Entry engineSpeed="1800.00" torque="200.00" fuelConsumption="11777.00" />
+				<Entry engineSpeed="1800.00" torque="400.00" fuelConsumption="17320.00" />
+				<Entry engineSpeed="1800.00" torque="600.00" fuelConsumption="23394.00" />
+				<Entry engineSpeed="1800.00" torque="800.00" fuelConsumption="30501.00" />
+				<Entry engineSpeed="1800.00" torque="1000.00" fuelConsumption="36378.00" />
+				<Entry engineSpeed="1800.00" torque="1200.00" fuelConsumption="43079.00" />
+				<Entry engineSpeed="1800.00" torque="1400.00" fuelConsumption="49796.00" />
+				<Entry engineSpeed="1800.00" torque="1600.00" fuelConsumption="57436.00" />
+				<Entry engineSpeed="1800.00" torque="1800.00" fuelConsumption="65157.00" />
+				<Entry engineSpeed="1800.00" torque="1857.00" fuelConsumption="67574.00" />
+				<Entry engineSpeed="2000.00" torque="-301.00" fuelConsumption="0.00" />
+				<Entry engineSpeed="2000.00" torque="0.00" fuelConsumption="9127.00" />
+				<Entry engineSpeed="2000.00" torque="200.00" fuelConsumption="14822.00" />
+				<Entry engineSpeed="2000.00" torque="400.00" fuelConsumption="20655.00" />
+				<Entry engineSpeed="2000.00" torque="600.00" fuelConsumption="27076.00" />
+				<Entry engineSpeed="2000.00" torque="800.00" fuelConsumption="34188.00" />
+				<Entry engineSpeed="2000.00" torque="1000.00" fuelConsumption="42837.00" />
+				<Entry engineSpeed="2000.00" torque="1200.00" fuelConsumption="51018.00" />
+				<Entry engineSpeed="2000.00" torque="1352.00" fuelConsumption="56618.00" />
+				<Entry engineSpeed="2100.00" torque="-320.00" fuelConsumption="0.00" />
+				<Entry engineSpeed="2100.00" torque="0.00" fuelConsumption="10470.00" />
+				<Entry engineSpeed="2100.00" torque="200.00" fuelConsumption="16332.00" />
+				<Entry engineSpeed="2100.00" torque="400.00" fuelConsumption="22396.00" />
+				<Entry engineSpeed="2100.00" torque="600.00" fuelConsumption="28914.00" />
+				<Entry engineSpeed="2100.00" torque="800.00" fuelConsumption="35717.00" />
+				<Entry engineSpeed="2100.00" torque="1000.00" fuelConsumption="45643.00" />
+				<Entry engineSpeed="2100.00" torque="1100.00" fuelConsumption="50653.00" />
+			</FuelConsumptionMap>
+			<FullLoadAndDragCurve>
+				<Entry engineSpeed="560.00" maxTorque="1180.00" dragTorque="-149.00" />
+				<Entry engineSpeed="600.00" maxTorque="1282.00" dragTorque="-148.00" />
+				<Entry engineSpeed="800.00" maxTorque="1791.00" dragTorque="-149.00" />
+				<Entry engineSpeed="1000.00" maxTorque="2300.00" dragTorque="-160.00" />
+				<Entry engineSpeed="1200.00" maxTorque="2300.00" dragTorque="-179.00" />
+				<Entry engineSpeed="1400.00" maxTorque="2300.00" dragTorque="-203.00" />
+				<Entry engineSpeed="1600.00" maxTorque="2079.00" dragTorque="-235.00" />
+				<Entry engineSpeed="1800.00" maxTorque="1857.00" dragTorque="-264.00" />
+				<Entry engineSpeed="2000.00" maxTorque="1352.00" dragTorque="-301.00" />
+				<Entry engineSpeed="2100.00" maxTorque="1100.00" dragTorque="-320.00" />
+			</FullLoadAndDragCurve>
+		</Data>
+		<Signature>
+			<di:Reference URI="#ENG-c481b13b8dba4d3682c4">
+				<di:Transforms>
+					<di:Transform Algorithm="urn:vecto:xml:2017:canonicalization" />
+					<di:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
+				</di:Transforms>
+				<di:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256" />
+				<di:DigestValue>bYGqZ5tcExIOHyNkH7HElRegtVqLcqBNzbTEWAKttsc=</di:DigestValue>
+			</di:Reference>
+		</Signature>
+	</tns:Engine>
+</tns:VectoInputDeclaration>
\ No newline at end of file
diff --git a/VectoCommon/VectoHashingTest/VectoHashTest.cs b/VectoCommon/VectoHashingTest/VectoHashTest.cs
index 96cf659622..08c14ed65f 100644
--- a/VectoCommon/VectoHashingTest/VectoHashTest.cs
+++ b/VectoCommon/VectoHashingTest/VectoHashTest.cs
@@ -514,5 +514,13 @@ namespace VectoHashingTest
 			Assert.AreEqual("1.0", version);
 
 		}
+
+		[TestCase(@"Testdata\XML\Validation\vecto_engine_valid.xml"),
+		TestCase(@"Testdata\XML\Validation\vecto_engine_valid-typeAttr.xml")]
+		public void TestIgnoreTypeAttribute(string file)
+		{
+			var h = VectoHash.Load(file);
+			Assert.IsTrue(h.ValidateHash());
+		}
 	}
 }
diff --git a/VectoCommon/VectoHashingTest/VectoHashingTest.csproj b/VectoCommon/VectoHashingTest/VectoHashingTest.csproj
index e4e95d277e..24b952790b 100644
--- a/VectoCommon/VectoHashingTest/VectoHashingTest.csproj
+++ b/VectoCommon/VectoHashingTest/VectoHashingTest.csproj
@@ -111,6 +111,9 @@
     <Content Include="Testdata\XML\Validation\vecto_engine_invalid.xml">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </Content>
+    <Content Include="Testdata\XML\Validation\vecto_engine_valid-typeAttr.xml">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </Content>
     <Content Include="Testdata\XML\Validation\vecto_engine_valid.xml">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </Content>
-- 
GitLab