Skip to content

Commit bf976a0

Browse files
committed
Merge remote-tracking branch 'commerce/2.4-develop' into MC-40448-integration-tests-failures
2 parents 55cc635 + 2a4641b commit bf976a0

File tree

153 files changed

+4476
-562
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

153 files changed

+4476
-562
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\AwsS3\Test\Mftf\Helper;
9+
10+
use Psr\Log\LoggerInterface;
11+
12+
/**
13+
* Mocked logger for using the AwsS3 driver in testing
14+
*
15+
* Ignores most log messages but throws errors on error/critical/emergency logs so tests will fail
16+
*/
17+
class MockTestLogger implements LoggerInterface {
18+
19+
public function emergency($message, array $context = array())
20+
{
21+
throw new \Exception($message);
22+
}
23+
24+
public function alert($message, array $context = array())
25+
{
26+
// noop
27+
}
28+
29+
public function critical($message, array $context = array())
30+
{
31+
throw new \Exception($message);
32+
}
33+
34+
public function error($message, array $context = array())
35+
{
36+
throw new \Exception($message);
37+
}
38+
39+
public function warning($message, array $context = array())
40+
{
41+
// noop
42+
}
43+
44+
public function notice($message, array $context = array())
45+
{
46+
// noop
47+
}
48+
49+
public function info($message, array $context = array())
50+
{
51+
// noop
52+
}
53+
54+
public function debug($message, array $context = array())
55+
{
56+
// noop
57+
}
58+
59+
public function log($level, $message, array $context = array())
60+
{
61+
// noop
62+
}
63+
}
Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\AwsS3\Test\Mftf\Helper;
9+
10+
use Aws\S3\S3Client;
11+
use Codeception\Lib\ModuleContainer;
12+
use League\Flysystem\AwsS3v3\AwsS3Adapter;
13+
use Magento\AwsS3\Driver\AwsS3;
14+
use Magento\FunctionalTestingFramework\Helper\Helper;
15+
use Magento\Framework\Filesystem\DriverInterface;
16+
17+
/**
18+
* Class for MFTF helpers for doing file assertions using S3.
19+
*/
20+
class S3FileAssertions extends Helper
21+
{
22+
/**
23+
* @var DriverInterface $driver
24+
*/
25+
private $driver;
26+
27+
/**
28+
* Call the parent constructor then create the AwsS3 driver from environment variables
29+
*
30+
* @param ModuleContainer $moduleContainer
31+
* @param array|null $config
32+
* @return void
33+
*/
34+
public function __construct(ModuleContainer $moduleContainer, ?array $config = null)
35+
{
36+
parent::__construct($moduleContainer, $config);
37+
38+
$region = getenv('REMOTE_STORAGE_AWSS3_REGION');
39+
$prefix = getenv('REMOTE_STORAGE_AWSS3_PREFIX');
40+
$bucket = getenv('REMOTE_STORAGE_AWSS3_BUCKET');
41+
$accessKey = getenv('REMOTE_STORAGE_AWSS3_ACCESS_KEY');
42+
$secretKey = getenv('REMOTE_STORAGE_AWSS3_SECRET_KEY');
43+
44+
$config = [
45+
'version' => 'latest',
46+
'credentials' => [
47+
'key' => $accessKey,
48+
'secret' => $secretKey
49+
],
50+
'bucket' => $bucket,
51+
'region' => $region
52+
];
53+
54+
if (empty($config['credentials']['key']) || empty($config['credentials']['secret'])) {
55+
unset($config['credentials']);
56+
}
57+
58+
$client = new S3Client($config);
59+
$adapter = new AwsS3Adapter($client, $config['bucket'], $prefix);
60+
$objectUrl = $client->getObjectUrl($adapter->getBucket(), $adapter->applyPathPrefix('.'));
61+
$s3Driver = new AwsS3($adapter, new MockTestLogger(), $objectUrl);
62+
63+
$this->driver = $s3Driver;
64+
}
65+
66+
/**
67+
* Create a file in the S3 bucket
68+
*
69+
* @param string $filePath
70+
* @param string $text
71+
* @return void
72+
*
73+
* @throws \Magento\Framework\Exception\FileSystemException
74+
*/
75+
public function createTextFile($filePath, $text): void
76+
{
77+
$this->driver->filePutContents($filePath, $text);
78+
}
79+
80+
/**
81+
* Delete a file from the S3 bucket if it exists
82+
*
83+
* @param string $filePath
84+
* @return void
85+
*
86+
* @throws \Magento\Framework\Exception\FileSystemException
87+
*/
88+
public function deleteFileIfExists($filePath): void
89+
{
90+
if ($this->driver->isExists($filePath)) {
91+
$this->driver->deleteFile($filePath);
92+
}
93+
}
94+
95+
/**
96+
* Assert a file exists on the remote storage system
97+
*
98+
* @param string $filePath
99+
* @param string $message
100+
* @return void
101+
*
102+
* @throws \Magento\Framework\Exception\FileSystemException
103+
*/
104+
public function assertFileExists($filePath, $message = ''): void
105+
{
106+
$this->assertTrue($this->driver->isExists($filePath), $message);
107+
}
108+
109+
/**
110+
* Assert a file does not exist on the remote storage system
111+
*
112+
* @param string $filePath
113+
* @param string $message
114+
* @return void
115+
*
116+
* @throws \Magento\Framework\Exception\FileSystemException
117+
*/
118+
public function assertFileDoesNotExist($filePath, $message = ''): void
119+
{
120+
$this->assertFalse($this->driver->isExists($filePath), $message);
121+
}
122+
123+
/**
124+
* Assert a file on the remote storage system has no contents
125+
*
126+
* @param string $filePath
127+
* @param string $message
128+
* @return void
129+
*
130+
* @throws \Magento\Framework\Exception\FileSystemException
131+
*/
132+
public function assertFileEmpty($filePath, $message = ""): void
133+
{
134+
$this->assertEmpty($this->driver->fileGetContents($filePath), $message);
135+
}
136+
137+
/**
138+
* Assert a file on the remote storage system is not empty
139+
*
140+
* @param string $filePath
141+
* @param string $message
142+
* @return void
143+
*
144+
* @throws \Magento\Framework\Exception\FileSystemException
145+
*/
146+
public function assertFileNotEmpty($filePath, $message = ""): void
147+
{
148+
$this->assertNotEmpty($this->driver->fileGetContents($filePath), $message);
149+
}
150+
151+
/**
152+
* Assert a file on the remote storage system contains a given string
153+
*
154+
* @param string $filePath
155+
* @param string $text
156+
* @param string $message
157+
* @return void
158+
*
159+
* @throws \Magento\Framework\Exception\FileSystemException
160+
*/
161+
public function assertFileContainsString($filePath, $text, $message = ""): void
162+
{
163+
$this->assertStringContainsString($text, $this->driver->fileGetContents($filePath), $message);
164+
}
165+
166+
/**
167+
* Assert a file on the remote storage system does not contain a given string
168+
*
169+
* @param string $filePath
170+
* @param string $text
171+
* @param string $message
172+
* @return void
173+
*
174+
* @throws \Magento\Framework\Exception\FileSystemException
175+
*/
176+
public function assertFileDoesNotContain($filePath, $text, $message = ""): void
177+
{
178+
$this->assertStringNotContainsString($text, $this->driver->fileGetContents($filePath), $message);
179+
}
180+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<test name="AwsS3AdminImportSimpleAndConfigurableProductsWithAssignedImagesTest" extends="AdminImportSimpleAndConfigurableProductsWithAssignedImagesTest">
12+
<annotations>
13+
<features value="AwsS3"/>
14+
<stories value="Import Products"/>
15+
<title value="S3 - Import Configurable Product With Simple Child Products With Images"/>
16+
<description value="Imports a .csv file containing a configurable product with 3 child simple products that
17+
have images. Verifies that products are imported successfully and that the images are attached to the
18+
products as expected."/>
19+
<severity value="MAJOR"/>
20+
<group value="importExport"/>
21+
<group value="remote_storage_aws_s3"/>
22+
<skip>
23+
<issueId value="MC-39280"/>
24+
</skip>
25+
</annotations>
26+
27+
<before>
28+
<!-- Enable AWS S3 Remote Storage -->
29+
<magentoCLI command="setup:config:set {{RemoteStorageAwsS3ConfigData.enable_options}}" stepKey="enableRemoteStorage"/>
30+
</before>
31+
32+
<after>
33+
<!-- Disable AWS S3 Remote Storage -->
34+
<magentoCLI command="setup:config:set {{RemoteStorageAwsS3ConfigData.disable_options}}" stepKey="disableRemoteStorage"/>
35+
</after>
36+
</test>
37+
</tests>

app/code/Magento/Backend/App/Action/Plugin/Authentication.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,8 @@ protected function _redirectIfNeededAfterLogin(\Magento\Framework\App\RequestInt
225225

226226
// Checks, whether secret key is required for admin access or request uri is explicitly set
227227
if ($this->_url->useSecretKey()) {
228-
$requestUri = $this->_url->getUrl('*/*/*', ['_current' => true]);
228+
$requestParts = explode('/', trim($request->getRequestUri(), '/'), 2);
229+
$requestUri = $this->_url->getUrl(array_pop($requestParts));
229230
} elseif ($request) {
230231
$requestUri = $request->getRequestUri();
231232
}

app/code/Magento/Backend/Controller/Adminhtml/Auth/Login.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,10 @@ public function execute()
4949
}
5050

5151
$requestUrl = $this->getRequest()->getUri();
52-
$backendUrl = $this->getUrl('*');
53-
// redirect according to rewrite rule
54-
if ($requestUrl != $backendUrl) {
55-
return $this->getRedirect($backendUrl);
52+
if (!$requestUrl->isValid()) {
53+
return $this->getRedirect($this->getUrl('*'));
5654
}
55+
5756
return $this->resultPageFactory->create();
5857
}
5958

app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -916,7 +916,12 @@ public function addWebsiteFilter($websites = null)
916916
}
917917

