From ae24751aa703cfd6a08ee1275c6b889a687064c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Chru=C5=9Bciel?= Date: Wed, 11 Dec 2024 17:58:51 +0100 Subject: [PATCH] [Maintenance] Remove deprecation notice --- .../TpayTransactionChannelResolver.php | 15 ++-------- .../Verifier/SignatureVerifier.php | 12 ++------ .../Verifier/SignatureVerifierTest.php | 28 ------------------- 3 files changed, 4 insertions(+), 51 deletions(-) diff --git a/src/Tpay/Resolver/TpayTransactionChannelResolver.php b/src/Tpay/Resolver/TpayTransactionChannelResolver.php index ab145ba0..555cc513 100644 --- a/src/Tpay/Resolver/TpayTransactionChannelResolver.php +++ b/src/Tpay/Resolver/TpayTransactionChannelResolver.php @@ -6,8 +6,6 @@ use CommerceWeavers\SyliusTpayPlugin\PayByLinkPayment\Payum\Factory\GatewayFactory; use CommerceWeavers\SyliusTpayPlugin\PayByLinkPayment\Payum\Factory\GetTpayTransactionsChannelsFactoryInterface; -use CommerceWeavers\SyliusTpayPlugin\PayByLinkPayment\Payum\Request\GetTpayTransactionsChannels; -use Payum\Core\Model\ArrayObject; use Payum\Core\Payum; use Psr\Log\LoggerInterface; use Tpay\OpenApi\Utilities\TpayException; @@ -16,25 +14,16 @@ final class TpayTransactionChannelResolver implements TpayTransactionChannelReso { public function __construct( private readonly Payum $payum, - private readonly ?GetTpayTransactionsChannelsFactoryInterface $getTpayTransactionsChannelsFactory = null, + private readonly GetTpayTransactionsChannelsFactoryInterface $getTpayTransactionsChannelsFactory, private readonly ?LoggerInterface $logger = null, ) { - if (null === $this->getTpayTransactionsChannelsFactory) { - trigger_deprecation( - 'commerce-weavers/sylius-tpay-plugin', - '1.0', - 'Not passing a $getTpayTransactionsChannelsFactory to %s constructor is deprecated and will be removed in SyliusTpayPlugin 2.0.', - self::class, - ); - } } public function resolve(): array { $gateway = $this->payum->getGateway(GatewayFactory::NAME); - $value = $this->getTpayTransactionsChannelsFactory?->createNewEmpty() - ?? new GetTpayTransactionsChannels(new ArrayObject()); + $value = $this->getTpayTransactionsChannelsFactory->createNewEmpty(); try { $gateway->execute($value, true); diff --git a/src/Tpay/Security/Notification/Verifier/SignatureVerifier.php b/src/Tpay/Security/Notification/Verifier/SignatureVerifier.php index 9f3c4732..5ba44814 100644 --- a/src/Tpay/Security/Notification/Verifier/SignatureVerifier.php +++ b/src/Tpay/Security/Notification/Verifier/SignatureVerifier.php @@ -17,16 +17,8 @@ public function __construct( private readonly CertificateResolverInterface $certificateResolver, private readonly TrustedCertificateResolverInterface $trustedCertificateResolver, private readonly X509FactoryInterface $x509Factory, - private readonly ?ProductionModeCheckerInterface $productionModeChecker = null, + private readonly ProductionModeCheckerInterface $productionModeChecker, ) { - if (null === $this->productionModeChecker) { - trigger_deprecation( - 'commerce-weavers/sylius-tpay-plugin', - '1.0', - 'Not passing a $productionModeChecker to %s constructor is deprecated and will be removed in SyliusTpayPlugin 2.0.', - self::class, - ); - } } public function verify(string $jws, string $requestContent): bool @@ -52,7 +44,7 @@ public function verify(string $jws, string $requestContent): bool throw new InvalidSignatureException('Missing x5u header'); } - $production = $this->productionModeChecker?->isProduction($x5u) ?? false; + $production = $this->productionModeChecker->isProduction($x5u); $certificate = $this->certificateResolver->resolve($x5u); $trusted = $this->trustedCertificateResolver->resolve($production); diff --git a/tests/Unit/Tpay/Security/Notification/Verifier/SignatureVerifierTest.php b/tests/Unit/Tpay/Security/Notification/Verifier/SignatureVerifierTest.php index a26716cf..79393a6b 100644 --- a/tests/Unit/Tpay/Security/Notification/Verifier/SignatureVerifierTest.php +++ b/tests/Unit/Tpay/Security/Notification/Verifier/SignatureVerifierTest.php @@ -132,34 +132,6 @@ public function test_it_returns_false_when_jws_is_invalid(): void $this->assertFalse($isJwsValid); } - public function test_it_supports_legacy_behaviour_if_production_mode_checker_is_not_passed(): void - { - $header = base64_encode(json_encode(['x5u' => 'https://cw.x5u'])); - $encodedRequestContent = str_replace('=', '', strtr(base64_encode('request content'), '+/', '-_')); - $signature = base64_encode('sigmature'); - - $jws = sprintf('%s.non_used_value.%s', $header, $signature); - - $this->certificateResolver->resolve('https://cw.x5u')->willReturn('cert'); - $this->trustedCertificateResolver->resolve(false)->willReturn('trusted_cert'); - - $this->x509->loadX509('cert')->shouldBeCalled(); - $this->x509->loadCA('trusted_cert')->shouldBeCalled(); - $this->x509->validateSignature()->willReturn(true); - $this->x509->withSettings($this->publicKey, 'sha256', RSA::SIGNATURE_PKCS1)->willReturn($this->publicKey); - - $this->publicKey->verify(sprintf('%s.%s', $header, $encodedRequestContent), 'sigmature')->willReturn(true); - - $signatureVerifier = new SignatureVerifier( - $this->certificateResolver->reveal(), - $this->trustedCertificateResolver->reveal(), - $this->x509Factory->reveal(), - ); - $isJwsValid = $signatureVerifier->verify($jws, 'request content'); - - $this->assertTrue($isJwsValid); - } - private function createTestSubject(): SignatureVerifierInterface { return new SignatureVerifier(