Skip to content

Commit c67c9d5

Browse files
committed
Fix test & migrate to phpunit attributes
1 parent 9e927db commit c67c9d5

1 file changed

Lines changed: 7 additions & 38 deletions

File tree

tests/src/Controller/AttributeServerTest.php

Lines changed: 7 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,21 @@
44

55
namespace SimpleSAML\Test\Module\exampleattributeserver\Controller;
66

7+
use PHPUnit\Framework\Attributes\CoversClass;
78
use PHPUnit\Framework\TestCase;
89
use SimpleSAML\Configuration;
910
use SimpleSAML\HTTP\RunnableResponse;
1011
use SimpleSAML\Metadata\MetaDataStorageHandler;
11-
use SimpleSAML\Module\exampleattributeserver\Controller;
12+
use SimpleSAML\Module\exampleattributeserver\Controller\AttributeServer;
13+
use SimpleSAML\XMLSecurity\TestUtils\PEMCertificatesMock;
1214
use Symfony\Component\HttpFoundation\Request;
1315

1416
/**
1517
* Set of tests for the controllers in the "exampleattributeserver" module.
1618
*
17-
* @covers \SimpleSAML\Module\exampleattributeserver\Controller\AttributeServer
18-
* @package SimpleSAML\Test
19+
* @package simplesamlphp/simplesamlphp-module-exampleattributeserver
1920
*/
21+
#[CoversClass(AttributeServer::class)]
2022
class ExampleAttributeServerTest extends TestCase
2123
{
2224
/** @var \SimpleSAML\Configuration */
@@ -61,44 +63,11 @@ public function testMain(): void
6163
$mdh->method('getMetaDataConfig')->willReturn(Configuration::loadFromArray([
6264
'EntityID' => 'auth_source_id',
6365
'testAttributeEndpoint' => 'test',
64-
'privatekey' => dirname(__FILE__, 4) . '/vendor/simplesamlphp/xml-security/resources/keys/selfsigned.simplesamlphp.org.key',
66+
'privatekey' => PEMCertificatesMock::buildKeysPath(PEMCertificatesMock::SELFSIGNED_PRIVATE_KEY),
6567
'privatekey_pass' => '1234',
6668
]));
67-
/**
68-
$mdh = new class () extends MetaDataStorageHandler {
69-
public function __construct()
70-
{
71-
}
72-
73-
public function getMetaDataCurrentEntityID(string $set, string $type = 'entityid'): string
74-
{
75-
return 'localhost/simplesaml';
76-
}
77-
78-
public function getMetaData(?string $entityId, string $set): array
79-
{
80-
return [
81-
'https://example.org/' => ['testAttributeEndpoint' => []]
82-
];
83-
}
84-
85-
public function getList(string $set = 'saml20-idp-hosted', bool $showExpired = false): array
86-
{
87-
if ($set === 'saml20-idp-hosted') {
88-
return [
89-
0 => [
90-
'name' => 'SimpleSAMLphp Hosted IDP',
91-
'descr' => 'The local IDP',
92-
'OrganizationDisplayName' => ['en' => 'My IDP', 'nl' => 'Mijn IDP']
93-
]
94-
];
95-
}
96-
return [];
97-
}
98-
};
99-
*/
10069

101-
$c = new Controller\AttributeServer(self::$config);
70+
$c = new AttributeServer(self::$config);
10271
$c->setMetadataStorageHandler($mdh);
10372
$response = $c->main($request);
10473

0 commit comments

Comments
 (0)