service = new HmacService(); } public function test_it_verifies_valid_signature(): void { $secret = 'test-secret'; $nonce = 'nonce-123'; $timestamp = (string)time(); $payload = json_encode(['foo' => 'bar']); $signature = $this->service->sign($payload, $secret, $nonce, $timestamp); $this->assertTrue($this->service->verify($payload, $signature, $secret, $nonce, $timestamp)); } public function test_it_rejects_tampered_payload(): void { $secret = 'test-secret'; $nonce = 'nonce-123'; $timestamp = (string)time(); $payload = json_encode(['foo' => 'bar']); $signature = $this->service->sign($payload, $secret, $nonce, $timestamp); $tamperedPayload = json_encode(['foo' => 'baz']); $this->assertFalse($this->service->verify($tamperedPayload, $signature, $secret, $nonce, $timestamp)); } }