Skip to content

Commit

Permalink
Expand interoperability-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tvdijen committed Mar 24, 2024
1 parent 315e013 commit 15685b0
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/interoperability.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,13 @@ jobs:
mkdir -p /tmp/metadata
wget https://md.aai.grnet.gr/aggregates/grnet-metadata.xml -O /tmp/metadata/grnet.xml
- name: Download MicrosoftOnline metadata
if: steps.cache-metadata.outputs.cache-hit != 'true'
run: |
mkdir -p /tmp/metadata
wget https://nexus.microsoftonline-p.com/federationmetadata/saml20/federationmetadata.xml \
-O /tmp/metadata/microsoftonline.xml
- name: Run unit tests
run: |
./vendor/bin/phpunit -c phpunit-interoperability.xml
53 changes: 53 additions & 0 deletions tests/InterOperability/EntityDescriptorTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php

declare(strict_types=1);

namespace SimpleSAML\Test\SAML2;

use DOMElement;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use SimpleSAML\Assert\AssertionFailedException;
use SimpleSAML\SAML2\XML\md\EntityDescriptor;
use SimpleSAML\XML\DOMDocumentFactory;

/**
* Class \SimpleSAML\SAML2\EntityDescriptorTest
*
* @package simplesamlphp\saml2
*/
final class EntityDescriptorTest extends TestCase
{
/**
* @param boolean $shouldPass
* @param \DOMElement $metadata;
*/
#[DataProvider('provideMetadata')]
public function testUnmarshalling(bool $shouldPass, DOMElement $metadata): void
{
try {
EntityDescriptor::fromXML($metadata);
$this->assertTrue($shouldPass);
} catch (AssertionFailedException $e) {
fwrite(STDERR, $e->getFile() . '(' . strval($e->getLine()) . '):' . $e->getMessage());
fwrite(STDERR, $e->getTraceAsString());
$this->assertFalse($shouldPass);
}
}


/**
* @return array
*/
public static function provideMetadata(): array
{
return [
// Known bug: Microsoft doensn't produce a schema-valid XML
// This was reported to them in 2022: TrackingID#2210040050001949
'MicrosoftOnline' => [
true,
DOMDocumentFactory::fromFile('/tmp/metadata/microsoftonline.xml')->documentElement,
],
];
}
}

0 comments on commit 15685b0

Please sign in to comment.