Skip to content

Commit

Permalink
[Maintenance] Remove deprecation notice
Browse files Browse the repository at this point in the history
  • Loading branch information
lchrusciel committed Dec 11, 2024
1 parent 88c81b8 commit ae24751
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 51 deletions.
15 changes: 2 additions & 13 deletions src/Tpay/Resolver/TpayTransactionChannelResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down
12 changes: 2 additions & 10 deletions src/Tpay/Security/Notification/Verifier/SignatureVerifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit ae24751

Please sign in to comment.