File tree Expand file tree Collapse file tree
apps/files_external/tests/Storage
lib/private/Files/ObjectStore Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+ /**
5+ * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
6+ * SPDX-License-Identifier: AGPL-3.0-or-later
7+ */
8+
9+ namespace OCA \Files_External \Tests \Storage ;
10+
11+ use OCA \Files_External \Lib \Storage \AmazonS3 ;
12+ use Test \TestCase ;
13+
14+ /**
15+ * Regression test for the storage id computation in AmazonS3::__construct().
16+ *
17+ * Constructs the storage directly (no live S3 backend) to exercise only the id
18+ * derivation, which runs unconditionally in the constructor.
19+ */
20+ #[\PHPUnit \Framework \Attributes \Group('S3 ' )]
21+ class Amazons3IdTest extends TestCase {
22+ /**
23+ * Mounts authenticating via the AWS SDK default credential chain (env, EC2
24+ * instance profile, ECS task role) carry no static `key` param. The id must
25+ * still be derivable without emitting an "Undefined array key" warning
26+ * (PHPUnit fails the test on any emitted warning).
27+ */
28+ public function testConstructWithoutKey (): void {
29+ $ storage = new AmazonS3 (['bucket ' => 'test-bucket ' ]);
30+ $ this ->assertNotEmpty ($ storage ->getId ());
31+ }
32+ }
Original file line number Diff line number Diff line change @@ -64,6 +64,7 @@ protected function parseParams($params) {
6464 $ this ->retriesMaxAttempts = $ params ['retriesMaxAttempts ' ] ?? 5 ;
6565 $ params ['region ' ] = empty ($ params ['region ' ]) ? 'eu-west-1 ' : $ params ['region ' ];
6666 $ params ['hostname ' ] = empty ($ params ['hostname ' ]) ? 's3. ' . $ params ['region ' ] . '.amazonaws.com ' : $ params ['hostname ' ];
67+ $ params ['key ' ] = $ params ['key ' ] ?? '' ;
6768 $ params ['s3-accelerate ' ] = $ params ['hostname ' ] === 's3-accelerate.amazonaws.com ' || $ params ['hostname ' ] === 's3-accelerate.dualstack.amazonaws.com ' ;
6869 if (!isset ($ params ['port ' ]) || $ params ['port ' ] === '' ) {
6970 $ params ['port ' ] = (isset ($ params ['use_ssl ' ]) && $ params ['use_ssl ' ] === false ) ? 80 : 443 ;
You can’t perform that action at this time.
0 commit comments