-
Notifications
You must be signed in to change notification settings - Fork 129
Expand file tree
/
Copy pathMicrosoftOidcMetadataPolicyTest.php
More file actions
64 lines (55 loc) · 2.12 KB
/
MicrosoftOidcMetadataPolicyTest.php
File metadata and controls
64 lines (55 loc) · 2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
/*
* This file is part of the official PHP MCP SDK.
*
* A collaboration between Symfony and the PHP Foundation.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Mcp\Example\Server\OAuthMicrosoft\Tests\Unit;
use Mcp\Example\Server\OAuthMicrosoft\MicrosoftOidcMetadataPolicy;
use PHPUnit\Framework\Attributes\TestDox;
use PHPUnit\Framework\TestCase;
/**
* Tests MicrosoftOidcMetadataPolicy validation behavior.
*
* @author Volodymyr Panivko <sveneld300@gmail.com>
*/
class MicrosoftOidcMetadataPolicyTest extends TestCase
{
#[TestDox('metadata without code challenge methods is accepted')]
public function testMissingCodeChallengeMethodsIsAccepted(): void
{
$policy = new MicrosoftOidcMetadataPolicy();
$metadata = [
'authorization_endpoint' => 'https://auth.example.com/authorize',
'token_endpoint' => 'https://auth.example.com/token',
'jwks_uri' => 'https://auth.example.com/jwks',
];
$this->assertTrue($policy->isValid($metadata));
}
#[TestDox('malformed code challenge methods are ignored for validity')]
public function testMalformedCodeChallengeMethodsSupportedIsAccepted(): void
{
$policy = new MicrosoftOidcMetadataPolicy();
$metadata = [
'authorization_endpoint' => 'https://auth.example.com/authorize',
'token_endpoint' => 'https://auth.example.com/token',
'jwks_uri' => 'https://auth.example.com/jwks',
'code_challenge_methods_supported' => 'S256',
];
$this->assertTrue($policy->isValid($metadata));
}
#[TestDox('required endpoint fields still enforce validity')]
public function testIsValidRequiresCoreEndpoints(): void
{
$policy = new MicrosoftOidcMetadataPolicy();
$metadata = [
'authorization_endpoint' => 'https://auth.example.com/authorize',
// token_endpoint missing
'jwks_uri' => 'https://auth.example.com/jwks',
];
$this->assertFalse($policy->isValid($metadata));
}
}