Skip to content

Commit

Permalink
Implement generic version of testUnmarshalling
Browse files Browse the repository at this point in the history
  • Loading branch information
tvdijen committed Dec 25, 2023
1 parent 5a07d07 commit 30f0153
Show file tree
Hide file tree
Showing 48 changed files with 11 additions and 647 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"ext-spl": "*",

"simplesamlphp/assert": "^1.0",
"simplesamlphp/xml-common": "^1.13"
"simplesamlphp/xml-common": "^1.14"
},
"require-dev": {
"simplesamlphp/simplesamlphp-test-framework": "^1.5"
Expand Down
18 changes: 10 additions & 8 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" colors="true" processIsolation="false" stopOnFailure="false" bootstrap="./tests/bootstrap.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" colors="true" processIsolation="false" stopOnFailure="false" bootstrap="./tests/bootstrap.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<coverage>
<include>
<directory suffix=".php">./src/</directory>
</include>
<exclude>
<directory>./vendor/</directory>
<directory>./tests/</directory>
</exclude>
<report>
<clover outputFile="build/logs/clover.xml"/>
</report>
Expand All @@ -17,4 +10,13 @@
<directory>./tests</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory suffix=".php">./src/</directory>
</include>
<exclude>
<directory>./vendor/</directory>
<directory>./tests/</directory>
</exclude>
</source>
</phpunit>
13 changes: 0 additions & 13 deletions tests/XML/CustomSignableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,4 @@ public function testMarshalling(): void
strval($customSignable),
);
}


/**
*/
public function testUnmarshalling(): void
{
$customSignable = CustomSignable::fromXML(self::$xmlRepresentation->documentElement);

$this->assertEquals(
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
strval($customSignable),
);
}
}
13 changes: 0 additions & 13 deletions tests/XML/SignableElementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -253,17 +253,4 @@ public function testSigningWithDifferentRoot(): void
);
$customSignable->toXML($doc->documentElement);
}


/**
*/
public function testUnmarshalling(): void
{
$customSignable = CustomSignable::fromXML(self::$xmlRepresentation->documentElement);

$this->assertEquals(
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
strval($customSignable),
);
}
}
10 changes: 0 additions & 10 deletions tests/XML/ds/CanonicalizationMethodTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,4 @@ public function testMarshalling(): void
strval($canonicalizationMethod),
);
}


/**
*/
public function testUnmarshalling(): void
{
$canonicalizationMethod = CanonicalizationMethod::fromXML(self::$xmlRepresentation->documentElement);

$this->assertEquals(C::C14N_EXCLUSIVE_WITHOUT_COMMENTS, $canonicalizationMethod->getAlgorithm());
}
}
13 changes: 0 additions & 13 deletions tests/XML/ds/DigestMethodTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,4 @@ public function testMarshalling(): void
strval($digestMethod),
);
}


/**
*/
public function testUnmarshalling(): void
{
$digestMethod = DigestMethod::fromXML(self::$xmlRepresentation->documentElement);

$this->assertEquals(
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
strval($digestMethod),
);
}
}
13 changes: 0 additions & 13 deletions tests/XML/ds/DigestValueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,4 @@ public function testMarshallingNotBase64(): void
$this->expectException(AssertionFailedException::class);
new DigestValue('/CTj3d1DB5e2t7CTo9BEzCf5S9NRzwnBgZRlm32REI=');
}


/**
*/
public function testUnmarshalling(): void
{
$digestValue = DigestValue::fromXML(self::$xmlRepresentation->documentElement);

$this->assertEquals(
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
strval($digestValue),
);
}
}
13 changes: 0 additions & 13 deletions tests/XML/ds/ExponentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,4 @@ public function testMarshallingNotBase64(): void
$this->expectException(SchemaViolationException::class);
new Exponent('/CTj3d1DB5e2t7CTo9BEzCf5S9NRzwnBgZRlm32REI=');
}


/**
*/
public function testUnmarshalling(): void
{
$exponent = Exponent::fromXML(self::$xmlRepresentation->documentElement);

$this->assertEquals(
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
strval($exponent),
);
}
}
13 changes: 0 additions & 13 deletions tests/XML/ds/KeyInfoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,19 +120,6 @@ public function testMarshallingEmpty(): void
}


/**
*/
public function testUnmarshalling(): void
{
$keyInfo = KeyInfo::fromXML(self::$xmlRepresentation->documentElement);

$this->assertEquals(
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
strval($keyInfo),
);
}


/**
*/
public function testUnmarshallingEmpty(): void
Expand Down
13 changes: 0 additions & 13 deletions tests/XML/ds/KeyNameTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,4 @@ public function testMarshalling(): void
strval($keyName),
);
}


/**
*/
public function testUnmarshalling(): void
{
$keyName = KeyName::fromXML(self::$xmlRepresentation->documentElement);

$this->assertEquals(
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
strval($keyName),
);
}
}
13 changes: 0 additions & 13 deletions tests/XML/ds/KeyValueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,19 +121,6 @@ public function testMarshallingEmpty(): void
}


/**
*/
public function testUnmarshalling(): void
{
$keyValue = KeyValue::fromXML(self::$xmlRepresentation->documentElement);

$this->assertEquals(
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
strval($keyValue),
);
}


