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

Commit

Permalink
More test updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Firehed committed Oct 27, 2021
1 parent 69e7573 commit d5ac233
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions tests/ServerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -293,15 +293,24 @@ public function testRegisterDefaultsToTryingEmptyCAList(): void

public function testRegisterThrowsIfChallengeDoesNotMatch(): void
{
// This would have come from a session, database, etc.
$request = (new RegisterRequest())
->setAppId('https://u2f.ericstern.com')
->setChallenge('some-other-challenge');
$challenge = $this->getDefaultRegistrationChallenge();
$response = $this->getDefaultRegistrationResponse([
'getChallenge' => 'some-other-challenge',
]);

$this->expectException(SecurityException::class);
$this->expectExceptionCode(SecurityException::CHALLENGE_MISMATCH);
$this->server->validateRegistration($challenge, $response);
}

public function testRegisterThrowsIfChallengeDoesNotMatchInverse(): void
{
$challenge = new Challenge('some-other-challenge');
$response = $this->getDefaultRegistrationResponse();

$this->expectException(SecurityException::class);
$this->expectExceptionCode(SecurityException::CHALLENGE_MISMATCH);
$this->server->validateRegistration($request, $response);
$this->server->validateRegistration($challenge, $response);
}

public function testRegisterThrowsWithUntrustedDeviceIssuerCertificate(): void
Expand Down Expand Up @@ -345,7 +354,6 @@ public function testRegisterWorksWithCAList(): void
public function testRegisterThrowsWithChangedApplicationParameter(): void
{
$challenge = $this->getDefaultRegistrationChallenge();

$response = $this->getDefaultRegistrationResponse([
'getRpIdHash' => hash('sha256', 'https://some.otherdomain.com', true),
]);
Expand Down Expand Up @@ -655,6 +663,9 @@ public function testRegistrationWithoutCidPubkeyBug14Case2(): void

// -( Helpers )------------------------------------------------------------

/**
* @deprecated
*/
private function getDefaultRegisterRequest(): RegisterRequest
{
// This would have come from a session, database, etc.
Expand Down Expand Up @@ -737,6 +748,9 @@ private function getDefaultRegistrationResponse(array $overrides = []): Registra
return $mock;
}

/**
* @deprecated
*/
private function getDefaultSignRequest(): SignRequest
{
// This would have come from a session, database, etc
Expand Down

0 comments on commit d5ac233

Please sign in to comment.