From c27d157149077f45b7e4c6bfe1d263b7679d4bb3 Mon Sep 17 00:00:00 2001 From: Lennart Tinkloh Date: Tue, 17 Dec 2024 13:22:49 +0100 Subject: [PATCH] NEXT-40076 - fix empty IAP message --- src/Context/ContextResolver.php | 6 +----- tests/Context/ContextResolverTest.php | 12 ------------ 2 files changed, 1 insertion(+), 17 deletions(-) diff --git a/src/Context/ContextResolver.php b/src/Context/ContextResolver.php index 0107ffb..7432846 100644 --- a/src/Context/ContextResolver.php +++ b/src/Context/ContextResolver.php @@ -91,11 +91,7 @@ public function assembleModule(RequestInterface $request, ShopInterface $shop): throw new MalformedWebhookBodyException(); } - if (isset($params['in-app-purchases'])) { - if (empty($params['in-app-purchases'])) { - throw new MalformedWebhookBodyException(); - } - + if (!empty($params['in-app-purchases'])) { /** @var non-empty-string $inAppPurchaseString */ $inAppPurchaseString = $params['in-app-purchases']; $inAppPurchases = $this->inAppPurchaseProvider->decodePurchases($inAppPurchaseString, $shop); diff --git a/tests/Context/ContextResolverTest.php b/tests/Context/ContextResolverTest.php index 21c771b..a2f1199 100644 --- a/tests/Context/ContextResolverTest.php +++ b/tests/Context/ContextResolverTest.php @@ -174,18 +174,6 @@ public function testAssembleModule(): void static::assertFalse($module->inAppPurchases->has('baz')); } - public function testAssembleModuleWithEmptyInAppPurchasesThrows(): void - { - $contextResolver = new ContextResolver($this->createMock(InAppPurchaseProvider::class)); - - static::expectException(MalformedWebhookBodyException::class); - - $contextResolver->assembleModule( - new Request('GET', 'http://localhost:6001/module/test?shop-id=vvRy7Nv3Bo8mAVda&shop-url=http://localhost:8000×tamp=1683015472&sw-version=6.5.9999999.9999999-dev&sw-context-language=2fbb5fe2e29a4d70aa5854ce7ce3e20b&sw-user-language=en-GB&in-app-purchases=&shopware-shop-signature=650455d43eda4eeb4c9a12ee0eb15b46ce88776abaf9beb1ffac31be136e1d9b'), - $this->getShop() - ); - } - #[DataProvider('assembleModuleInvalidRequestBodyProvider')] public function testAssembleModuleInvalid(string $uri): void {