Skip to content

Commit d3c13d8

Browse files
committed
ACP2E-3890: [QUANS]Server Issue Potentially Caused by Invalid S3 Access Key
1 parent 462ede9 commit d3c13d8

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

app/code/Magento/AwsS3/Driver/AwsS3.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,9 @@ private function createDirectoryRecursively(string $path): bool
188188
$parentDir = dirname($path);
189189

190190
while (!$this->isDirectory($parentDir)) {
191-
$this->createDirectoryRecursively($parentDir);
191+
if (!$this->createDirectoryRecursively($parentDir)) {
192+
return false;
193+
}
192194
}
193195

194196
if (!$this->isDirectory($path)) {

app/code/Magento/AwsS3/Test/Unit/Driver/AwsS3Test.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,23 @@ public function testCreateDirectory(): void
497497
self::assertTrue($this->driver->createDirectory(self::URL . 'test/test2/'));
498498
}
499499

500+
/**
501+
* This test ensures that the method does not loop infinitely in case of an exception
502+
*
503+
* @return void
504+
* @throws FileSystemException
505+
* @throws \PHPUnit\Framework\MockObject\Exception
506+
*/
507+
public function testShouldFailSafelyIfUnableToCreateDirectory(): void
508+
{
509+
$this->adapterMock->expects(self::once())
510+
->method('createDirectory')
511+
->willThrowException($this->createMock(\League\Flysystem\FilesystemException::class))
512+
->with('test');
513+
514+
self::assertFalse($this->driver->createDirectory(self::URL . 'test/test2/'));
515+
}
516+
500517
public function testRename(): void
501518
{
502519
$this->adapterMock->expects(self::once())

0 commit comments

Comments
 (0)