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

Commit

Permalink
Test login with incorrect signature
Browse files Browse the repository at this point in the history
  • Loading branch information
Firehed committed Oct 27, 2021
1 parent 0d7c57e commit d09d994
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions tests/ServerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -556,16 +556,15 @@ public function testAuthenticateThrowsIfNoRequestMatchesKeyHandle(): void

public function testValidateLoginThrowsIfSignatureIsInvalid(): void
{
$challenge = $this->getDefaultLoginChallenge();
$response = $this->getDefaultLoginResponse([
'getSignature' => 'some-other-signature',
]);
$registration = $this->getDefaultRegistration();
$request = $this->getDefaultSignRequest();
// Trimming a byte off the signature to cause a mismatch
$data = $this->readJsonFile('sign_response.json');
$data['signatureData'] = substr($data['signatureData'], 0, -1);
$response = SignResponse::fromJson($this->safeEncode($data));

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

/**
Expand Down

0 comments on commit d09d994

Please sign in to comment.