/**
*/
public function testUnmarshallingWithOtherElement(): void
Expand Down
13 changes: 0 additions & 13 deletions tests/XML/ds/ManifestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,4 @@ public function testMarshalling(): void
strval($manifest),
);
}


/**
*/
public function testUnmarshalling(): void
{
$manifest = Manifest::fromXML(self::$xmlRepresentation->documentElement);

$this->assertEquals(
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
strval($manifest),
);
}
}
10 changes: 0 additions & 10 deletions tests/XML/ds/ModulusTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,4 @@ public function testMarshallingNotBase64(): void
$this->expectException(SchemaViolationException::class);
new Modulus('/CTj3d1DB5e2t7CTo9BEzCf5S9NRzwnBgZRlm32REI=');
}


/**
*/
public function testUnmarshalling(): void
{
$modulus = Modulus::fromXML(self::$xmlRepresentation->documentElement);

$this->assertEquals('dGhpcyBpcyBzb21lIHJhbmRvbSBtb2R1bHVzCg==', $modulus->getContent());
}
}
13 changes: 0 additions & 13 deletions tests/XML/ds/ObjectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,6 @@ public function testMarshalling(): void
}


/**
*/
public function testUnmarshalling(): void
{
$obj = DsObject::fromXML(self::$xmlRepresentation->documentElement);

$this->assertEquals(
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
strval($obj)
);
}


/**
* Adding an empty Object-element should yield an empty element.
*/
Expand Down
13 changes: 0 additions & 13 deletions tests/XML/ds/RSAKeyValueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,4 @@ public function testMarshallingElementOrder(): void
$this->assertCount(1, $RSAKeyValueElements);
$this->assertEquals('ds:Exponent', $RSAKeyValueElements[0]->tagName);
}


/**
*/
public function testUnmarshalling(): void
{
$RSAKeyValue = RSAKeyValue::fromXML(self::$xmlRepresentation->documentElement);

$this->assertEquals(
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
strval($RSAKeyValue),
);
}
}
13 changes: 0 additions & 13 deletions tests/XML/ds/ReferenceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,17 +96,4 @@ public function testMarshallingReferenceElementOrdering(): void
$this->assertEquals('ds:DigestMethod', $children[1]->tagName);
$this->assertEquals('ds:DigestValue', $children[2]->tagName);
}


/**
*/
public function testUnmarshalling(): void
{
$reference = Reference::fromXML(self::$xmlRepresentation->documentElement);

$this->assertEquals(
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
strval($reference),
);
}
}
13 changes: 0 additions & 13 deletions tests/XML/ds/RetrievalMethodTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,4 @@ public function testMarshalling(): void
strval($retrievalMethod),
);
}


/**
*/
public function testUnmarshalling(): void
{
$retrievalMethod = retrievalMethod::fromXML(self::$xmlRepresentation->documentElement);

$this->assertEquals(
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
strval($retrievalMethod),
);
}
}
13 changes: 0 additions & 13 deletions tests/XML/ds/SignatureMethodTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,4 @@ public function testMarshalling(): void
strval($signatureMethod),
);
}


/**
*/
public function testUnmarshalling(): void
{
$signatureMethod = SignatureMethod::fromXML(self::$xmlRepresentation->documentElement);

$this->assertEquals(
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
strval($signatureMethod),
);
}
}
13 changes: 0 additions & 13 deletions tests/XML/ds/SignaturePropertiesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,4 @@ public function testMarshalling(): void
strval($signatureProperties)
);
}


/**
*/
public function testUnmarshalling(): void
{
$signatureProperties = SignatureProperties::fromXML(self::$xmlRepresentation->documentElement);

$this->assertEquals(
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
strval($signatureProperties)
);
}
}
13 changes: 0 additions & 13 deletions tests/XML/ds/SignaturePropertyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,4 @@ public function testMarshalling(): void
strval($signatureProperty)
);
}


/**
*/
public function testUnmarshalling(): void
{
$signatureProperty = SignatureProperty::fromXML(self::$xmlRepresentation->documentElement);

$this->assertEquals(
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
strval($signatureProperty)
);
}
}
27 changes: 0 additions & 27 deletions tests/XML/ds/SignatureTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,31 +144,4 @@ public function testMarshallingElementOrdering(): void
$this->assertEquals('ds:KeyInfo', $signatureElements[1]->tagName);
$this->assertEquals('ds:Object', $signatureElements[2]->tagName);
}


/**
* Test creating a SignatureValue object from XML.
*/
public function testUnmarshalling(): void
{
$signature = Signature::fromXML(self::$xmlRepresentation->documentElement);
$this->assertEquals('def456', $signature->getId());

$signedInfo = $signature->getSignedInfo();
$this->assertInstanceOf(SignedInfo::class, $signedInfo);

$signatureValue = $signature->getSignatureValue();
$this->assertInstanceOf(SignatureValue::class, $signatureValue);

$keyInfo = $signature->getKeyInfo();
$this->assertInstanceOf(KeyInfo::class, $keyInfo);

$objects = $signature->getObjects();
$this->assertCount(1, $objects);

$this->assertEquals(
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
strval($signature),
);
}
}
Loading

0 comments on commit 30f0153

Please sign in to comment.