918918
$this->_productLimitationFilters['website_ids'] = $websites;
919-
$this->_applyProductLimitations();
919+
920+
if ($this->getStoreId() == Store::DEFAULT_STORE_ID) {
921+
$this->_productLimitationJoinWebsite();
922+
} else {
923+
$this->_applyProductLimitations();
924+
}
920925

921926
return $this;
922927
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
-->
7+
8+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10+
<actionGroup name="AssertStorefrontProductNameIsNotOnProductMainPageActionGroup">
11+
<annotations>
12+
<description>Validates that the provided Product Name is NOT present on a Storefront page.</description>
13+
</annotations>
14+
<arguments>
15+
<argument name="productName" type="string"/>
16+
</arguments>
17+
18+
<waitForPageLoad stepKey="waitForTheProductPageToLoad"/>
19+
<dontSee selector="{{StorefrontCategoryMainSection.productName}}" userInput="{{productName}}" stepKey="dontSeeProductName"/>
20+
</actionGroup>
21+
</actionGroups>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
-->
7+
8+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
9+
<actionGroup name="StorefrontNavigateToCategoryUrlActionGroup">
10+
<annotations>
11+
<description>Goes to the Storefront Category page for the provided Category URL.</description>
12+
</annotations>
13+
<arguments>
14+
<argument name="categoryUrl" type="string"/>
15+
</arguments>
16+
<amOnPage url="{{StorefrontCategoryPage.url(categoryUrl)}}" stepKey="goToStorefrontCategoryPage"/>
17+
</actionGroup>
18+
</actionGroups>

app/code/Magento/Catalog/Test/Mftf/ActionGroup/StorefrontProductPageSelectDropDownOptionValueActionGroup.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,6 @@
1818
</arguments>
1919

2020
<selectOption selector="{{StorefrontProductInfoMainSection.productOptionSelect(attributeLabel)}}" userInput="{{optionLabel}}" stepKey="fillDropDownAttributeOption"/>
21+
<waitForPageLoad stepKey="waitForPageLoad"/>
2122
</actionGroup>
2223
</actionGroups>

0 commit comments

Comments
 (0)