Skip to content

Commit

Permalink
feat: Add EncodingOptions::keySet getter
Browse files Browse the repository at this point in the history
  • Loading branch information
vincent4vx committed Aug 2, 2023
1 parent 146318a commit ef2bada
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/EncodingOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,16 @@ public function setHeader(string $key, $value): EncodingOptions
return $this;
}

/**
* Get the configured JWKS
*
* @return JWKSet
*/
public function keySet(): JWKSet
{
return $this->keySet;
}

/**
* Try to select a signature key
*
Expand Down
3 changes: 2 additions & 1 deletion tests/EncodingOptionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,14 @@ protected function setUp(): void

public function test_getter_setter()
{
$options = new EncodingOptions(new JWKSet([
$options = new EncodingOptions($jwks = new JWKSet([
JWKFactory::createFromKeyFile($this->privateKey, null, ['use' => 'sig', 'alg' => 'RS256']),
]));

$this->assertSame('RS256', $options->algorithm());
$this->assertNull($options->kid());
$this->assertSame(['alg' => 'RS256'], $options->headers());
$this->assertSame($jwks, $options->keySet());

$options
->setAlgorithm('RS512')
Expand Down

0 comments on commit ef2bada

Please sign in to comment.