Penambahan thema pada Menu Laporan per pintu pos
This commit is contained in:
42
tests/Unit/BcaSignatureTest.php
Normal file
42
tests/Unit/BcaSignatureTest.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit;
|
||||
|
||||
use Tests\TestCase;
|
||||
use App\Services\BcaSignatureService;
|
||||
|
||||
class BcaSignatureTest extends TestCase
|
||||
{
|
||||
public function test_generate_signature()
|
||||
{
|
||||
$service = new BcaSignatureService();
|
||||
|
||||
$method = 'POST';
|
||||
$relativeUrl = '/test/api';
|
||||
$accessToken = 'dummy_token';
|
||||
$timestamp = '2026-04-10T10:00:00.000+07:00';
|
||||
$apiSecret = 'secret123';
|
||||
|
||||
$body = json_encode([
|
||||
"foo" => "bar"
|
||||
]);
|
||||
|
||||
$result = $service->generateSignature(
|
||||
$method,
|
||||
$relativeUrl,
|
||||
$accessToken,
|
||||
$body,
|
||||
$timestamp,
|
||||
$apiSecret
|
||||
);
|
||||
|
||||
// Expected manual
|
||||
$expected = hash_hmac(
|
||||
'sha256',
|
||||
'POST:/test/api:dummy_token:' . hash('sha256', $body) . ':' . $timestamp,
|
||||
$apiSecret
|
||||
);
|
||||
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user