From e198415c04f27ec45e912c357659280ba7f88402 Mon Sep 17 00:00:00 2001 From: Djoyke Reijans <115019123+DjoykeAbyah@users.noreply.github.com> Date: Tue, 30 Jul 2024 08:30:07 +0200 Subject: [PATCH] Update HmacSignatureTest.php Included tests for deprecated and corrected HMAC validation methods --- tests/Unit/Util/HmacSignatureTest.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/Unit/Util/HmacSignatureTest.php b/tests/Unit/Util/HmacSignatureTest.php index fda67040..8b861c98 100644 --- a/tests/Unit/Util/HmacSignatureTest.php +++ b/tests/Unit/Util/HmacSignatureTest.php @@ -153,9 +153,30 @@ public function testIsHmacSupportedEventCode() } /** + * @deprecated * @throws AdyenException */ public function testBankingWebhookHmacValidation() + { + $params = "{\"data\":{\"balancePlatform\":\"Integration_tools_test\"," + . "\"accountId\":\"BA32272223222H5HVKTBK4MLB\",\"sweep\":{\"id\":\"SWPC42272223222H5HVKV6H8C64DP5\"," + . "\"schedule\":{\"type\":\"balance\"},\"status\":\"active\",\"targetAmount\":{\"currency\":\"EUR\"" + . ",\"value\":0},\"triggerAmount\":{\"currency\":\"EUR\",\"value\":0},\"type\":\"pull\",\"counterparty\":" + . "{\"balanceAccountId\":\"BA3227C223222H5HVKT3H9WLC\"},\"currency\":\"EUR\"}},\"environment\":" + . "\"test\",\"type\":\"balancePlatform.balanceAccountSweep.updated\"}"; + $hmac = new HmacSignature(); + $result = $hmac->validateHMAC( + "9Qz9S/0xpar1klkniKdshxpAhRKbiSAewPpWoxKefQA=", + "D7DD5BA6146493707BF0BE7496F6404EC7A63616B7158EC927B9F54BB436765F", + $params + ); + self::assertTrue($result); + } + + /** + * @throws AdyenException + */ + public function testBankingWebhookHmacSignatureValidation() { $params = "{\"data\":{\"balancePlatform\":\"Integration_tools_test\"," . "\"accountId\":\"BA32272223222H5HVKTBK4MLB\",\"sweep\":{\"id\":\"SWPC42272223222H5HVKV6H8C64DP5\","