Skip to content

Commit

Permalink
Issue #123 add test for generation of signature key.
Browse files Browse the repository at this point in the history
  • Loading branch information
judgej committed Jan 20, 2019
1 parent bbf1985 commit 7871bd3
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions tests/Message/DPMAuthorizeRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,37 @@ public function testGetData()
$this->assertArrayNotHasKey('x_test_request', $data);
}

/**
* Issue #123 test the signature key.
*/
public function testSha512hash()
{
$signatureKey =
'48D2C629E4A6D3E19AC47767C8B7EFEA4AE2004F8FA9C190F19D0238D871978B'
. 'E35925A6AD9256FE623934C1099DFEFD6449D54744E5734CE7CA3C4E6CD7223D';

$this->request->setSignatureKey($signatureKey);

$data = $this->request->getData();
$hash = $data['x_fp_hash'];

// Now check the hash.

$fingerprint = implode(
'^',
array(
$this->request->getApiLoginId(),
$data['x_fp_sequence'],
$data['x_fp_timestamp'],
$data['x_amount']
)
).'^';

$this->assertTrue(
hash_equals(hash_hmac('sha512', $fingerprint, hex2bin($signatureKey)), $hash)
);
}

public function testGetDataTestMode()
{
$this->request->setTestMode(true);
Expand Down

0 comments on commit 7871bd3

Please sign in to comment.