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

Add interfaces for data structures #13

Merged
merged 11 commits into from
May 30, 2019
Prev Previous commit
Next Next commit
test getSignedData for sign/login response
  • Loading branch information
Firehed committed May 30, 2019
commit 464077c45eca1b13f558bc8892055d20dbc66ce4
34 changes: 34 additions & 0 deletions tests/SignResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,40 @@ public function testFromJsonWithInvalidSignatureData()
SignResponse::fromJson($json);
}

/**
* @covers ::getSignedData
*/
public function testGetSignedData()
{
$json = file_get_contents(__DIR__ . '/sign_response.json');
assert($json !== false);
$response = SignResponse::fromJson($json);
print_r($response);

$expectedSignedData = sprintf(
'%s%s%s%s',
hash('sha256', 'https://u2f.ericstern.com', true),
"\x01", // user presence
"\x00\x00\x00\x2d", // counter (int(45))
hash(
'sha256',
'{'.
'"typ":"navigator.id.getAssertion",'.
'"challenge":"wt2ze8IskcTO3nIsO2D2hFjE5tVD041NpnYesLpJweg",'.
'"origin":"https://u2f.ericstern.com",'.
'"cid_pubkey":""'.
'}',
true
),
);

$this->assertSame(
$expectedSignedData,
$response->getSignedData(),
'Wrong signed data'
);
}

/**
* @dataProvider clientErrors
*/
Expand Down