Skip to content

Commit 6f2c287

Browse files
committed
WIP sig algs
1 parent 54f1f21 commit 6f2c287

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

src/Services/OpMetadataService.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,16 @@ public function __construct(
3939
*/
4040
private function initMetadata(): void
4141
{
42+
// Signature algorithms that this OP can use to sign JWS artifacts.
4243
$protocolSignatureAlgorithmNames = array_values(
4344
array_map(
4445
fn(SignatureKeyPair $signatureKeyPair): string => $signatureKeyPair->getSignatureAlgorithm()->value,
4546
$this->moduleConfig->getProtocolSignatureKeyPairBag()->getAll(),
4647
),
4748
);
4849

50+
// Signature algorithms that this OP can use to validate signature on
51+
// signed JWS artifacts.
4952
$supportedSignatureAlgorithmNames = array_values(
5053
array_map(
5154
fn(SignatureAlgorithmEnum $signatureAlgorithm): string => $signatureAlgorithm->value,

tests/unit/src/Services/OpMetadataServiceTest.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@
1111
use SimpleSAML\Module\oidc\ModuleConfig;
1212
use SimpleSAML\Module\oidc\Services\OpMetadataService;
1313
use SimpleSAML\Module\oidc\Utils\ClaimTranslatorExtractor;
14+
use SimpleSAML\OpenID\Algorithms\SignatureAlgorithmBag;
15+
use SimpleSAML\OpenID\Algorithms\SignatureAlgorithmEnum;
1416
use SimpleSAML\OpenID\Codebooks\ClaimsEnum;
17+
use SimpleSAML\OpenID\SupportedAlgorithms;
18+
use SimpleSAML\OpenID\ValueAbstracts\SignatureKeyPair;
19+
use SimpleSAML\OpenID\ValueAbstracts\SignatureKeyPairBag;
1520

1621
/**
1722
* @covers \SimpleSAML\Module\oidc\Services\OpMetadataService
@@ -20,6 +25,10 @@ class OpMetadataServiceTest extends TestCase
2025
{
2126
protected MockObject $moduleConfigMock;
2227
protected MockObject $claimTranslatorExtractorMock;
28+
protected MockObject $signatureAlgorithmBag;
29+
protected MockObject $supportedAlgorithmsMock;
30+
protected MockObject $signatureKeyPairBagMock;
31+
protected MockObject $signatureKeyPairMock;
2332

2433
/**
2534
* @throws \Exception
@@ -51,6 +60,28 @@ public function setUp(): void
5160
$this->moduleConfigMock->method('getProtocolSigner')->willReturn($signer);
5261

5362
$this->claimTranslatorExtractorMock = $this->createMock(ClaimTranslatorExtractor::class);
63+
64+
$this->signatureAlgorithmBag = $this->createMock(SignatureAlgorithmBag::class);
65+
$this->signatureAlgorithmBag->method('getAll')
66+
->willReturn([SignatureAlgorithmEnum::RS256]);
67+
68+
$this->supportedAlgorithmsMock = $this->createMock(SupportedAlgorithms::class);
69+
$this->supportedAlgorithmsMock->method('getSignatureAlgorithmBag')
70+
->willReturn($this->signatureAlgorithmBag);
71+
72+
$this->moduleConfigMock->method('getSupportedAlgorithms')
73+
->willReturn($this->supportedAlgorithmsMock);
74+
75+
$this->signatureKeyPairMock = $this->createMock(SignatureKeyPair::class);
76+
$this->signatureKeyPairMock->method('getSignatureAlgorithm')
77+
->willReturn(SignatureAlgorithmEnum::RS256);
78+
79+
$this->signatureKeyPairBagMock = $this->createMock(SignatureKeyPairBag::class);
80+
$this->signatureKeyPairBagMock->method('getAll')
81+
->willReturn([$this->signatureKeyPairMock]);
82+
83+
$this->moduleConfigMock->method('getProtocolSignatureKeyPairBag')
84+
->willReturn($this->signatureKeyPairBagMock);
5485
}
5586

5687
/**

0 commit comments

Comments
 (0)