Skip to content

Commit

Permalink
Merge pull request #562 from FatchipRobert/MAG2-324-HashFix
Browse files Browse the repository at this point in the history
MAG2-324 - Fixed a problem with hash function
  • Loading branch information
janteuber authored Sep 24, 2024
2 parents 0124ca7 + ff5f44f commit e960b85
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Helper/Toolkit.php
Original file line number Diff line number Diff line change
Expand Up @@ -264,12 +264,14 @@ public function generateUUIDv4()
* Returns a hashed string and defines a default through the sAlgorithm parameter
*
* @param string $sString
* @param string $sAlgorithm
* @param string $sKey
* @return string
*/
public function hashString($sString, $sAlgorithm = 'sha384', $sKey = false)
{
if ($sAlgorithm == "sha384" && $sKey !== false) {
return hash_hmac($sAlgorithm, $sString, $sKey);
return hash_hmac($sAlgorithm, $sString, $sKey ?? '');
}
return hash($sAlgorithm, $sString);
}
Expand Down
11 changes: 11 additions & 0 deletions Test/Unit/Helper/RatepayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,22 @@ public function testRefreshProfiles()
{
$aShopConfig = [['shop_id' => '12345', 'currency' => 'EUR']];
$this->scopeConfig->method('getValue')->willReturn(json_encode($aShopConfig));
$this->profile->method('sendRequest')->willReturn(['status' => 'OK']);

$result = $this->classToTest->refreshProfiles('payone_ratepay_invoice');
$this->assertNull($result);
}

public function testRefreshProfilesException()
{
$aShopConfig = [['shop_id' => '12345', 'currency' => 'EUR']];
$this->scopeConfig->method('getValue')->willReturn(json_encode($aShopConfig));
$this->profile->method('sendRequest')->willReturn(['status' => 'ERROR']);

$this->expectException(\Exception::class);
$this->classToTest->refreshProfiles('payone_ratepay_invoice');
}

public function testGetRatepayDeviceFingerprintToken()
{
$this->checkoutSession->method('getPayoneRatepayDeviceFingerprintToken')->willReturn(null);
Expand Down

0 comments on commit e960b85

Please sign in to comment.