🚀 مُصادَق: تحديث وتطوير النظام 2026-05-03 13:49
This commit is contained in:
@@ -23,9 +23,9 @@ final class HmacTest extends TestCase
|
||||
$timestamp = (string)time();
|
||||
$payload = json_encode(['foo' => 'bar']);
|
||||
|
||||
$signature = $this->service->sign($payload, $secret, $nonce, $timestamp);
|
||||
$signature = $this->service->sign($secret, 'POST', '/api/v1/test', $timestamp, $nonce, $payload);
|
||||
|
||||
$this->assertTrue($this->service->verify($payload, $signature, $secret, $nonce, $timestamp));
|
||||
$this->assertTrue($this->service->verify($secret, 'POST', '/api/v1/test', $timestamp, $nonce, $payload, $signature));
|
||||
}
|
||||
|
||||
public function test_it_rejects_tampered_payload(): void
|
||||
@@ -35,10 +35,10 @@ final class HmacTest extends TestCase
|
||||
$timestamp = (string)time();
|
||||
$payload = json_encode(['foo' => 'bar']);
|
||||
|
||||
$signature = $this->service->sign($payload, $secret, $nonce, $timestamp);
|
||||
$signature = $this->service->sign($secret, 'POST', '/api/v1/test', $timestamp, $nonce, $payload);
|
||||
|
||||
$tamperedPayload = json_encode(['foo' => 'baz']);
|
||||
|
||||
$this->assertFalse($this->service->verify($tamperedPayload, $signature, $secret, $nonce, $timestamp));
|
||||
$this->assertFalse($this->service->verify($secret, 'POST', '/api/v1/test', $timestamp, $nonce, $tamperedPayload, $signature));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user