Skip to content
This repository has been archived by the owner on Mar 25, 2024. It is now read-only.

Finish deprecation of all U2F-specific classes #36

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
More updates
  • Loading branch information
Firehed committed Oct 27, 2021
commit b0034c0e3fbd513142a0ae4ca7d70991cc0e78da
22 changes: 14 additions & 8 deletions tests/ServerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -521,17 +521,15 @@ public function testValidateLoginThrowsWhenChallengeDoesNotMatch(): void
public function testValidateLoginThrowsIfNoRegistrationMatchesKeyHandle(): void
{
// Change registration KH
$registration = (new Registration())
->setKeyHandle(fromBase64Web('some-other-key-handle'))
->setPublicKey($this->getDefaultPublicKey())
->setCounter(2)
;
$request = $this->getDefaultSignRequest();
$registration = $this->getDefaultRegistration([
'keyHandle' => 'some-other-key-handle',
]);
$challenge = $this->getDefaultLoginChallenge();
$response = $this->getDefaultLoginResponse();

$this->expectException(SecurityException::class);
$this->expectExceptionCode(SecurityException::KEY_HANDLE_UNRECOGNIZED);
$this->server->validateLogin($request, $response, [$registration]);
$this->server->validateLogin($challenge, $response, [$registration]);
}

/**
Expand Down Expand Up @@ -763,17 +761,25 @@ private function getDefaultLoginChallenge(): ChallengeProviderInterface
/**
* @param array{
* counter?: int,
* keyHandle?: string,
* } $overrides
*/
private function getDefaultRegistration(array $overrides = []): RegistrationInterface
{
$defaults = [
'counter' => 2,
'keyHandle' => fromBase64Web(self::ENCODED_KEY_HANDLE),
];
/**
* @var array{
* counter: int,
* keyHandle: string,
* } (phpstan/phpstan#5846)
*/
$data = array_merge($defaults, $overrides);
// From database attached to the authenticating user
return (new Registration())
->setKeyHandle(fromBase64Web(self::ENCODED_KEY_HANDLE))
->setKeyHandle($data['keyHandle'])
->setAttestationCertificate($this->getDefaultAttestationCertificate())
->setPublicKey($this->getDefaultPublicKey())
->setCounter($data['counter'])
Expand Down