Skip to content

Commit 5c39a2b

Browse files
committed
add test for thumb calculation based on the RFC example
1 parent 904cbee commit 5c39a2b

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tests/unit/Utils/DPOPTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,27 @@ final public function testGetWebIdWithDpop(): void
619619
$this->assertEquals(self::MOCK_SUBJECT, $actual);
620620
}
621621

622+
/**
623+
* @testdox makeJwkThumbprint test with a known key and expected result
624+
*
625+
* @covers ::makeJwkThumbprint
626+
*
627+
* @uses \Pdsinterop\Solid\Auth\Utils\DPop::makeJwkThumbprint
628+
*/
629+
final public function testMakeJwkThumbprint(): void
630+
{
631+
$mockJtiValidator = $this->createMockJtiValidator();
632+
$dpop = new DPop($mockJtiValidator);
633+
634+
// Example thumbprint calculation from https://www.rfc-editor.org/rfc/rfc7638#ref-SHS
635+
$jwk = json_decode('{"kty": "RSA","n": "0vx7agoebGcQSuuPiLJXZptN9nndrQmbXEps2aiAFbWhM78LhWx4cbbfAAtVT86zwu1RK7aPFFxuhDR1L6tSoc_BJECPebWKRXjBZCiFV4n3oknjhMstn64tZ_2W-5JsGY4Hc5n9yBXArwl93lqt7_RN5w6Cf0h4QyQ5v-65YGjQR0_FDW2QvzqY368QQMicAtaSqzs8KJZgnYb9c7d0zgdAZHzu6qMQvRL5hajrn1n91CbOpbISD08qNLyrdkt-bFTWhAI4vMQFh6WeZu0fM4lFd2NcRwr3XPksINHaQ-G_xBniIqbw0Ls1jF44-csFCur-kEgU8awapJzKnqDKgw","e": "AQAB","alg": "RS256","kid": "2011-04-29"}', true);
636+
$expectedThumbprint = 'NzbLsXh8uDCcd-6MNwXF4W_7noWXFZAfHkxZsRGC9Xs';
637+
638+
$actual = $dpop->makeJwkThumbprint($jwk);
639+
640+
$this->assertEquals($expectedThumbprint, $actual);
641+
}
642+
622643
////////////////////////////// MOCKS AND STUBS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\
623644

624645
private function createMockJtiValidator()

0 commit comments

Comments
 (0)