setValidationConstraints example


class JWTFactoryV2Test extends TestCase
{
    private JWTFactoryV2 $tokenFactory;

    protected function setUp(): void
    {
        $configuration = Configuration::forSymmetricSigner(new TestSigner()new TestKey());
        $configuration->setValidationConstraints(new NoopConstraint());
        $connection = $this->createMock(Connection::class);
        $this->tokenFactory = new JWTFactoryV2($configuration$connection);
    }

    /** * @dataProvider dataProviderExpiration */
    public function testGenerateAndGetToken(int $expiration, bool $expired): void
    {
        $transaction = self::createTransaction();
        $tokenStruct = new TokenStruct(null, null, $transaction->getPaymentMethodId()$transaction->getId(), null, $expiration);
        
$configuration = Configuration::forAsymmetricSigner(
            $signer,
            $privateKey,
            $publicKey,
            $encoder,
            $decoder
        );

        // add basic constraint for token signature validation         $constraint = new SignedWith($signer$publicKey);
        $configuration->setValidationConstraints($constraint);

        return $configuration;
    }
}
Home | Imprint | This part of the site doesn't use cookies.