mirror of
https://github.com/nextcloud/server.git
synced 2026-10-28 15:15:54 +01:00
S3 mounts that authenticate via the AWS SDK default credential chain (env vars, EC2 instance profile, ECS task role) carry no static `key` param. AmazonS3::__construct() read $this->params['key'] unconditionally when deriving the storage id, emitting an "Undefined array key" warning on every storage construction for such mounts. Default `key` to an empty string in S3ConnectionTrait::parseParams(), alongside the other normalized params, so it is always set before the id is derived. The only other reader, paramCredentialProvider(), uses an empty() check that treats '' the same as an absent key, so the SDK default provider chain is still used when no key is configured. Fixes #63564 Assisted-by: Kiro:claude-opus-4.8 Signed-off-by: Sebastian Cruz <default50@gmail.com>
33 lines
1.0 KiB
PHP
33 lines
1.0 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
/**
|
|
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
*/
|
|
|
|
namespace OCA\Files_External\Tests\Storage;
|
|
|
|
use OCA\Files_External\Lib\Storage\AmazonS3;
|
|
use Test\TestCase;
|
|
|
|
/**
|
|
* Regression test for the storage id computation in AmazonS3::__construct().
|
|
*
|
|
* Constructs the storage directly (no live S3 backend) to exercise only the id
|
|
* derivation, which runs unconditionally in the constructor.
|
|
*/
|
|
#[\PHPUnit\Framework\Attributes\Group('S3')]
|
|
class Amazons3IdTest extends TestCase {
|
|
/**
|
|
* Mounts authenticating via the AWS SDK default credential chain (env, EC2
|
|
* instance profile, ECS task role) carry no static `key` param. The id must
|
|
* still be derivable without emitting an "Undefined array key" warning
|
|
* (PHPUnit fails the test on any emitted warning).
|
|
*/
|
|
public function testConstructWithoutKey(): void {
|
|
$storage = new AmazonS3(['bucket' => 'test-bucket']);
|
|
$this->assertNotEmpty($storage->getId());
|
|
}
|
|
}
|