🚀 مُصادَق: تحديث وتطوير النظام 2026-05-03 13:49

This commit is contained in:
Hamza-Ayed
2026-05-03 13:49:16 +03:00
parent ad995352fc
commit f5f836551e
2 changed files with 24 additions and 23 deletions

View File

@@ -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));
}
}