-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…6032 - Merge Pull Request #26032 from maqlec/magento2:issue-7213 - Merged commits: 1. 859307b 2. 8aed39f 3. 4a05e78 4. cfa889e 5. b219c4e 6. c5ad40b 7. fe0bd17 8. ac0dea5 9. ea10595 10. b4a02dd 11. 4f20656 12. 192bc7e 13. f149763 14. ac0f4e6 15. 3e833b3 16. c1f5509 17. edd0ccd 18. 4dac67d 19. 97b235d 20. 16797c3
- Loading branch information
Showing
6 changed files
with
86 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?xml version="1.0"?> | ||
<!-- | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
--> | ||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> | ||
<type name="Magento\Framework\App\FrontControllerInterface"> | ||
<plugin name="page_cache_form_key_from_cookie" type="Magento\PageCache\Plugin\RegisterFormKeyFromCookie" /> | ||
</type> | ||
</config> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
dev/tests/api-functional/testsuite/Magento/Webapi/RestSessionCookieTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
namespace Magento\Webapi; | ||
|
||
use Magento\Framework\Module\Manager; | ||
use Magento\TestFramework\Helper\Bootstrap; | ||
|
||
/** | ||
* Class for RestSessionCookieTest | ||
*/ | ||
class RestSessionCookieTest extends \Magento\TestFramework\TestCase\WebapiAbstract | ||
{ | ||
|
||
private $moduleManager; | ||
private $objectManager; | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
protected function setUp(): void | ||
{ | ||
$this->objectManager = Bootstrap::getObjectManager(); | ||
$this->moduleManager = $this->objectManager->get(Manager::class); | ||
if ($this->moduleManager->isEnabled('Magento_B2b')) { | ||
$this->markTestSkipped('Skipped, because this logic is rewritten on B2B.'); | ||
} | ||
} | ||
|
||
/** | ||
* Check for non exist cookie PHPSESSID | ||
*/ | ||
public function testRestSessionNoCookie() | ||
{ | ||
$this->_markTestAsRestOnly(); | ||
/** @var $curlClient CurlClientWithCookies */ | ||
|
||
$curlClient = $this->objectManager | ||
->get(\Magento\TestFramework\TestCase\HttpClient\CurlClientWithCookies::class); | ||
$phpSessionCookieName = | ||
[ | ||
'cookie_name' => 'PHPSESSID', | ||
]; | ||
|
||
$response = $curlClient->get('/rest/V1/directory/countries', []); | ||
|
||
$cookie = $this->findCookie($phpSessionCookieName['cookie_name'], $response['cookies']); | ||
$this->assertNull($cookie); | ||
} | ||
|
||
/** | ||
* Find cookie with given name in the list of cookies | ||
* | ||
* @param string $cookieName | ||
* @param array $cookies | ||
* @return $cookie|null | ||
* @SuppressWarnings(PHPMD.UnusedLocalVariable) | ||
*/ | ||
private function findCookie($cookieName, $cookies) | ||
{ | ||
foreach ($cookies as $cookieIndex => $cookie) { | ||
if ($cookie['name'] === $cookieName) { | ||
return $cookie; | ||
} | ||
} | ||
return null; | ||
} | ||
} |