SuperSeller3000/tests/Unit/Infrastructure/Channel/Ebay/EbayWebhookVerifierTest.php
Simon Kuehn a79791a972
Some checks are pending
CI / test (push) Waiting to run
style: apply CS Fixer formatting across codebase
Consistent brace style, spacing, and method expansion throughout
domain, infrastructure, and test files.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-19 10:56:37 +00:00

42 lines
1.3 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Tests\Unit\Infrastructure\Channel\Ebay;
use App\Infrastructure\Channel\Ebay\EbayWebhookVerifier;
use PHPUnit\Framework\TestCase;
final class EbayWebhookVerifierTest extends TestCase
{
private EbayWebhookVerifier $verifier;
protected function setUp(): void
{
$this->verifier = new EbayWebhookVerifier(
verificationToken: 'my-secret-token',
endpointUrl: 'https://example.com/webhooks/ebay',
);
}
public function testValidSignaturePasses(): void
{
$body = '{"notification":{"data":{"orderId":"123"}}}';
$expected = base64_encode(hash('sha256', $body.'my-secret-tokenhttps://example.com/webhooks/ebay', binary: true));
$this->assertTrue($this->verifier->verify($body, $expected));
}
public function testInvalidSignatureFails(): void
{
$this->assertFalse($this->verifier->verify('{"body":"x"}', 'invalidsignature'));
}
public function testChallengeResponseReturnsCorrectHash(): void
{
$challengeCode = 'abc123';
$expected = hash('sha256', $challengeCode.'my-secret-tokenhttps://example.com/webhooks/ebay');
$this->assertSame($expected, $this->verifier->challengeResponse($challengeCode));
}
}