diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AddCostPriceToProductActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AddCostPriceToProductActionGroup.xml
new file mode 100644
index 000000000000..446a3032578d
--- /dev/null
+++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AddCostPriceToProductActionGroup.xml
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+ Sets the provided Cost Price on the Admin Product creation/edit page.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml b/app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml
index 0436609c7e73..2122760363c8 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml
@@ -1488,4 +1488,35 @@
Simple Product with special characters in SKU
s000&01
+
+ Product1
+ product-1
+ product1
+ 200.00
+ 100
+ 1
+ 150.00
+ None
+ simple
+ 4
+ 1
+ EavStockItem
+ CustomAttributeCategoryIds
+
+
+ product2
+ Product2
+ product-2
+ 300.00
+ 300
+ 1
+ IN STOCK
+ 250.00
+ Taxable Goods
+ simple
+ 4
+ 1
+ EavStockItem
+ CustomAttributeCategoryIds
+
diff --git a/app/code/Magento/Catalog/Test/Mftf/Section/AdminProductFormSection/AdminProductFormCostPricingSection.xml b/app/code/Magento/Catalog/Test/Mftf/Section/AdminProductFormSection/AdminProductFormCostPricingSection.xml
new file mode 100644
index 000000000000..2ea5d9e0bdb4
--- /dev/null
+++ b/app/code/Magento/Catalog/Test/Mftf/Section/AdminProductFormSection/AdminProductFormCostPricingSection.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
diff --git a/app/code/Magento/Catalog/Test/Mftf/Section/AdminProductGridSection.xml b/app/code/Magento/Catalog/Test/Mftf/Section/AdminProductGridSection.xml
index 57824d73f4d7..1c704a373b05 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Section/AdminProductGridSection.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Section/AdminProductGridSection.xml
@@ -46,6 +46,7 @@
+
diff --git a/app/code/Magento/Catalog/Test/Mftf/Section/StorefrontCategoryMainSection.xml b/app/code/Magento/Catalog/Test/Mftf/Section/StorefrontCategoryMainSection.xml
index 744b279e4c77..4c4dedb521d2 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Section/StorefrontCategoryMainSection.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Section/StorefrontCategoryMainSection.xml
@@ -45,5 +45,6 @@
+
diff --git a/app/code/Magento/Checkout/Test/Mftf/Section/CheckoutPaymentSection.xml b/app/code/Magento/Checkout/Test/Mftf/Section/CheckoutPaymentSection.xml
index 08ecef34337c..be7f0e0ed98e 100644
--- a/app/code/Magento/Checkout/Test/Mftf/Section/CheckoutPaymentSection.xml
+++ b/app/code/Magento/Checkout/Test/Mftf/Section/CheckoutPaymentSection.xml
@@ -75,6 +75,7 @@
+
diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUKCustomerCheckoutWithCouponTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUKCustomerCheckoutWithCouponTest.xml
index 6ea870cf4183..b04688ffdc3a 100644
--- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUKCustomerCheckoutWithCouponTest.xml
+++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUKCustomerCheckoutWithCouponTest.xml
@@ -94,7 +94,7 @@
-
+
diff --git a/app/code/Magento/Config/Test/Mftf/ActionGroup/ResetCalculationClassForShippingActionGroup.xml b/app/code/Magento/Config/Test/Mftf/ActionGroup/ResetCalculationClassForShippingActionGroup.xml
new file mode 100644
index 000000000000..06c465c140a1
--- /dev/null
+++ b/app/code/Magento/Config/Test/Mftf/ActionGroup/ResetCalculationClassForShippingActionGroup.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+ Goes to the 'Configuration' page for 'Tax Calculation Method Based On'. Sets 'Unit Price' to 'Total'. Clicks on the Save button. PLEASE NOTE: The value is Hardcoded.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Config/Test/Mftf/ActionGroup/ResetIncludeTaxInTotalForShippingActionGroup.xml b/app/code/Magento/Config/Test/Mftf/ActionGroup/ResetIncludeTaxInTotalForShippingActionGroup.xml
new file mode 100644
index 000000000000..3cc913650e72
--- /dev/null
+++ b/app/code/Magento/Config/Test/Mftf/ActionGroup/ResetIncludeTaxInTotalForShippingActionGroup.xml
@@ -0,0 +1,35 @@
+
+
+
+
+
+
+ Goes to the 'Configuration' page for 'Orders, Invoices, Credit Memos Display Settings'. Sets 'Yes' to 'No'. Clicks on the Save button. PLEASE NOTE: The value is Hardcoded.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Config/Test/Mftf/ActionGroup/ResetOrderInvoiceSettingsForShippingActionGroup.xml b/app/code/Magento/Config/Test/Mftf/ActionGroup/ResetOrderInvoiceSettingsForShippingActionGroup.xml
new file mode 100644
index 000000000000..fb88ad7e6b17
--- /dev/null
+++ b/app/code/Magento/Config/Test/Mftf/ActionGroup/ResetOrderInvoiceSettingsForShippingActionGroup.xml
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+ Goes to the 'Configuration' page for 'Orders, Invoices, Credit Memos Display Settings'. Sets 'Display Subtotal' to 'Excluding Tax'. Clicks on the Save button. PLEASE NOTE: The value is Hardcoded.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Config/Test/Mftf/ActionGroup/SetCalculationSettingsForShippingActionGroup.xml b/app/code/Magento/Config/Test/Mftf/ActionGroup/SetCalculationSettingsForShippingActionGroup.xml
new file mode 100644
index 000000000000..2a76b58768c3
--- /dev/null
+++ b/app/code/Magento/Config/Test/Mftf/ActionGroup/SetCalculationSettingsForShippingActionGroup.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+ Goes to the 'Configuration' page for 'Tax'. Sets 'Tax Calculation Method Based On' to 'Unit Price'. Clicks on the Save button. PLEASE NOTE: The value is Hardcoded.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Config/Test/Mftf/ActionGroup/SetIncludeTaxInTotalForShippingActionGroup.xml b/app/code/Magento/Config/Test/Mftf/ActionGroup/SetIncludeTaxInTotalForShippingActionGroup.xml
new file mode 100644
index 000000000000..36919c9c70ca
--- /dev/null
+++ b/app/code/Magento/Config/Test/Mftf/ActionGroup/SetIncludeTaxInTotalForShippingActionGroup.xml
@@ -0,0 +1,38 @@
+
+
+
+
+
+
+ Goes to the 'Configuration' page for 'Orders, Invoices, Credit Memos Display Settings'. Sets 'No' to 'Yes'. Clicks on the Save button. PLEASE NOTE: The value is Hardcoded.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Config/Test/Mftf/ActionGroup/SetOrderInvoiceSettingsForShippingActionGroup.xml b/app/code/Magento/Config/Test/Mftf/ActionGroup/SetOrderInvoiceSettingsForShippingActionGroup.xml
new file mode 100644
index 000000000000..60a0cac2f810
--- /dev/null
+++ b/app/code/Magento/Config/Test/Mftf/ActionGroup/SetOrderInvoiceSettingsForShippingActionGroup.xml
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+ Goes to the 'Configuration' page for 'Orders, Invoices, Credit Memos Display Settings'. Sets 'Display Subtotal' to 'Include and Excluded tax'. Clicks on the Save button. PLEASE NOTE: The value is Hardcoded.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Config/Test/Mftf/ActionGroup/SetTaxClassForShippingActionGroup.xml b/app/code/Magento/Config/Test/Mftf/ActionGroup/SetTaxClassForShippingActionGroup.xml
index a0f05405ba0c..cf8b4e9d7d92 100644
--- a/app/code/Magento/Config/Test/Mftf/ActionGroup/SetTaxClassForShippingActionGroup.xml
+++ b/app/code/Magento/Config/Test/Mftf/ActionGroup/SetTaxClassForShippingActionGroup.xml
@@ -12,13 +12,15 @@
Goes to the 'Configuration' page for 'Tax'. Sets 'Tax Class for Shipping' to 'Taxable Goods'. Clicks on the Save button. PLEASE NOTE: The value is Hardcoded.
-
+
+
+
-
+
diff --git a/app/code/Magento/Config/Test/Mftf/Section/AdminConfigSection.xml b/app/code/Magento/Config/Test/Mftf/Section/AdminConfigSection.xml
index 9e2b314c5457..94be7f34c01b 100644
--- a/app/code/Magento/Config/Test/Mftf/Section/AdminConfigSection.xml
+++ b/app/code/Magento/Config/Test/Mftf/Section/AdminConfigSection.xml
@@ -28,5 +28,6 @@
+
diff --git a/app/code/Magento/Cookie/etc/di.xml b/app/code/Magento/Cookie/etc/di.xml
index 8b53209f5191..ba3813a2a577 100644
--- a/app/code/Magento/Cookie/etc/di.xml
+++ b/app/code/Magento/Cookie/etc/di.xml
@@ -7,5 +7,6 @@
-->
+
diff --git a/app/code/Magento/Shipping/Test/Mftf/Test/MultiShippingWithCreationNewCustomerAndAddressesDuringCheckoutTest.xml b/app/code/Magento/Multishipping/Test/Mftf/Test/MultiShippingWithCreationNewCustomerAndAddressesDuringCheckoutTest.xml
similarity index 78%
rename from app/code/Magento/Shipping/Test/Mftf/Test/MultiShippingWithCreationNewCustomerAndAddressesDuringCheckoutTest.xml
rename to app/code/Magento/Multishipping/Test/Mftf/Test/MultiShippingWithCreationNewCustomerAndAddressesDuringCheckoutTest.xml
index f97dc3f30ab7..dca1537e9d2d 100644
--- a/app/code/Magento/Shipping/Test/Mftf/Test/MultiShippingWithCreationNewCustomerAndAddressesDuringCheckoutTest.xml
+++ b/app/code/Magento/Multishipping/Test/Mftf/Test/MultiShippingWithCreationNewCustomerAndAddressesDuringCheckoutTest.xml
@@ -14,17 +14,11 @@
-
-
-
-
-
-
-
+
simple product
@@ -37,6 +31,7 @@
+
@@ -44,38 +39,39 @@
+
+
+
+
+
+
-
-
+
-
+
-
-
-
-
-
-
+
+
-
+
-
-
-
+
+
+
@@ -102,8 +98,8 @@
-
-
+
+
@@ -117,6 +113,7 @@
+
@@ -143,9 +140,9 @@
-
-
-
+
+
+
@@ -156,10 +153,10 @@
-
+
-
-
+
+
diff --git a/app/code/Magento/PageCache/Model/App/Response/HttpPlugin.php b/app/code/Magento/PageCache/Model/App/Response/HttpPlugin.php
index a6949cccc1ad..abc33da5e59b 100644
--- a/app/code/Magento/PageCache/Model/App/Response/HttpPlugin.php
+++ b/app/code/Magento/PageCache/Model/App/Response/HttpPlugin.php
@@ -22,10 +22,12 @@ class HttpPlugin
*/
public function beforeSendResponse(HttpResponse $subject)
{
- if ($subject instanceof NotCacheableInterface || $subject->headersSent()) {
+ if ($subject instanceof NotCacheableInterface
+ || $subject->headersSent()
+ || $subject->getMetadata("NotCacheable")
+ ) {
return;
}
-
$subject->sendVary();
}
}
diff --git a/app/code/Magento/Paypal/Test/Mftf/Test/AdminPayPalExpressCheckoutTest.xml b/app/code/Magento/Paypal/Test/Mftf/Test/AdminPayPalExpressCheckoutTest.xml
new file mode 100644
index 000000000000..e474f888096f
--- /dev/null
+++ b/app/code/Magento/Paypal/Test/Mftf/Test/AdminPayPalExpressCheckoutTest.xml
@@ -0,0 +1,74 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 10.00
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Paypal/Test/Mftf/Test/GuestCheckoutUsingPayPalExpressCheckoutTest.xml b/app/code/Magento/Paypal/Test/Mftf/Test/GuestCheckoutUsingPayPalExpressCheckoutTest.xml
new file mode 100644
index 000000000000..a836849a1b5d
--- /dev/null
+++ b/app/code/Magento/Paypal/Test/Mftf/Test/GuestCheckoutUsingPayPalExpressCheckoutTest.xml
@@ -0,0 +1,109 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 10.00
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Sales/Test/Mftf/Section/AdminOrderPaymentInformationSection.xml b/app/code/Magento/Sales/Test/Mftf/Section/AdminOrderPaymentInformationSection.xml
index 6c6cb1e9d338..78d7f603e7d4 100644
--- a/app/code/Magento/Sales/Test/Mftf/Section/AdminOrderPaymentInformationSection.xml
+++ b/app/code/Magento/Sales/Test/Mftf/Section/AdminOrderPaymentInformationSection.xml
@@ -5,7 +5,6 @@
* See COPYING.txt for license details.
*/
-->
-
-
\ No newline at end of file
+
+
diff --git a/app/code/Magento/Sales/Test/Mftf/Section/AdminOrderTotalSection.xml b/app/code/Magento/Sales/Test/Mftf/Section/AdminOrderTotalSection.xml
index 9301bb401835..113916606553 100644
--- a/app/code/Magento/Sales/Test/Mftf/Section/AdminOrderTotalSection.xml
+++ b/app/code/Magento/Sales/Test/Mftf/Section/AdminOrderTotalSection.xml
@@ -21,6 +21,8 @@
+
+
diff --git a/app/code/Magento/Sales/Test/Mftf/Test/CreateCreditMemoWithBaseCurrencyUSDAndDisplayCurrencyEuroTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/CreateCreditMemoWithBaseCurrencyUSDAndDisplayCurrencyEuroTest.xml
new file mode 100644
index 000000000000..30ed35e7b7eb
--- /dev/null
+++ b/app/code/Magento/Sales/Test/Mftf/Test/CreateCreditMemoWithBaseCurrencyUSDAndDisplayCurrencyEuroTest.xml
@@ -0,0 +1,133 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ $grabGrandTotalBaseValue
+ $105.00
+
+
+
+
+
diff --git a/app/code/Magento/Store/Test/Mftf/ActionGroup/AdminSwitchDefaultConfigWebsiteActionGroup.xml b/app/code/Magento/Store/Test/Mftf/ActionGroup/AdminSwitchDefaultConfigWebsiteActionGroup.xml
new file mode 100644
index 000000000000..168d76e8b23f
--- /dev/null
+++ b/app/code/Magento/Store/Test/Mftf/ActionGroup/AdminSwitchDefaultConfigWebsiteActionGroup.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+ Goes to the Store Configuration page. Click on the default config and switch between the websites.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Tax/Test/Mftf/ActionGroup/AdminAddProductTaxClassConditionalActionGroup.xml b/app/code/Magento/Tax/Test/Mftf/ActionGroup/AdminAddProductTaxClassConditionalActionGroup.xml
new file mode 100644
index 000000000000..4df93271caa1
--- /dev/null
+++ b/app/code/Magento/Tax/Test/Mftf/ActionGroup/AdminAddProductTaxClassConditionalActionGroup.xml
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+ Adds the provided Product Tax Class to a Tax Rule. Before click on Save check Class Exist or not.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Tax/Test/Mftf/Data/TaxCodeData.xml b/app/code/Magento/Tax/Test/Mftf/Data/TaxCodeData.xml
index f7431b05d513..cbeecc0f2f9d 100644
--- a/app/code/Magento/Tax/Test/Mftf/Data/TaxCodeData.xml
+++ b/app/code/Magento/Tax/Test/Mftf/Data/TaxCodeData.xml
@@ -58,4 +58,53 @@
78729
0.125
+
+ Product Rate
+ California
+ United States
+ 90001
+ 10
+
+
+ Shipping Rate
+ California
+ United States
+ 90001
+ 5
+
+
+ Product Rate NY
+ New York
+ United States
+ 10001
+ 20
+
+
+ Shipping Rate NY
+ New York
+ United States
+ 10001
+ 10
+
+
+ Texas
+ Texas
+ United States
+ *
+ 8.3
+
+
+ Shipping Rate
+ California
+ United States
+ *
+ 5
+
+
+ Product Rate
+ California
+ United States
+ *
+ 4
+
diff --git a/app/code/Magento/Tax/Test/Mftf/Data/TaxRuleData.xml b/app/code/Magento/Tax/Test/Mftf/Data/TaxRuleData.xml
index 4f2ebc1d18ee..aae0921b72fe 100644
--- a/app/code/Magento/Tax/Test/Mftf/Data/TaxRuleData.xml
+++ b/app/code/Magento/Tax/Test/Mftf/Data/TaxRuleData.xml
@@ -152,4 +152,16 @@
false
+
+ ProductTax
+
+
+ ProductShipping
+
+
+ ShippingTax
+
+
+ ShippingGood
+
diff --git a/app/code/Magento/Tax/Test/Mftf/Section/AdminConfigureTaxSection.xml b/app/code/Magento/Tax/Test/Mftf/Section/AdminConfigureTaxSection.xml
index e6182714b108..9a8a34eaf861 100644
--- a/app/code/Magento/Tax/Test/Mftf/Section/AdminConfigureTaxSection.xml
+++ b/app/code/Magento/Tax/Test/Mftf/Section/AdminConfigureTaxSection.xml
@@ -54,6 +54,7 @@
+
@@ -68,6 +69,14 @@
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/User/Test/Mftf/ActionGroup/AdminDeleteUserViaCurlActionGroup.xml b/app/code/Magento/User/Test/Mftf/ActionGroup/AdminDeleteUserViaCurlActionGroup.xml
index 66013b4d23a2..e1a5f66294c0 100644
--- a/app/code/Magento/User/Test/Mftf/ActionGroup/AdminDeleteUserViaCurlActionGroup.xml
+++ b/app/code/Magento/User/Test/Mftf/ActionGroup/AdminDeleteUserViaCurlActionGroup.xml
@@ -14,12 +14,13 @@
+
+
-
{$userId}
{{adminPassword}}
diff --git a/app/etc/di.xml b/app/etc/di.xml
index eed765920f95..7ffe8e749b20 100644
--- a/app/etc/di.xml
+++ b/app/etc/di.xml
@@ -94,6 +94,7 @@
+
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/GraphQl/GraphQlSessionTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/GraphQl/GraphQlSessionTest.php
index 7c37ea001380..f5b811a63cbd 100644
--- a/dev/tests/api-functional/testsuite/Magento/GraphQl/GraphQl/GraphQlSessionTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/GraphQl/GraphQlSessionTest.php
@@ -48,6 +48,10 @@ public function setUp(): void
/**
* Test for checking if graphQL query sets session cookies
*
+ * Note: The reason why the first response doesn't have cookies, but the subsequent responses do is
+ * because Magento/Framework/App/PageCache/Kernel.php removes Set-Cookie headers when the response has a
+ * public Cache-Control. This test asserts that behaviour.
+ *
* @magentoApiDataFixture Magento/Catalog/_files/categories.php
* @magentoConfigFixture graphql/session/disable 0
*/
@@ -71,8 +75,7 @@ public function testCheckSessionCookieWithGetCategoryList(): void
$result = $this->graphQlClient->getWithResponseHeaders($query, [], '', [], true);
$this->assertEmpty($result['cookies']);
// perform secondary request after cookies have been flushed
- $result = $this->graphQlClient->getWithResponseHeaders($query, [], '', []);
-
+ $result = $this->graphQlClient->getWithResponseHeaders($query, [], '', [], true);
// may have other cookies than session
$this->assertNotEmpty($result['cookies']);
$this->assertAnyCookieMatchesRegex('/PHPSESSID=[a-z0-9]+;/', $result['cookies']);
@@ -280,4 +283,46 @@ private function assertNoCookiesMatchRegex(string $pattern, array $cookies): voi
}
$this->assertTrue($result, 'Failed assertion. At least one cookie in the array matches pattern: ' . $pattern);
}
+
+ /**
+ * Tests that Magento\Customer\Model\Session works properly when graphql/session/disable=0
+ *
+ * @magentoApiDataFixture Magento/Customer/_files/customer.php
+ * @magentoConfigFixture graphql/session/disable 0
+ */
+ public function testCustomerCanQueryOwnEmailUsingSession() : void
+ {
+ $query = '{customer{email}}';
+ $result = $this->graphQlClient->postWithResponseHeaders($query, [], '', $this->getAuthHeaders(), true);
+ // cookies are never empty and session is restarted for the authorized customer regardless current session
+ $this->assertNotEmpty($result['cookies']);
+ $this->assertAnyCookieMatchesRegex('/PHPSESSID=[a-z0-9]+;/', $result['cookies']);
+ $this->assertEquals('customer@example.com', $result['body']['customer']['email'] ?? '');
+ $result = $this->graphQlClient->postWithResponseHeaders($query, [], '', $this->getAuthHeaders());
+ // cookies are never empty and session is restarted for the authorized customer
+ // regardless current session and missing flush
+ $this->assertNotEmpty($result['cookies']);
+ $this->assertAnyCookieMatchesRegex('/PHPSESSID=[a-z0-9]+;/', $result['cookies']);
+ $this->assertEquals('customer@example.com', $result['body']['customer']['email'] ?? '');
+ /* Note: This third request is the actual one that tests that the session cookie is properly used.
+ * This time we don't send the Authorization header and rely on Cookie header instead.
+ * Because of bug in postWithResponseHeaders's $flushCookies parameter not being properly used,
+ * We have to manually set cookie header ourselves. :-(
+ */
+ $cookiesToSend = '';
+ foreach ($result['cookies'] as $cookie) {
+ preg_match('/^([^;]*);/', $cookie, $matches);
+ if (!strlen($matches[1] ?? '')) {
+ continue;
+ }
+ if (!empty($cookiesToSend)) {
+ $cookiesToSend .= '; ';
+ }
+ $cookiesToSend .= $matches[1];
+ }
+ $result = $this->graphQlClient->postWithResponseHeaders($query, [], '', ['Cookie: ' . $cookiesToSend]);
+ $this->assertNotEmpty($result['cookies']);
+ $this->assertAnyCookieMatchesRegex('/PHPSESSID=[a-z0-9]+;/', $result['cookies']);
+ $this->assertEquals('customer@example.com', $result['body']['customer']['email'] ?? '');
+ }
}
diff --git a/lib/internal/Magento/Framework/App/PageCache/Kernel.php b/lib/internal/Magento/Framework/App/PageCache/Kernel.php
index c4d88f031a51..d6a9a249ec38 100644
--- a/lib/internal/Magento/Framework/App/PageCache/Kernel.php
+++ b/lib/internal/Magento/Framework/App/PageCache/Kernel.php
@@ -7,6 +7,7 @@
use Magento\Framework\App\State as AppState;
use Magento\Framework\App\ObjectManager;
+use Magento\Framework\Stdlib\CookieDisablerInterface;
/**
* Builtin cache processor
@@ -68,6 +69,9 @@ class Kernel
*/
private $identifierForSave;
+ // phpcs:disable Magento2.Commenting.ClassPropertyPHPDocFormatting
+ private readonly CookieDisablerInterface $cookieDisabler;
+
/**
* @param Cache $cache
* @param \Magento\Framework\App\PageCache\IdentifierInterface $identifier
@@ -79,6 +83,7 @@ class Kernel
* @param AppState|null $state
* @param \Magento\PageCache\Model\Cache\Type|null $fullPageCache
* @param \Magento\Framework\App\PageCache\IdentifierInterface|null $identifierForSave
+ * @param CookieDisablerInterface|null $cookieDisabler
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
@@ -91,7 +96,8 @@ public function __construct(
\Magento\Framework\Serialize\SerializerInterface $serializer = null,
AppState $state = null,
\Magento\PageCache\Model\Cache\Type $fullPageCache = null,
- \Magento\Framework\App\PageCache\IdentifierInterface $identifierForSave = null
+ \Magento\Framework\App\PageCache\IdentifierInterface $identifierForSave = null,
+ ?CookieDisablerInterface $cookieDisabler = null,
) {
$this->cache = $cache;
$this->identifier = $identifier;
@@ -113,6 +119,7 @@ public function __construct(
$this->identifierForSave = $identifierForSave ?? ObjectManager::getInstance()->get(
\Magento\Framework\App\PageCache\IdentifierInterface::class
);
+ $this->cookieDisabler = $cookieDisabler ?? ObjectManager::getInstance()->get(CookieDisablerInterface::class);
}
/**
@@ -163,9 +170,7 @@ public function process(\Magento\Framework\App\Response\Http $response)
if ($this->state->getMode() != AppState::MODE_DEVELOPER) {
$response->clearHeader('X-Magento-Tags');
}
- if (!headers_sent()) {
- header_remove('Set-Cookie');
- }
+ $this->cookieDisabler->setCookiesDisabled(true);
$this->fullPageCache->save(
$this->serializer->serialize($this->getPreparedData($response)),
diff --git a/lib/internal/Magento/Framework/Session/SaveHandler/Redis.php b/lib/internal/Magento/Framework/Session/SaveHandler/Redis.php
index 2dc0a67e0f07..58f256ebb0e2 100644
--- a/lib/internal/Magento/Framework/Session/SaveHandler/Redis.php
+++ b/lib/internal/Magento/Framework/Session/SaveHandler/Redis.php
@@ -9,6 +9,7 @@
use Cm\RedisSession\Handler\LoggerInterface;
use Cm\RedisSession\ConnectionFailedException;
use Cm\RedisSession\ConcurrentConnectionsExceededException;
+use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Exception\SessionException;
use Magento\Framework\Phrase;
use Magento\Framework\Filesystem;
@@ -82,7 +83,7 @@ public function read($sessionId)
try {
$result = $this->getConnection()->read($sessionId);
} catch (ConcurrentConnectionsExceededException $e) {
- require $this->filesystem->getDirectoryRead(DirectoryList::PUB)->getAbsolutePath('errors/503.php');
+ throw new LocalizedException(__("Redis session exceeded concurrent connections"), $e);
}
return $result;
diff --git a/lib/internal/Magento/Framework/Session/SessionManager.php b/lib/internal/Magento/Framework/Session/SessionManager.php
index f79f0900c2c2..ce381bb22782 100644
--- a/lib/internal/Magento/Framework/Session/SessionManager.php
+++ b/lib/internal/Magento/Framework/Session/SessionManager.php
@@ -638,13 +638,6 @@ private function initIniOptions()
*/
public function _resetState(): void
{
- if (session_status() === PHP_SESSION_ACTIVE) {
- session_write_close();
- session_id('');
- }
- session_name('PHPSESSID');
- session_unset();
static::$urlHostCache = [];
- $_SESSION = [];
}
}
diff --git a/lib/internal/Magento/Framework/Stdlib/Cookie/PhpCookieDisabler.php b/lib/internal/Magento/Framework/Stdlib/Cookie/PhpCookieDisabler.php
new file mode 100644
index 000000000000..76cd5848458e
--- /dev/null
+++ b/lib/internal/Magento/Framework/Stdlib/Cookie/PhpCookieDisabler.php
@@ -0,0 +1,26 @@
+
-
+