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 f9b8ca7 commit 77f6a99
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/interoperability.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ 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
51 changes: 51 additions & 0 deletions tests/InterOperability/EntityDescriptorTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?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 [
'MicrosoftOnline' => [
true,
DOMDocumentFactory::fromFile('/tmp/metadata/microsoftonline.xml')->documentElement,
],
];
}
}

0 comments on commit 77f6a99

Please sign in to comment.