From 0b0075ff3762d245e6a8110d51320ca3cbe553e1 Mon Sep 17 00:00:00 2001 From: Filefabrik Date: Wed, 25 Nov 2026 13:08:17 +0100 Subject: [PATCH 01/13] mutation tests v1.10.11 --- src/Rfc9421/Verify/AbstractVerifyPrepare.php | 2 +- tests/Rfc9421/VerifyRequestPrepareTest.php | 86 ++++++++++++++++---- 2 files changed, 73 insertions(+), 15 deletions(-) diff --git a/src/Rfc9421/Verify/AbstractVerifyPrepare.php b/src/Rfc9421/Verify/AbstractVerifyPrepare.php index 058451d..5e3cc53 100644 --- a/src/Rfc9421/Verify/AbstractVerifyPrepare.php +++ b/src/Rfc9421/Verify/AbstractVerifyPrepare.php @@ -127,7 +127,7 @@ protected function getExtractedMetadataArray(): array * @throws \Filefabrik\Rfc9421\Exceptions\UnexpectedValue * @throws \Filefabrik\Rfc9421\Exceptions\VerifyHeaderSignatureException */ - protected function getSignaturInputInstance(): HeaderSignatureInput + private function getSignaturInputInstance(): HeaderSignatureInput { $headerSignatureInstance = new HeaderSignatureInput( headerSignatureInputValue: $this->headerHelper diff --git a/tests/Rfc9421/VerifyRequestPrepareTest.php b/tests/Rfc9421/VerifyRequestPrepareTest.php index d62b5dd..e8df90c 100644 --- a/tests/Rfc9421/VerifyRequestPrepareTest.php +++ b/tests/Rfc9421/VerifyRequestPrepareTest.php @@ -16,6 +16,7 @@ use Filefabrik\Rfc9421\Enums\DigestAlgorithmsEnum; use Filefabrik\Rfc9421\Enums\SigningEnum; use Filefabrik\Rfc9421\Exceptions\VerifyHeaderSignatureException; +use Filefabrik\Rfc9421\Extractors\HeaderSignature; use Filefabrik\Rfc9421\RequestSigner; use Filefabrik\Rfc9421\SigningComponents; use Filefabrik\Rfc9421\SigningConfiguration; @@ -78,13 +79,13 @@ public static function withSigningMethods(): array */ #[DataProvider('withSigningMethods')] public function testPrepareVerify(string|SigningEnum $signingAlgo, string $cert): void - { require_once dirname(__DIR__, 2).'/src/register-openssl-signing-verify.php'; + { + require_once dirname(__DIR__, 2).'/src/register-openssl-signing-verify.php'; $certInstance = new CertHelper($cert); $signatureKeyName = 'testing='; $signingComponents = new SigningComponents()->sign('@method') ->sign('@authority') - ; /** * Prepare signingConfiguration @@ -167,8 +168,6 @@ public function testPrepareVerifyWithContentDigest(string|SigningEnum $signingAl $signatureKeyName = 'testing='; $signatureComponents = new SigningComponents()->sign('@method') ->sign('@authority') - - ; /** * Prepare signingConfiguration @@ -176,15 +175,15 @@ public function testPrepareVerifyWithContentDigest(string|SigningEnum $signingAl $currentDateTime = new DateTime()->getTimestamp(); $configuration = new SigningConfiguration(signingComponents: $signatureComponents); $configuration - ->setSigningAlgorithm($signingAlgo) - ->setCreated($currentDateTime) - ->setExpires($currentDateTime + 7200) - ->setTag('mastodon') - ->withNonce('nonce-now') - ->setSignatureKeyName($signatureKeyName) - ->withContentDigest(DigestAlgorithmsEnum::sha512) + ->setSigningAlgorithm($signingAlgo) + ->setCreated($currentDateTime) + ->setExpires($currentDateTime + 7200) + ->setTag('mastodon') + ->withNonce('nonce-now') + ->setSignatureKeyName($signatureKeyName) + ->withContentDigest(DigestAlgorithmsEnum::sha512) // for signing needs private - ->setPrivatePem($certInstance->getPrivatPemContent()) + ->setPrivatePem($certInstance->getPrivatPemContent()) ; /** @@ -323,8 +322,7 @@ public function testGetSignatureInputInstance(): void $certInstance = new CertHelper('rsa'); $signatureComponents = new SigningComponents()->sign('@method') - ->sign('@authority') - /* + ->sign('@authority')/* * todo check duplicate content-digest * ->withHeader('content-digest') */ @@ -372,4 +370,64 @@ public function testGetHeaderHelper(): void self::assertInstanceOf(HeaderHelper::class, $prepareVerifierInstance->getHeaderHelper()); } + /** + * @throws \Filefabrik\Rfc9421\Exceptions\MethodException + * @throws \Filefabrik\Rfc9421\Exceptions\ProcessingException + * @throws \Filefabrik\Rfc9421\Exceptions\StructuredFieldException + * @throws \Filefabrik\Rfc9421\Exceptions\VerifyHeaderSignatureException + * @throws \Filefabrik\Rfc9421\Exceptions\SignatureExtractionException + * @throws \Filefabrik\Rfc9421\Exceptions\EnumTypeException + * @throws \Filefabrik\Rfc9421\Exceptions\InvalidHeaderKeyException + * @throws \Filefabrik\Rfc9421\Exceptions\PrepareMethodsException + * @throws \Filefabrik\Rfc9421\Exceptions\UnexpectedValue + * @throws \Filefabrik\Rfc9421\Exceptions\EmptyException + * @throws \JsonException + * @throws \Filefabrik\Rfc9421\Exceptions\ContentDigestException + * @throws \Filefabrik\Rfc9421\Exceptions\AlreadySetException + * @throws \Filefabrik\Rfc9421\Exceptions\SignatureException + */ + public function testGetHeaderSignatureExtractor() + { + $certInstance = new CertHelper('rsa'); + + $signatureComponents = new SigningComponents()->sign('@method') + ->sign('@authority')/* + * todo check duplicate content-digest + * ->withHeader('content-digest') + */ + + ; + $signatureKeyName = 'testing='; + $bodyParams = ['recipient' => 'Alex', 'amount' => 900, 'currency' => 'EUR']; + $bodyJson = json_encode($bodyParams, JSON_THROW_ON_ERROR); + $request = new Request( + method : 'POST', + uri : 'https://target-host.com', + headers: ['x-origin-host' => 'target-host.com'], + body : $bodyJson, + ); + $currentDateTime = new DateTime()->getTimestamp(); + $configuration = new SigningConfiguration(signingComponents: $signatureComponents); + $configuration + ->setSigningAlgorithm(SigningEnum::rsa_v_1_5_sha_256) + ->setCreated($currentDateTime) + ->setExpires($currentDateTime + 7200) + ->setTag('mastodon') + ->withNonce('nonce-now') + ->setSignatureKeyName($signatureKeyName) + ->setContentDigestAlgo(DigestAlgorithmsEnum::sha512) + // for signing needs private + ->setPrivatePem($certInstance->getPrivatPemContent()) + ; + + $signer = new RequestSigner($request, $configuration); + $signedRequest = $signer->sign(); + $prepareVerifierInstance = new VerifyRequestPrepare( + message : $signedRequest, + signingConfiguration: new SigningConfiguration(), + ); + $prepareVerifierInstance->prepareVerification(); + $hs = $prepareVerifierInstance->getHeaderSignatureExtractor(); + self::assertTrue($hs instanceof HeaderSignature); + } } From 3c5bd142db020d910573eaaa8d8f4cd8b9b783dd Mon Sep 17 00:00:00 2001 From: Filefabrik Date: Wed, 25 Nov 2026 13:12:51 +0100 Subject: [PATCH 02/13] mutation tests v1.10.11 --- src/Rfc9421/Verify/AbstractVerifying.php | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/Rfc9421/Verify/AbstractVerifying.php b/src/Rfc9421/Verify/AbstractVerifying.php index cea814e..43407f7 100644 --- a/src/Rfc9421/Verify/AbstractVerifying.php +++ b/src/Rfc9421/Verify/AbstractVerifying.php @@ -54,8 +54,8 @@ public function verifying(): bool $preparedSigningConfiguration = $this->getVerifySigningConfiguration(); $preparedSigningConfiguration->setSigningComponents( components: $this->preparedVerify - ->getSignatureInputInstance() - ->getExtractedComponents(), + ->getSignatureInputInstance() + ->getExtractedComponents(), ); $contentDigestResult = $this->verifyContentDigestIfNeed($preparedSigningConfiguration); @@ -100,22 +100,19 @@ private function verifyContentDigestIfNeed(SigningConfiguration $signingConfigur // Validates the Content digest if needed from signature-line sig1=("content-digest") if ($signingConfiguration->hasContentDigestHashAlgo()) { if (!$this->validateContentDigest()) { - $this->hasSignedBody = false; - // todo logging the error that validate content digest is wrong - return false; + return $this->hasSignedBody = false; } // was signed and is valid $this->hasSignedBody = true; } - if(null===$this->hasSignedBody){ + if (null === $this->hasSignedBody) { // content-digest was not part of the signing process $this->hasSignedBody = false; } - // return true so tell we have no validation error return true; } @@ -128,8 +125,8 @@ private function verifyContentDigestIfNeed(SigningConfiguration $signingConfigur private function validateContentDigest(): bool { $contentDigestLine = $this->preparedVerify - ->getHeaderHelper() - ->getContentDigestLine() + ->getHeaderHelper() + ->getContentDigestLine() ; $verifyInstance = new VerifyContentDigest( @@ -149,8 +146,8 @@ abstract protected function getSigner(): RequestSigner|ResponseSigner; private function getBinarySignatureValue(): string { return $this->preparedVerify - ->getHeaderSignatureExtractor() - ->getBinarySignatureValue() + ->getHeaderSignatureExtractor() + ->getBinarySignatureValue() ; } From 28eeefa825c149320fff6d67bd0fbd981b287b80 Mon Sep 17 00:00:00 2001 From: Filefabrik Date: Wed, 25 Nov 2026 13:18:30 +0100 Subject: [PATCH 03/13] mutation tests v1.10.11 --- src/Rfc9421/Verify/AbstractVerifying.php | 5 ++++- tests/Rfc9421/VerifyRequestTest.php | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Rfc9421/Verify/AbstractVerifying.php b/src/Rfc9421/Verify/AbstractVerifying.php index 43407f7..ed597c3 100644 --- a/src/Rfc9421/Verify/AbstractVerifying.php +++ b/src/Rfc9421/Verify/AbstractVerifying.php @@ -156,7 +156,10 @@ private function getBinarySignatureValue(): string */ public function getSignedHeaderLines(): ReadLines { - return $this->signedHeaderLines ?? throw ProcessingException::SignedHeaderLines(); + if ($this->signedHeaderLines instanceof ReadLines) { + return $this->signedHeaderLines; + } + throw ProcessingException::SignedHeaderLines(); } abstract public function getMessage(): MessageInterface; diff --git a/tests/Rfc9421/VerifyRequestTest.php b/tests/Rfc9421/VerifyRequestTest.php index 1ac0e25..ad1cd33 100644 --- a/tests/Rfc9421/VerifyRequestTest.php +++ b/tests/Rfc9421/VerifyRequestTest.php @@ -17,6 +17,7 @@ use Filefabrik\Rfc9421\Enums\SigningEnum; use Filefabrik\Rfc9421\Exceptions\ProcessingException; use Filefabrik\Rfc9421\RequestSigner; +use Filefabrik\Rfc9421\Signer\Signatures\ReadLines; use Filefabrik\Rfc9421\SigningComponents; use Filefabrik\Rfc9421\SigningConfiguration; use Filefabrik\Rfc9421\VerifyRequest; @@ -117,6 +118,7 @@ public function testValidate(string|SigningEnum $signingAlgo, string $cert): voi self::assertEquals(1, $verifier->verifying()); // must be true because body(content-digest) was part of the signing process self::assertTrue($verifier->hasSignedBody()); + self::assertInstanceOf(ReadLines::class,$verifier->getSignedHeaderLines()); } /** From 9b4bcf5818c5d449ef111bd4ace78309c738396f Mon Sep 17 00:00:00 2001 From: Filefabrik Date: Wed, 25 Nov 2026 14:16:19 +0100 Subject: [PATCH 04/13] mutation tests v1.10.11 --- src/Rfc9421/Verify/AbstractVerifyPrepare.php | 10 ++- .../Rfc9421/Enums/InitialContentsEnumTest.php | 8 ++ tests/Rfc9421/VerifyRequestPrepareTest.php | 74 ++++++++++++++++++- 3 files changed, 87 insertions(+), 5 deletions(-) diff --git a/src/Rfc9421/Verify/AbstractVerifyPrepare.php b/src/Rfc9421/Verify/AbstractVerifyPrepare.php index 5e3cc53..6d12484 100644 --- a/src/Rfc9421/Verify/AbstractVerifyPrepare.php +++ b/src/Rfc9421/Verify/AbstractVerifyPrepare.php @@ -113,11 +113,13 @@ public function getHeaderSignatureExtractor(): HeaderSignature * @throws \Filefabrik\Rfc9421\Exceptions\VerifyHeaderSignatureException * @return array{}|array{created?: int, expires?: int, nonce?: string, keyid?: string, alg?: string, tag?: string} */ - protected function getExtractedMetadataArray(): array + private function getExtractedMetadataArray(): array { - return $this->getSignaturInputInstance()->extractedMetadata?->toArray() ?? throw new UnexpectedValue( - 'No Metadata Found', - ); + $toArray = $this->getSignaturInputInstance()->extractedMetadata?->toArray(); + if (is_array($toArray)) { + return $toArray; + } + throw new UnexpectedValue('No Metadata Found'); } /** diff --git a/tests/Rfc9421/Enums/InitialContentsEnumTest.php b/tests/Rfc9421/Enums/InitialContentsEnumTest.php index 61278c7..c25c9d5 100644 --- a/tests/Rfc9421/Enums/InitialContentsEnumTest.php +++ b/tests/Rfc9421/Enums/InitialContentsEnumTest.php @@ -54,6 +54,14 @@ public function testIsOwnTypeOrNullOrThrowException(): void InitialContentsEnum::isOwnTypeOrNullOrThrow('nothing'); } + /** + * @throws \Filefabrik\Rfc9421\Exceptions\EnumTypeException + */ + public function testIsOwnTypeOrNullOrThrowNull(): void + { + self::assertNull(InitialContentsEnum::isOwnTypeOrNullOrThrow(null)); + } + /** * @throws \Filefabrik\Rfc9421\Exceptions\EnumTypeException */ diff --git a/tests/Rfc9421/VerifyRequestPrepareTest.php b/tests/Rfc9421/VerifyRequestPrepareTest.php index e8df90c..acba742 100644 --- a/tests/Rfc9421/VerifyRequestPrepareTest.php +++ b/tests/Rfc9421/VerifyRequestPrepareTest.php @@ -220,6 +220,10 @@ public function testPrepareVerifyWithContentDigest(string|SigningEnum $signingAl * now prepare the verify process */ self::assertTrue($prepareVerifierInstance->prepareVerification()); + self::assertSame( + DigestAlgorithmsEnum::sha512, + $prepareVerifierInstance->signingConfiguration->contentDigestAlgo, + ); } /** @@ -251,6 +255,74 @@ public function testValidateThrowMissingSignatureInput(): void self::assertTrue($prepareVerifierInstance->prepareVerification()); } + /** + * @throws \Filefabrik\Rfc9421\Exceptions\AlreadySetException + * @throws \Filefabrik\Rfc9421\Exceptions\ContentDigestException + * @throws \Filefabrik\Rfc9421\Exceptions\EmptyException + * @throws \Filefabrik\Rfc9421\Exceptions\EnumTypeException + * @throws \Filefabrik\Rfc9421\Exceptions\InvalidHeaderKeyException + * @throws \Filefabrik\Rfc9421\Exceptions\MethodException + * @throws \Filefabrik\Rfc9421\Exceptions\PrepareMethodsException + * @throws \Filefabrik\Rfc9421\Exceptions\ProcessingException + * @throws \Filefabrik\Rfc9421\Exceptions\SignatureException + * @throws \Filefabrik\Rfc9421\Exceptions\SignatureExtractionException + * @throws \Filefabrik\Rfc9421\Exceptions\StructuredFieldException + * @throws \Filefabrik\Rfc9421\Exceptions\UnexpectedValue + * @throws \Filefabrik\Rfc9421\Exceptions\VerifyHeaderSignatureException + * @throws \JsonException + */ + public function testValidateThrowMissingSignatureLines(): void + { + $this->expectExceptionObject(new VerifyHeaderSignatureException('Missing signature')); + $signingAlgo = SigningEnum::rsa_v_1_5_sha_512->name; + $cert = 'rsa'; + $certInstance = new CertHelper($cert); + + $signatureKeyName = 'testing='; + $signatureComponents = new SigningComponents()->sign('@method') + ->sign('@authority') + ; + /** + * Prepare signingConfiguration + */ + $currentDateTime = new DateTime()->getTimestamp(); + $configuration = new SigningConfiguration(signingComponents: $signatureComponents); + $configuration + ->setSigningAlgorithm($signingAlgo) + ->setCreated($currentDateTime) + ->setExpires($currentDateTime + 7200) + ->setTag('mastodon') + ->withNonce('nonce-now') + ->setSignatureKeyName($signatureKeyName) + ->withContentDigest(DigestAlgorithmsEnum::sha512) + // for signing needs private + ->setPrivatePem($certInstance->getPrivatPemContent()) + ; + + /** + * Prepare the Request + */ + $bodyParams = ['recipient' => 'Alex', 'amount' => 900, 'currency' => 'EUR']; + $bodyJson = json_encode($bodyParams, JSON_THROW_ON_ERROR); + $request = new Request( + method : 'POST', + uri : 'https://target-host.com', + headers: ['x-origin-host' => 'target-host.com'], + body : $bodyJson, + ); + + $signer = new RequestSigner($request, $configuration); + $signedRequest = $signer->sign(); + + // Kills signature to provocate error + $signedRequest = $signedRequest->withoutHeader('signature'); + + $prepareVerifierInstance = new VerifyRequestPrepare( + message : $signedRequest, + signingConfiguration: new SigningConfiguration(), + )->prepareVerification(); + } + /** * @throws \Filefabrik\Rfc9421\Exceptions\VerifyHeaderSignatureException * @throws \Filefabrik\Rfc9421\Exceptions\ContentDigestException @@ -427,7 +499,7 @@ public function testGetHeaderSignatureExtractor() signingConfiguration: new SigningConfiguration(), ); $prepareVerifierInstance->prepareVerification(); - $hs = $prepareVerifierInstance->getHeaderSignatureExtractor(); + $hs = $prepareVerifierInstance->getHeaderSignatureExtractor(); self::assertTrue($hs instanceof HeaderSignature); } } From a547ef3eae472fbdc37c2d8a24b0ce364c203109 Mon Sep 17 00:00:00 2001 From: Filefabrik Date: Wed, 25 Nov 2026 14:21:09 +0100 Subject: [PATCH 05/13] mutation tests v1.10.11 Enums fully Tested --- src/Rfc9421/Enums/DigestAlgorithmsEnum.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/Rfc9421/Enums/DigestAlgorithmsEnum.php b/src/Rfc9421/Enums/DigestAlgorithmsEnum.php index 02c28a9..42479c9 100644 --- a/src/Rfc9421/Enums/DigestAlgorithmsEnum.php +++ b/src/Rfc9421/Enums/DigestAlgorithmsEnum.php @@ -1,4 +1,5 @@ Date: Wed, 25 Nov 2026 14:23:20 +0100 Subject: [PATCH 06/13] mutation tests v1.10.11 DTO --- src/Rfc9421/Dto/ComponentItemDto.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Rfc9421/Dto/ComponentItemDto.php b/src/Rfc9421/Dto/ComponentItemDto.php index 743fb29..8255e51 100644 --- a/src/Rfc9421/Dto/ComponentItemDto.php +++ b/src/Rfc9421/Dto/ComponentItemDto.php @@ -73,7 +73,10 @@ private static function validFieldName(Item $item): string private static function ensureStringValue( Bytes|Token|DisplayString|DateTimeImmutable|string|int|float|bool $v, ): string { - return is_string($v) ? $v : throw new UnexpectedValue( + if (is_string($v)) { + return $v; + } + throw new UnexpectedValue( sprintf('Expected string, got "%s"', gettype($v)), ); } From 9cafff578c188fe65a64238a3c71a2542b3a5328 Mon Sep 17 00:00:00 2001 From: Filefabrik Date: Wed, 25 Nov 2026 14:44:52 +0100 Subject: [PATCH 07/13] mutation tests v1.10.11 useless removed --- src/Rfc9421/Verify/AbstractVerifyPrepare.php | 22 +------------------- src/Rfc9421/Verify/HeaderSignatureInput.php | 8 +++++-- src/Rfc9421/Verify/VerifyContentDigest.php | 4 ++-- tests/Rfc9421/VerifyRequestPrepareTest.php | 8 ++++--- 4 files changed, 14 insertions(+), 28 deletions(-) diff --git a/src/Rfc9421/Verify/AbstractVerifyPrepare.php b/src/Rfc9421/Verify/AbstractVerifyPrepare.php index 6d12484..5728803 100644 --- a/src/Rfc9421/Verify/AbstractVerifyPrepare.php +++ b/src/Rfc9421/Verify/AbstractVerifyPrepare.php @@ -12,7 +12,6 @@ namespace Filefabrik\Rfc9421\Verify; -use Filefabrik\Rfc9421\Exceptions\UnexpectedValue; use Filefabrik\Rfc9421\Exceptions\VerifyHeaderSignatureException; use Filefabrik\Rfc9421\Extractors\ContentDigest; use Filefabrik\Rfc9421\Extractors\HeaderSignature; @@ -79,7 +78,7 @@ public function prepareVerification(): bool */ Metadata::bindMetadata( instance: $this->signingConfiguration->getMetadata(), - metadata: $this->getExtractedMetadataArray(), + metadata: $this->getSignaturInputInstance()->extractedMetadata->toArray(), ); /* @@ -103,25 +102,6 @@ public function getHeaderSignatureExtractor(): HeaderSignature return $this->headerSignatureExtractor; } - /** - * - * @throws \Filefabrik\Rfc9421\Exceptions\AlreadySetException - * @throws \Filefabrik\Rfc9421\Exceptions\UnexpectedValue - * @throws \Filefabrik\Rfc9421\Exceptions\SignatureException - * @throws \Filefabrik\Rfc9421\Exceptions\SignatureExtractionException - * @throws \Filefabrik\Rfc9421\Exceptions\UnexpectedValue - * @throws \Filefabrik\Rfc9421\Exceptions\VerifyHeaderSignatureException - * @return array{}|array{created?: int, expires?: int, nonce?: string, keyid?: string, alg?: string, tag?: string} - */ - private function getExtractedMetadataArray(): array - { - $toArray = $this->getSignaturInputInstance()->extractedMetadata?->toArray(); - if (is_array($toArray)) { - return $toArray; - } - throw new UnexpectedValue('No Metadata Found'); - } - /** * @throws \Filefabrik\Rfc9421\Exceptions\AlreadySetException * @throws \Filefabrik\Rfc9421\Exceptions\SignatureException diff --git a/src/Rfc9421/Verify/HeaderSignatureInput.php b/src/Rfc9421/Verify/HeaderSignatureInput.php index e9e14fc..5355cf9 100644 --- a/src/Rfc9421/Verify/HeaderSignatureInput.php +++ b/src/Rfc9421/Verify/HeaderSignatureInput.php @@ -42,7 +42,7 @@ public function __construct( * if the signatureNameKey not set/null, then detect it during the extract * */ - private(set) readonly string $signatureNameKey + private(set) readonly string $signatureNameKey, ) { } @@ -103,7 +103,11 @@ private function extractSignatureString(): string */ public function getExtractedComponents(): SigningComponents { - return $this->extractedComponents ?? throw SignatureExtractionException::notProceeded(); + if ($this->extractedComponents instanceof SigningComponents) { + return $this->extractedComponents; + } + + throw SignatureExtractionException::notProceeded(); } } diff --git a/src/Rfc9421/Verify/VerifyContentDigest.php b/src/Rfc9421/Verify/VerifyContentDigest.php index 25636f8..a714d9a 100644 --- a/src/Rfc9421/Verify/VerifyContentDigest.php +++ b/src/Rfc9421/Verify/VerifyContentDigest.php @@ -27,8 +27,8 @@ public function __construct( } /** - * @return bool true if valid * @throws \Filefabrik\Rfc9421\Exceptions\ContentDigestException + * @return bool true if valid */ public function verify(): bool { @@ -40,7 +40,7 @@ public function verify(): bool /** * @throws \Filefabrik\Rfc9421\Exceptions\ContentDigestException */ - public function getContentDigestVerifier(): ContentDigest + private function getContentDigestVerifier(): ContentDigest { if (null === $this->contentDigestVerifier) { $this->contentDigestVerifier = $this->prepare(); diff --git a/tests/Rfc9421/VerifyRequestPrepareTest.php b/tests/Rfc9421/VerifyRequestPrepareTest.php index acba742..2eeba86 100644 --- a/tests/Rfc9421/VerifyRequestPrepareTest.php +++ b/tests/Rfc9421/VerifyRequestPrepareTest.php @@ -269,7 +269,7 @@ public function testValidateThrowMissingSignatureInput(): void * @throws \Filefabrik\Rfc9421\Exceptions\StructuredFieldException * @throws \Filefabrik\Rfc9421\Exceptions\UnexpectedValue * @throws \Filefabrik\Rfc9421\Exceptions\VerifyHeaderSignatureException - * @throws \JsonException + * @throws JsonException */ public function testValidateThrowMissingSignatureLines(): void { @@ -433,6 +433,8 @@ public function testGetSignatureInputInstance(): void self::assertInstanceOf(HeaderSignatureInput::class, $prepareVerifierInstance->getSignatureInputInstance()); } + + public function testGetHeaderHelper(): void { $prepareVerifierInstance = new VerifyRequestPrepare( @@ -453,12 +455,12 @@ public function testGetHeaderHelper(): void * @throws \Filefabrik\Rfc9421\Exceptions\PrepareMethodsException * @throws \Filefabrik\Rfc9421\Exceptions\UnexpectedValue * @throws \Filefabrik\Rfc9421\Exceptions\EmptyException - * @throws \JsonException + * @throws JsonException * @throws \Filefabrik\Rfc9421\Exceptions\ContentDigestException * @throws \Filefabrik\Rfc9421\Exceptions\AlreadySetException * @throws \Filefabrik\Rfc9421\Exceptions\SignatureException */ - public function testGetHeaderSignatureExtractor() + public function testGetHeaderSignatureExtractor(): void { $certInstance = new CertHelper('rsa'); From e485db33e0091a169d3af7a9708a9ed9cc4a87f5 Mon Sep 17 00:00:00 2001 From: Filefabrik Date: Wed, 25 Nov 2026 15:05:37 +0100 Subject: [PATCH 08/13] mutation tests v1.10.11 up to 98% --- Changelog.md | 4 ++ infection.json5 | 4 +- src/Rfc9421/Signer/Metadata.php | 1 + src/Rfc9421/Support/AbstractMetadata.php | 9 ++-- tests/Rfc9421/Signer/MetadataTest.php | 63 +++++++++++++++++++++++- 5 files changed, 75 insertions(+), 6 deletions(-) diff --git a/Changelog.md b/Changelog.md index ae56ab6..9f0308d 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,9 @@ # Changelog +## v1.10.11 2026-11-25 + +Mutation testing is now up to 98% + ## v1.10.10 2026-11-25 ## v1.10.9 2026-11-25 diff --git a/infection.json5 b/infection.json5 index 8b0da52..fa213ba 100644 --- a/infection.json5 +++ b/infection.json5 @@ -17,8 +17,8 @@ } }, "tmpDir": "build/cache/infection", - "minMsi": 95, - "minCoveredMsi": 95, + "minMsi": 97, + "minCoveredMsi": 97, "mutators": { "@default": true, }, diff --git a/src/Rfc9421/Signer/Metadata.php b/src/Rfc9421/Signer/Metadata.php index 0377a98..027484b 100644 --- a/src/Rfc9421/Signer/Metadata.php +++ b/src/Rfc9421/Signer/Metadata.php @@ -1,4 +1,5 @@ getTimestamp(); - self::assertEquals($ts, new Metadata()->setCreated($ts)->getCreated()); + self::assertEquals( + $ts, + new Metadata()->setCreated($ts) + ->getCreated(), + ); } /** @@ -157,4 +163,59 @@ public function testHasTag(): void ); self::assertFalse(new Metadata()->hasTag()); } + + /** + * @throws \Filefabrik\Rfc9421\Exceptions\UnexpectedValue + * @throws \Filefabrik\Rfc9421\Exceptions\SignatureException + */ + public function testSetStringOrNullThrow(): void + { + $this->expectExceptionObject(new UnexpectedValue('$value must be string|null')); + $md = new Metadata(); + $md->set('keyid', 1); + } + + /** + * @throws \Filefabrik\Rfc9421\Exceptions\UnexpectedValue + * @throws \Filefabrik\Rfc9421\Exceptions\SignatureException + */ + public function testsetStringOrSigningEnumThrow(): void + { + $this->expectExceptionObject( + new SignatureException('The signature algorithm must be a string|SigningEnumInterface.'), + ); + $md = new Metadata(); + $md->set('alg', 1); + } + + /** + * @throws \Filefabrik\Rfc9421\Exceptions\UnexpectedValue + * @throws \Filefabrik\Rfc9421\Exceptions\SignatureException + */ + public function testSetStringOrSigningEnumValid(): void + { + $md = new Metadata(); + $md->set('alg', SigningEnum::rsa_v_1_5_sha_256); + self::assertSame($md->alg, SigningEnum::rsa_v_1_5_sha_256); + + $md = new Metadata(); + $md->set('alg', SigningEnum::rsa_v_1_5_sha_256->value); + self::assertSame($md->alg, SigningEnum::rsa_v_1_5_sha_256); + + $md = new Metadata(); + $md->set('alg', SigningEnum::rsa_v_1_5_sha_256->name); + self::assertSame($md->alg, SigningEnum::rsa_v_1_5_sha_256); + } + + /** + * @throws \Filefabrik\Rfc9421\Exceptions\UnexpectedValue + * @throws \Filefabrik\Rfc9421\Exceptions\SignatureException + */ + public function testSetIntOrNullThrow(): void + { + $this->expectExceptionObject(new UnexpectedValue('$value must be int|null')); + $md = new Metadata(); + $md->set('created', 'string'); + } + } From 0b8abe288dfb074245cf07deda31f7517f6e10a6 Mon Sep 17 00:00:00 2001 From: Filefabrik Date: Wed, 25 Nov 2026 15:11:39 +0100 Subject: [PATCH 09/13] codecov @codeCoverageIgnore exception --- src/Rfc9421/Dto/ComponentItemDto.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Rfc9421/Dto/ComponentItemDto.php b/src/Rfc9421/Dto/ComponentItemDto.php index 8255e51..de1131b 100644 --- a/src/Rfc9421/Dto/ComponentItemDto.php +++ b/src/Rfc9421/Dto/ComponentItemDto.php @@ -76,9 +76,11 @@ private static function ensureStringValue( if (is_string($v)) { return $v; } + // @codeCoverageIgnoreStart throw new UnexpectedValue( sprintf('Expected string, got "%s"', gettype($v)), ); + // @codeCoverageIgnoreEnd } public function getItem(): Item From 0bb040c49f1e06d7eb446e1a54e069b82100fa4d Mon Sep 17 00:00:00 2001 From: Filefabrik Date: Wed, 25 Nov 2026 15:32:38 +0100 Subject: [PATCH 10/13] mutation details testing --- src/Rfc9421/Signer/SigCompilerHelper.php | 4 ++-- src/Rfc9421/Signer/SignBody.php | 2 +- src/Rfc9421/Signer/Signatures/ReadLines.php | 14 +++++++++--- src/Rfc9421/Signer/TraitSigner.php | 8 +++---- tests/Rfc9421/Signer/MetadataTest.php | 18 +++++++++++++++ .../Signer/Signatures/ReadLinesTest.php | 22 +++++++++++++++++++ 6 files changed, 57 insertions(+), 11 deletions(-) diff --git a/src/Rfc9421/Signer/SigCompilerHelper.php b/src/Rfc9421/Signer/SigCompilerHelper.php index 34a03d3..8fb1c00 100644 --- a/src/Rfc9421/Signer/SigCompilerHelper.php +++ b/src/Rfc9421/Signer/SigCompilerHelper.php @@ -52,7 +52,7 @@ public static function makeSig1fromComponents(SigningComponents $components, str /** * simple helper */ - public static function wrapBraces(string $string): string + private static function wrapBraces(string $string): string { return sprintf('(%s)', $string); } @@ -61,7 +61,7 @@ public static function wrapBraces(string $string): string * todo that is wrong, must use the component-parser * */ - public static function compileFromArrayComponent(SigningComponents $components): string + private static function compileFromArrayComponent(SigningComponents $components): string { $parts = []; diff --git a/src/Rfc9421/Signer/SignBody.php b/src/Rfc9421/Signer/SignBody.php index b11c819..b582f38 100644 --- a/src/Rfc9421/Signer/SignBody.php +++ b/src/Rfc9421/Signer/SignBody.php @@ -64,7 +64,7 @@ public function calculateSignature(): string /** * Create the hash */ - public function hash(): string + private function hash(): string { return hash( algo : $this->algorithm diff --git a/src/Rfc9421/Signer/Signatures/ReadLines.php b/src/Rfc9421/Signer/Signatures/ReadLines.php index 34b8b5e..960db83 100644 --- a/src/Rfc9421/Signer/Signatures/ReadLines.php +++ b/src/Rfc9421/Signer/Signatures/ReadLines.php @@ -11,6 +11,8 @@ namespace Filefabrik\Rfc9421\Signer\Signatures; +use Filefabrik\Rfc9421\Exceptions\UnexpectedValue; + /** * after verify, so nothing can be written into the ReadLines */ @@ -18,6 +20,8 @@ final class ReadLines extends AbstractLines { /** * @param array|array{}|\Filefabrik\Rfc9421\Signer\Signatures\WriteLines $lines + * + * @throws \Filefabrik\Rfc9421\Exceptions\UnexpectedValue */ public function __construct(array|WriteLines $lines) { @@ -26,6 +30,8 @@ public function __construct(array|WriteLines $lines) /** * @param array|array{}|\Filefabrik\Rfc9421\Signer\Signatures\WriteLines $lines + * + * @throws \Filefabrik\Rfc9421\Exceptions\UnexpectedValue */ private function setup(array|WriteLines $lines): void { @@ -36,10 +42,12 @@ private function setup(array|WriteLines $lines): void foreach ($lines as $key => $line) { if ($line instanceof Line && is_int($key)) { $this->protectedAdd($line); - } else { - /* @var string $key */ - /* @var string $line */ + } elseif ((is_string($line) || is_int($line)) && is_string($key)) { $this->protectedAddEntry($key, $line); + } else { + throw new UnexpectedValue( + sprintf('Unexpected value of type %s or key of type %s', gettype($line), gettype($key)), + ); } } } diff --git a/src/Rfc9421/Signer/TraitSigner.php b/src/Rfc9421/Signer/TraitSigner.php index 37b0bc4..1c496ca 100644 --- a/src/Rfc9421/Signer/TraitSigner.php +++ b/src/Rfc9421/Signer/TraitSigner.php @@ -129,7 +129,7 @@ public function prepareSigning(): void $this->signingLines->add( new Line( - // important to quote + // important to quote signatureComponent: $signatureParamsEntry->getComponent(), valueToSign : $signatureParamsEntry->getValue(), ), @@ -170,13 +170,11 @@ private function updateHeadersBeforePrepare(): void /** * Generate the base signature * - * - * * @throws \Filefabrik\Rfc9421\Exceptions\EmptyException * @throws \Filefabrik\Rfc9421\Exceptions\SignatureException * @throws \Filefabrik\Rfc9421\Exceptions\UnexpectedValue */ - public function crypt(string $signingParametersString): string + private function crypt(string $signingParametersString): string { $signature = SignatureRegistry::signing( signingEnumInterface: SigningEnum::isOwnTypeOrThrow($this->signingConfiguration->getMetadata()->alg), @@ -193,7 +191,7 @@ public function crypt(string $signingParametersString): string * @return string $signatureKeyName:$signature: * */ - public function makeSignatureString(string $signature): string + private function makeSignatureString(string $signature): string { return sprintf($this->signingConfiguration->getSignatureKeyName().':%s:', $signature); } diff --git a/tests/Rfc9421/Signer/MetadataTest.php b/tests/Rfc9421/Signer/MetadataTest.php index 66de96b..53f7dd6 100644 --- a/tests/Rfc9421/Signer/MetadataTest.php +++ b/tests/Rfc9421/Signer/MetadataTest.php @@ -218,4 +218,22 @@ public function testSetIntOrNullThrow(): void $md->set('created', 'string'); } + /** + * @throws \Filefabrik\Rfc9421\Exceptions\SignatureException + * @throws \Filefabrik\Rfc9421\Exceptions\UnexpectedValue + */ + #[DataProvider('dataProviderToArray')] + public function testBindMetadata(...$datas): void + { + $inputMeta = Metadata::fromArray($datas) + ->toArray() + ; + $bondage = Metadata::bindMetadata(new Metadata(), $inputMeta); + self::assertSame( + $datas, + $bondage->toArray(), + + ); + } + } diff --git a/tests/Rfc9421/Signer/Signatures/ReadLinesTest.php b/tests/Rfc9421/Signer/Signatures/ReadLinesTest.php index d04bd2d..9f20f6e 100644 --- a/tests/Rfc9421/Signer/Signatures/ReadLinesTest.php +++ b/tests/Rfc9421/Signer/Signatures/ReadLinesTest.php @@ -11,6 +11,7 @@ namespace Filefabrik\Rfc9421Test\Signer\Signatures; +use Filefabrik\Rfc9421\Exceptions\UnexpectedValue; use Filefabrik\Rfc9421\Signer\Signatures\Line; use Filefabrik\Rfc9421\Signer\Signatures\ReadLines; use Filefabrik\Rfc9421\Signer\Signatures\WriteLines; @@ -20,6 +21,9 @@ #[CoversClass(ReadLines::class)] final class ReadLinesTest extends TestCase { + /** + * @throws \Filefabrik\Rfc9421\Exceptions\UnexpectedValue + */ public function testSetupArray(): void { $rl = new ReadLines(['foo' => 'bar', 'play' => 'book']); @@ -27,6 +31,9 @@ public function testSetupArray(): void self::assertEquals(['foo' => 'bar', 'play' => 'book'], $rl->toKeyValueArray()); } + /** + * @throws \Filefabrik\Rfc9421\Exceptions\UnexpectedValue + */ public function testReadWriteLines(): void { $wl = new WriteLines()->addEntry('foo', 'bar') @@ -38,6 +45,9 @@ public function testReadWriteLines(): void self::assertEquals(['foo' => 'bar', 'play' => 'book'], $rl->toKeyValueArray()); } + /** + * @throws \Filefabrik\Rfc9421\Exceptions\UnexpectedValue + */ public function testSetup(): void { $rl = new ReadLines([new Line('foo', 'bar'), new Line('play', 'book')]); @@ -45,10 +55,22 @@ public function testSetup(): void self::assertEquals(['foo' => 'bar', 'play' => 'book'], $rl->toKeyValueArray()); } + /** + * @throws \Filefabrik\Rfc9421\Exceptions\UnexpectedValue + */ public function testToLineString(): void { $rl = new ReadLines([new Line('"foo"', 'bar'), new Line('"play"', 'book')]); self::assertEquals(['"foo"' => '"foo": bar', '"play"' => '"play": book'], $rl->toLineString()); } + + /** + * @throws \Filefabrik\Rfc9421\Exceptions\UnexpectedValue + */ + public function testWrongFormat(): void + { + $this->expectExceptionObject(new UnexpectedValue('Unexpected value of type string or key of type integer')); + new ReadLines(['bar', 'book']); + } } From 82de0352199ffd5525b3ab4aea599e141e7cef41 Mon Sep 17 00:00:00 2001 From: Filefabrik Date: Wed, 25 Nov 2026 15:41:43 +0100 Subject: [PATCH 11/13] mutation details testing --- .../Rfc9421/Verify/HeaderSignatureInputTest.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/Rfc9421/Verify/HeaderSignatureInputTest.php b/tests/Rfc9421/Verify/HeaderSignatureInputTest.php index b88c953..dde4a0d 100644 --- a/tests/Rfc9421/Verify/HeaderSignatureInputTest.php +++ b/tests/Rfc9421/Verify/HeaderSignatureInputTest.php @@ -11,6 +11,7 @@ namespace Filefabrik\Rfc9421Test\Verify; +use Filefabrik\Rfc9421\Exceptions\SignatureExtractionException; use Filefabrik\Rfc9421\Exceptions\VerifyHeaderSignatureException; use Filefabrik\Rfc9421\SigningComponents; use Filefabrik\Rfc9421\Verify\HeaderSignatureInput; @@ -27,6 +28,7 @@ final class HeaderSignatureInputTest extends TestCase * @throws \Filefabrik\Rfc9421\Exceptions\SignatureExtractionException * @throws \Filefabrik\Rfc9421\Exceptions\SignatureException * @throws \Filefabrik\Rfc9421\Exceptions\UnexpectedValue + * @throws \Filefabrik\Rfc9421\Exceptions\EnumTypeException */ public function testExtract(): void { @@ -55,6 +57,7 @@ public function testExtract(): void * @throws \Filefabrik\Rfc9421\Exceptions\SignatureExtractionException * @throws \Filefabrik\Rfc9421\Exceptions\SignatureException * @throws \Filefabrik\Rfc9421\Exceptions\UnexpectedValue + * @throws \Filefabrik\Rfc9421\Exceptions\EnumTypeException */ public function testExtractWithoutKey(): void { @@ -136,4 +139,18 @@ public function testExtractInvalidSignature(): void $headerSignatureInput->extract(); } + + /** + * @throws \Filefabrik\Rfc9421\Exceptions\SignatureExtractionException + */ + public function testGetExtractedComponents(): void + { + $this->expectExceptionObject(SignatureExtractionException::notProceeded()); + $expectedComponents = new SigningComponents(); + + $sig = 'someSig=()'; + $headerSignatureInput = new HeaderSignatureInput($sig, 'someSig='); + + self::assertEquals($expectedComponents, $headerSignatureInput->getExtractedComponents()); + } } From acbb1c5aa26231e3cf9e73ce1f30b95400d5a74b Mon Sep 17 00:00:00 2001 From: Filefabrik Date: Wed, 25 Nov 2026 15:57:20 +0100 Subject: [PATCH 12/13] mutation deeper testing --- src/Rfc9421/Signer/TraitSigner.php | 6 +++++- src/Rfc9421/StructuredFields/Processing/Bs.php | 2 +- tests/Rfc9421/Signer/PrepareComponentsTest.php | 17 +++++++++++++++++ tests/Rfc9421/Support/PreparedMethodsTest.php | 3 +++ 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/Rfc9421/Signer/TraitSigner.php b/src/Rfc9421/Signer/TraitSigner.php index 1c496ca..12da339 100644 --- a/src/Rfc9421/Signer/TraitSigner.php +++ b/src/Rfc9421/Signer/TraitSigner.php @@ -201,7 +201,11 @@ private function makeSignatureString(string $signature): string */ public function getSigningParametersStringOrThrow(): string { - return $this->signingParametersString ?? throw ProcessingException::signingParametersString(); + if (is_string($this->signingParametersString)) { + return $this->signingParametersString; + } + + return throw ProcessingException::signingParametersString(); } /** diff --git a/src/Rfc9421/StructuredFields/Processing/Bs.php b/src/Rfc9421/StructuredFields/Processing/Bs.php index acd533e..975facc 100644 --- a/src/Rfc9421/StructuredFields/Processing/Bs.php +++ b/src/Rfc9421/StructuredFields/Processing/Bs.php @@ -39,7 +39,7 @@ public function handle( if (0 < count($values)) { $valuesSegments = []; foreach ($values as $value) { - $valuesSegments [] = ':'.base64_encode(trim($value)).':'; + $valuesSegments [] = ':'.base64_encode($value).':'; } // all in a line diff --git a/tests/Rfc9421/Signer/PrepareComponentsTest.php b/tests/Rfc9421/Signer/PrepareComponentsTest.php index 4e8ec50..67150de 100644 --- a/tests/Rfc9421/Signer/PrepareComponentsTest.php +++ b/tests/Rfc9421/Signer/PrepareComponentsTest.php @@ -206,6 +206,23 @@ public function testProcessAuthority(): void ); } + /** + * @throws \Filefabrik\Rfc9421\Exceptions\EnumTypeException + * @throws \Filefabrik\Rfc9421\Exceptions\PrepareMethodsException + * @throws \Filefabrik\Rfc9421\Exceptions\UnexpectedValue + */ + public function testProcessSignatureParamsThrow(): void + { + $this->expectExceptionObject( + new PrepareMethodsException( + 'Error during calling the method with key: "@signature-params": remove before processing signatureParams', + ), + ); + $r = new Request('post', 'https://www.Test.com/var/pathy/?qer=var', ['']); + + new PrepareComponents($r)->processValue('@signature-params'); + } + /** * @throws \Filefabrik\Rfc9421\Exceptions\EnumTypeException * @throws \Filefabrik\Rfc9421\Exceptions\PrepareMethodsException diff --git a/tests/Rfc9421/Support/PreparedMethodsTest.php b/tests/Rfc9421/Support/PreparedMethodsTest.php index 378bdcc..ff59750 100644 --- a/tests/Rfc9421/Support/PreparedMethodsTest.php +++ b/tests/Rfc9421/Support/PreparedMethodsTest.php @@ -36,9 +36,12 @@ public function testGetMethod(): void [ 'texst' => fn (MessageInterface $message): string => $message->getMethod(), 'poster' => fn (MessageInterface $message): string => $message->getMethod(), + 'UpperCase' => fn (MessageInterface $message): string => $message->getMethod(), ], ); self::assertInstanceOf(Closure::class, $i->getMethod('poster')); + self::assertInstanceOf(Closure::class, $i->getMethod('uppercase')); + self::assertInstanceOf(Closure::class, $i->getMethod('UpperCase')); } /** From 72390592822ebc0f26fb54bebe109e6dd17c9260 Mon Sep 17 00:00:00 2001 From: Filefabrik Date: Wed, 25 Nov 2026 16:06:19 +0100 Subject: [PATCH 13/13] mutation deeper testing --- src/Rfc9421/Signer/TraitSigner.php | 2 +- tests/Rfc9421/RequestSignerTest.php | 42 +++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/src/Rfc9421/Signer/TraitSigner.php b/src/Rfc9421/Signer/TraitSigner.php index 12da339..d8128f3 100644 --- a/src/Rfc9421/Signer/TraitSigner.php +++ b/src/Rfc9421/Signer/TraitSigner.php @@ -129,7 +129,7 @@ public function prepareSigning(): void $this->signingLines->add( new Line( - // important to quote + // important to quote signatureComponent: $signatureParamsEntry->getComponent(), valueToSign : $signatureParamsEntry->getValue(), ), diff --git a/tests/Rfc9421/RequestSignerTest.php b/tests/Rfc9421/RequestSignerTest.php index 2036382..139371b 100644 --- a/tests/Rfc9421/RequestSignerTest.php +++ b/tests/Rfc9421/RequestSignerTest.php @@ -669,4 +669,46 @@ public function testSignThrowsReq(): void $signer = new RequestSigner(message: $request, signingConfiguration: $signingConfiguration); $signer->sign(); } + + /** + * @throws \Filefabrik\Rfc9421\Exceptions\ProcessingException + * @throws \Filefabrik\Rfc9421\Exceptions\SignatureException + * @throws \Filefabrik\Rfc9421\Exceptions\UnexpectedValue + */ + public function testHasNoSigningParametersString(): void + { + $this->expectExceptionObject(ProcessingException::signingParametersString()); + + $targetUrl = 'http://localhost:8001/mastodon?param=value&foo=bar&baz=bat%2Dman'; + $certInstance = new CertHelper('rsa'); + $currentDateTime = new DateTime()->getTimestamp(); + $expiredDate = $currentDateTime + 7200; + $signingConfiguration = new SigningConfiguration() + ->setSigningAlgorithm(SigningEnum::rsa_v_1_5_sha_512) + ->setCreated($currentDateTime) + ->setExpires($expiredDate) + ->setTag('mastodon') + ->setKeyid('http://127.0.0.1:8001/actor#main-key') + ->withNonce('nonce-now') + + // content digest signer key + ->setSignatureKeyName('testValue=') + // for signing needs private + ->setPrivatePem($certInstance->getPrivatPemContent()) + ; + + /** + * Prepare the Request + */ + $request = new Request( + method : 'POST', + uri : $targetUrl, + headers: ['x-origin-host' => 'mytest.com'], + body : '{"recipient":"Alex","amount":900000000,"text":"fdawsfs"}', + ); + + $signer = new RequestSigner(message: $request, signingConfiguration: $signingConfiguration); + + $signer->getSigningParametersStringOrThrow(); + } }