SuperSeller3000/tests/Unit/Infrastructure/Channel/Ebay/EbayWebhookVerifierTest.php
Simon Kuehn 46cff4553f feat: add eBay and Frappe channel adapters with order infrastructure
eBay adapter covers OAuth, inventory API, fulfillment API, taxonomy
service and webhook signature verification. Frappe ERP adapter wraps
the Frappe HTTP client for order/invoice sync.

Includes CustomerResolver, InvoiceMailer, and the EbayWebhookController
for inbound eBay marketplace notifications.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-17 22:43:52 +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 test_valid_signature_passes(): 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 test_invalid_signature_fails(): void
{
$this->assertFalse($this->verifier->verify('{"body":"x"}', 'invalidsignature'));
}
public function test_challenge_response_returns_correct_hash(): void
{
$challengeCode = 'abc123';
$expected = hash('sha256', $challengeCode.'my-secret-tokenhttps://example.com/webhooks/ebay');
$this->assertSame($expected, $this->verifier->challengeResponse($challengeCode));
}
}