diff --git a/app/config/onboarding.php b/app/config/onboarding.php index 014301a72e..21a105b878 100644 --- a/app/config/onboarding.php +++ b/app/config/onboarding.php @@ -33,6 +33,10 @@ return [ 'databases.create' => true, 'databases.createCollection' => true, 'databases.createDocument' => true, + // Databases — dedicated + 'mysql.create' => true, + 'postgresql.create' => true, + 'mongo.create' => true, // Storage 'storage.createBucket' => true, diff --git a/app/config/services.php b/app/config/services.php index 16a0bd6901..c05a917a58 100644 --- a/app/config/services.php +++ b/app/config/services.php @@ -335,7 +335,7 @@ return [ 'tests' => true, 'optional' => false, 'icon' => '', - 'platforms' => ['client', 'server', 'console'], + 'platforms' => ['console'], ], 'advisor' => [ 'key' => 'advisor', diff --git a/app/controllers/general.php b/app/controllers/general.php index 47a5f67427..c8d266cf8d 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -1664,7 +1664,6 @@ Http::get('/v1/ping') ->groups(['api', 'general']) ->desc('Test the connection between the Appwrite and the SDK.') ->label('scope', 'global') - ->label('event', 'projects.[projectId].ping') ->label('sdk', new Method( namespace: 'ping', group: null, @@ -1699,6 +1698,7 @@ Http::get('/v1/ping') ]))); $queueForEvents + ->setEvent('projects.[projectId].ping') ->setParam('projectId', $project->getId()) ->setPayload($response->output($project, Response::MODEL_PROJECT)); } diff --git a/composer.json b/composer.json index aca0e41e97..1f231eddbb 100644 --- a/composer.json +++ b/composer.json @@ -57,7 +57,7 @@ "utopia-php/agents": "2.*", "utopia-php/analytics": "0.15.*", "utopia-php/audit": "2.6.*", - "utopia-php/auth": "^0.7", + "utopia-php/auth": "^0.8", "utopia-php/cache": "^3.0.0", "utopia-php/cli": "^0.24", "utopia-php/compression": "0.1.*", diff --git a/composer.lock b/composer.lock index 99d770e9a8..8bad4622a2 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "17128527d9ef62968ea12eb43a81fdfb", + "content-hash": "091a71ba9518a11bacfa660d4df558ba", "packages": [ { "name": "adhocore/jwt", @@ -3319,16 +3319,16 @@ }, { "name": "utopia-php/auth", - "version": "0.7.0", + "version": "0.8.0", "source": { "type": "git", "url": "https://github.com/utopia-php/auth.git", - "reference": "22a2cf6ca604e5cc6bf10f0f8240195f0baa063a" + "reference": "1d77657e9c91e48e873e6e096f9d4f55f778b11f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/auth/zipball/22a2cf6ca604e5cc6bf10f0f8240195f0baa063a", - "reference": "22a2cf6ca604e5cc6bf10f0f8240195f0baa063a", + "url": "https://api.github.com/repos/utopia-php/auth/zipball/1d77657e9c91e48e873e6e096f9d4f55f778b11f", + "reference": "1d77657e9c91e48e873e6e096f9d4f55f778b11f", "shasum": "" }, "require": { @@ -3336,7 +3336,7 @@ "ext-openssl": "*", "ext-scrypt": "*", "ext-sodium": "*", - "php": ">=8.1" + "php": ">=8.3" }, "type": "library", "autoload": { @@ -3363,9 +3363,9 @@ ], "support": { "issues": "https://github.com/utopia-php/auth/issues", - "source": "https://github.com/utopia-php/auth/tree/0.7.0" + "source": "https://github.com/utopia-php/auth/tree/0.8.0" }, - "time": "2026-06-22T11:58:24+00:00" + "time": "2026-07-08T05:10:32+00:00" }, { "name": "utopia-php/cache", diff --git a/docs/references/storage/list-folders.md b/docs/references/storage/list-folders.md new file mode 100644 index 0000000000..446580b223 --- /dev/null +++ b/docs/references/storage/list-folders.md @@ -0,0 +1 @@ +Get a list of the child folders directly inside a virtual folder in a bucket. Folders are derived from the folder paths of existing files: a folder exists while at least one file lives under it, and empty pages mean the listing is complete. diff --git a/src/Appwrite/Auth/OAuth2/Oidc.php b/src/Appwrite/Auth/OAuth2/Oidc.php index c9810c48eb..d5b54dfc59 100644 --- a/src/Appwrite/Auth/OAuth2/Oidc.php +++ b/src/Appwrite/Auth/OAuth2/Oidc.php @@ -38,18 +38,39 @@ class Oidc extends OAuth2 protected array $wellKnownConfiguration = []; + /** + * Memoized decode of the JSON stored in appSecret. Building a single login + * URL reads the secret several times (prompt, max_age, each endpoint), so + * decode once and reuse. + * + * @var array|null + */ + protected ?array $decodedAppSecret = null; + /** * @return string */ public function getLoginURL(): string { - return $this->getAuthorizationEndpoint() . '?' . \http_build_query([ + $params = [ 'client_id' => $this->appID, 'redirect_uri' => $this->callback, 'state' => \json_encode($this->state), 'scope' => \implode(' ', $this->getScopes()), 'response_type' => 'code', - ]); + ]; + + $prompt = $this->getPrompt(); + if (!empty($prompt)) { + $params['prompt'] = $prompt; + } + + $maxAge = $this->getMaxAge(); + if ($maxAge !== null) { + $params['max_age'] = $maxAge; + } + + return $this->getAuthorizationEndpoint() . '?' . \http_build_query($params); } /** @@ -196,6 +217,40 @@ class Oidc extends OAuth2 return $secret['clientSecret'] ?? ''; } + /** + * Extracts the prompt values from the JSON stored in appSecret. + * + * @return string + */ + protected function getPrompt(): string + { + $secret = $this->getAppSecret(); + $prompt = $secret['prompt'] ?? []; + + if (!\is_array($prompt)) { + $prompt = [$prompt]; + } + + return \implode(' ', $prompt); + } + + /** + * Extracts the max_age value from the JSON stored in appSecret. + * + * @return int|null + */ + protected function getMaxAge(): ?int + { + $secret = $this->getAppSecret(); + $maxAge = $secret['maxAge'] ?? null; + + if ($maxAge === null || $maxAge === '') { + return null; + } + + return (int) $maxAge; + } + /** * Extracts the well known endpoint from the JSON stored in appSecret. * @@ -257,7 +312,9 @@ class Oidc extends OAuth2 protected function getUserinfoEndpoint(): string { $secret = $this->getAppSecret(); - $endpoint = $secret['userinfoEndpoint'] ?? ''; + // Read the legacy lowercase `userinfoEndpoint` key as a fallback so that + // OIDC configs stored via the old generic oauth2 PATCH endpoint keep working. + $endpoint = $secret['userInfoEndpoint'] ?? $secret['userinfoEndpoint'] ?? ''; if (!empty($endpoint)) { return $endpoint; } @@ -289,11 +346,16 @@ class Oidc extends OAuth2 */ protected function getAppSecret(): array { + if ($this->decodedAppSecret !== null) { + return $this->decodedAppSecret; + } + try { $secret = \json_decode($this->appSecret, true, 512, JSON_THROW_ON_ERROR); } catch (\Throwable $th) { throw new \Exception('Invalid secret'); } - return $secret; + + return $this->decodedAppSecret = \is_array($secret) ? $secret : []; } } diff --git a/src/Appwrite/Migration/Version/V25.php b/src/Appwrite/Migration/Version/V25.php index 1b8533fb39..f59f4e3542 100644 --- a/src/Appwrite/Migration/Version/V25.php +++ b/src/Appwrite/Migration/Version/V25.php @@ -7,8 +7,6 @@ use Exception; use Throwable; use Utopia\Console; use Utopia\Database\Database; -use Utopia\Database\Document; -use Utopia\Database\Exception\Duplicate; use Utopia\Database\Query; class V25 extends Migration @@ -20,9 +18,6 @@ class V25 extends Migration { Console::info('Migrating collections'); $this->migrateCollections(); - - Console::info('Migrating buckets'); - $this->migrateBuckets(); } /** @@ -92,38 +87,4 @@ class V25 extends Migration } } } - - /** - * Add the virtual folder `folder` attribute and index to every - * per-bucket files collection. - * - * @return void - * @throws Throwable - */ - private function migrateBuckets(): void - { - $this->dbForProject->foreach('buckets', function (Document $bucket) { - $bucketTable = "bucket_{$bucket->getSequence()}"; - Console::log("Migrating Bucket {$bucket->getId()} ({$bucket->getAttribute('name')})"); - - try { - $this->createAttributeFromCollection($this->dbForProject, $bucketTable, 'folder', 'files'); - } catch (Duplicate) { - Console::warning("'folder' from {$bucketTable}: Column already exists"); - } catch (Throwable $th) { - Console::warning("'folder' from {$bucketTable}: {$th->getMessage()}"); - } - - try { - $this->createIndexFromCollection($this->dbForProject, $bucketTable, '_key_folder', 'files'); - } catch (Duplicate) { - Console::warning("'_key_folder' from {$bucketTable}: Index already exists"); - } catch (Throwable $th) { - Console::warning("'_key_folder' from {$bucketTable}: {$th->getMessage()}"); - } - - $this->dbForProject->purgeCachedCollection($bucketTable); - $this->dbForProject->purgeCachedDocument(Database::METADATA, $bucketTable); - }); - } } diff --git a/src/Appwrite/Platform/Modules/Notifications/Http/Notifications/Update.php b/src/Appwrite/Platform/Modules/Notifications/Http/Notifications/Update.php index 9ca7b6b683..01f6bb3c85 100644 --- a/src/Appwrite/Platform/Modules/Notifications/Http/Notifications/Update.php +++ b/src/Appwrite/Platform/Modules/Notifications/Http/Notifications/Update.php @@ -37,7 +37,7 @@ class Update extends Action group: null, name: 'update', description: '/docs/references/notifications/update-notification.md', - auth: [AuthType::SESSION, AuthType::JWT], + auth: [AuthType::ADMIN], responses: [ new SDKResponse( code: Response::STATUS_CODE_OK, diff --git a/src/Appwrite/Platform/Modules/Notifications/Http/Notifications/XList.php b/src/Appwrite/Platform/Modules/Notifications/Http/Notifications/XList.php index 558190d99a..1a8c78a546 100644 --- a/src/Appwrite/Platform/Modules/Notifications/Http/Notifications/XList.php +++ b/src/Appwrite/Platform/Modules/Notifications/Http/Notifications/XList.php @@ -39,7 +39,7 @@ class XList extends Action group: null, name: 'list', description: '/docs/references/notifications/list-notifications.md', - auth: [AuthType::SESSION, AuthType::JWT], + auth: [AuthType::ADMIN], responses: [ new SDKResponse( code: Response::STATUS_CODE_OK, diff --git a/src/Appwrite/Platform/Modules/Project/Http/Project/OAuth2/Oidc/Update.php b/src/Appwrite/Platform/Modules/Project/Http/Project/OAuth2/Oidc/Update.php index 05ad535899..dbf18ad6f0 100644 --- a/src/Appwrite/Platform/Modules/Project/Http/Project/OAuth2/Oidc/Update.php +++ b/src/Appwrite/Platform/Modules/Project/Http/Project/OAuth2/Oidc/Update.php @@ -14,10 +14,14 @@ use Appwrite\Utopia\Response; use Utopia\Database\Database; use Utopia\Database\Document; use Utopia\Database\Validator\Authorization; +use Utopia\Platform\Enum; +use Utopia\Validator\ArrayList; use Utopia\Validator\Boolean; use Utopia\Validator\Nullable; +use Utopia\Validator\Range; use Utopia\Validator\Text; use Utopia\Validator\URL; +use Utopia\Validator\WhiteList; class Update extends Base { @@ -93,6 +97,18 @@ class Update extends Base 'example' => 'https://myoauth.com/oauth2/userinfo', 'hint' => '', ], + [ + '$id' => 'prompt', + 'name' => 'Prompt', + 'example' => '["consent"]', + 'hint' => '', + ], + [ + '$id' => 'maxAge', + 'name' => 'Max Age', + 'example' => '3600', + 'hint' => '', + ], ]); } @@ -129,6 +145,8 @@ class Update extends Base ->param('authorizationURL', null, new Nullable(new URL(allowEmpty: true)), 'OpenID Connect authorization endpoint URL. Required when wellKnownURL is not provided. For example: https://myoauth.com/oauth2/authorize', optional: true) ->param('tokenURL', null, new Nullable(new URL(allowEmpty: true)), 'OpenID Connect token endpoint URL. Required when wellKnownURL is not provided. For example: https://myoauth.com/oauth2/token', optional: true, aliases: ['tokenUrl']) ->param('userInfoURL', null, new Nullable(new URL(allowEmpty: true)), 'OpenID Connect user info endpoint URL. Required when wellKnownURL is not provided. For example: https://myoauth.com/oauth2/userinfo', optional: true, aliases: ['userInfoUrl']) + ->param('prompt', null, new Nullable(new ArrayList(new WhiteList(['none', 'login', 'consent', 'select_account'], true), 4)), 'Array of OpenID Connect prompt values controlling the authentication and consent screens. If "none" is included, it must be the only element. "none" means: don\'t display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. "select_account" means: prompt the user to select an account.', optional: true, enum: new Enum(name: 'ProjectOAuth2OidcPrompt')) + ->param('maxAge', null, new Nullable(new Range(0, PHP_INT_MAX, Range::TYPE_INTEGER)), 'Maximum authentication age in seconds. When set, the user must have authenticated within this many seconds, otherwise they are prompted to re-authenticate.', optional: true) ->param('enabled', null, new Nullable(new Boolean()), 'OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid.', true) ->inject('response') ->inject('dbForPlatform') @@ -153,6 +171,8 @@ class Update extends Base 'authorizationURL' => $decoded['authorizationEndpoint'] ?? '', 'tokenURL' => $decoded['tokenEndpoint'] ?? '', 'userInfoURL' => $decoded['userInfoEndpoint'] ?? '', + 'prompt' => $decoded['prompt'] ?? [], + 'maxAge' => $decoded['maxAge'] ?? null, ]); } @@ -176,6 +196,8 @@ class Update extends Base ?string $authorizationURL, ?string $tokenURL, ?string $userInfoURL, + ?array $prompt, + ?int $maxAge, ?bool $enabled, Response $response, Database $dbForPlatform, @@ -186,8 +208,12 @@ class Update extends Base $providerId = static::getProviderId(); $queueForEvents->setParam('providerId', $providerId); + if ($prompt !== null && \in_array('none', $prompt) && \count($prompt) > 1) { + throw new Exception(Exception::GENERAL_ARGUMENT_INVALID, 'When "none" is used as a prompt value, it must be the only element in the array.'); + } + // The secret is stored as JSON - // `{"clientSecret": "...", "wellKnownEndpoint": "...", "authorizationEndpoint": "...", "tokenEndpoint": "...", "userInfoEndpoint": "..."}` + // `{"clientSecret": "...", "wellKnownEndpoint": "...", "authorizationEndpoint": "...", "tokenEndpoint": "...", "userInfoEndpoint": "...", "prompt": [...], "maxAge": ...}` // so that the OIDC OAuth2 adapter can extract each endpoint individually. // Merge new values with what's already stored so that submitting only a // subset of fields leaves the others untouched. @@ -203,6 +229,8 @@ class Update extends Base 'authorizationEndpoint' => $authorizationURL ?? ($existing['authorizationEndpoint'] ?? ''), 'tokenEndpoint' => $tokenURL ?? ($existing['tokenEndpoint'] ?? ''), 'userInfoEndpoint' => $userInfoURL ?? ($existing['userInfoEndpoint'] ?? ''), + 'prompt' => $prompt ?? ($existing['prompt'] ?? []), + 'maxAge' => $maxAge ?? ($existing['maxAge'] ?? null), ]; // When enabling, require either wellKnownEndpoint alone, or all three diff --git a/src/Appwrite/Platform/Tasks/Specs.php b/src/Appwrite/Platform/Tasks/Specs.php index 46b217e5a9..8b3b9fc073 100644 --- a/src/Appwrite/Platform/Tasks/Specs.php +++ b/src/Appwrite/Platform/Tasks/Specs.php @@ -171,12 +171,6 @@ class Specs extends Action 'description' => 'The user session to authenticate with', 'in' => 'header', ], - 'Mode' => [ - 'type' => 'apiKey', - 'name' => 'X-Appwrite-Mode', - 'description' => '', - 'in' => 'header', - ], 'DevKey' => [ 'type' => 'apiKey', 'name' => 'X-Appwrite-Dev-Key', @@ -264,12 +258,6 @@ class Specs extends Action 'description' => 'The user session to authenticate with', 'in' => 'header', ], - 'Mode' => [ - 'type' => 'apiKey', - 'name' => 'X-Appwrite-Mode', - 'description' => '', - 'in' => 'header', - ], 'ForwardedUserAgent' => [ 'type' => 'apiKey', 'name' => 'X-Forwarded-User-Agent', diff --git a/src/Appwrite/Utopia/Database/Validator/Folder.php b/src/Appwrite/Utopia/Database/Validator/Folder.php new file mode 100644 index 0000000000..592f1a9ff7 --- /dev/null +++ b/src/Appwrite/Utopia/Database/Validator/Folder.php @@ -0,0 +1,72 @@ + self::MAX_LENGTH) { + return false; + } + + if (\preg_match('/[\x00-\x1F\x7F]/', $value)) { + return false; + } + + if (\str_ends_with($value, '/')) { + $value = \substr($value, 0, -1); + } + + if ($value === '') { + return false; + } + + foreach (\explode('/', $value) as $segment) { + if ($segment === '' || $segment === '.' || $segment === '..') { + return false; + } + } + + return true; + } + + /** + * Canonical stored form: trailing slash when non-empty. + */ + public static function normalize(string $value): string + { + if ($value === '') { + return ''; + } + + return \str_ends_with($value, '/') ? $value : $value . '/'; + } + + public function isArray(): bool + { + return false; + } + + public function getType(): string + { + return self::TYPE_STRING; + } +} diff --git a/src/Appwrite/Utopia/Response/Model/OAuth2Oidc.php b/src/Appwrite/Utopia/Response/Model/OAuth2Oidc.php index 0b18539423..e3b4191496 100644 --- a/src/Appwrite/Utopia/Response/Model/OAuth2Oidc.php +++ b/src/Appwrite/Utopia/Response/Model/OAuth2Oidc.php @@ -53,6 +53,21 @@ class OAuth2Oidc extends OAuth2Base 'description' => 'OpenID Connect user info endpoint URL.', 'default' => '', 'example' => 'https://myoauth.com/oauth2/userinfo', + ]) + ->addRule('prompt', [ + 'type' => self::TYPE_ENUM, + 'description' => 'OpenID Connect prompt values controlling the authentication and consent screens.', + 'default' => [], + 'example' => ['consent'], + 'array' => true, + 'enum' => ['none', 'login', 'consent', 'select_account'], + ]) + ->addRule('maxAge', [ + 'type' => self::TYPE_INTEGER, + 'description' => 'Maximum authentication age in seconds. When set, the user must have authenticated within this many seconds.', + 'default' => null, + 'example' => 3600, + 'required' => false, ]); } diff --git a/tests/e2e/Services/Project/OAuth2Base.php b/tests/e2e/Services/Project/OAuth2Base.php index 1bf607fc29..4f6076e581 100644 --- a/tests/e2e/Services/Project/OAuth2Base.php +++ b/tests/e2e/Services/Project/OAuth2Base.php @@ -19,7 +19,7 @@ trait OAuth2Base 'amazon' => ['clientId' => '', 'clientSecret' => '', 'enabled' => false], 'github' => ['clientId' => '', 'clientSecret' => '', 'enabled' => false], 'apple' => ['serviceId' => '', 'keyId' => '', 'teamId' => '', 'p8File' => '', 'enabled' => false], - 'oidc' => ['clientId' => '', 'clientSecret' => '', 'wellKnownURL' => '', 'authorizationURL' => '', 'tokenURL' => '', 'userInfoURL' => '', 'enabled' => false], + 'oidc' => ['clientId' => '', 'clientSecret' => '', 'wellKnownURL' => '', 'authorizationURL' => '', 'tokenURL' => '', 'userInfoURL' => '', 'prompt' => [], 'enabled' => false], 'okta' => ['clientId' => '', 'clientSecret' => '', 'domain' => '', 'authorizationServerId' => '', 'enabled' => false], 'google' => ['clientId' => '', 'clientSecret' => '', 'prompt' => ['consent'], 'enabled' => false], 'dropbox' => ['appKey' => '', 'appSecret' => '', 'enabled' => false], @@ -404,4 +404,96 @@ trait OAuth2Base $params, ); } + + public function testUpdateOAuth2OidcPromptAndMaxAge(): void + { + $response = $this->updateOAuth2('oidc', [ + 'clientId' => 'oidc-prompt-client', + 'clientSecret' => 'oidc-prompt-secret', + 'wellKnownURL' => 'https://idp.example.com/.well-known/openid-configuration', + 'prompt' => ['login', 'consent'], + 'maxAge' => 3600, + 'enabled' => false, + ]); + + $this->assertSame(200, $response['headers']['status-code']); + $this->assertSame(['login', 'consent'], $response['body']['prompt']); + $this->assertSame(3600, $response['body']['maxAge']); + + // GET reads back prompt + maxAge while hiding the clientSecret. + $get = $this->getOAuth2Provider('oidc'); + $this->assertSame(200, $get['headers']['status-code']); + $this->assertSame(['login', 'consent'], $get['body']['prompt']); + $this->assertSame(3600, $get['body']['maxAge']); + $this->assertSame('', $get['body']['clientSecret']); + + // Cleanup + $this->updateOAuth2('oidc', [ + 'clientId' => '', + 'clientSecret' => '', + 'wellKnownURL' => '', + 'authorizationURL' => '', + 'tokenURL' => '', + 'userInfoURL' => '', + 'prompt' => [], + 'enabled' => false, + ]); + } + + public function testUpdateOAuth2OidcPartialPreservesPromptAndMaxAge(): void + { + // Seed prompt + maxAge. + $this->updateOAuth2('oidc', [ + 'clientId' => 'oidc-seed-client', + 'clientSecret' => 'oidc-seed-secret', + 'wellKnownURL' => 'https://idp.example.com/.well-known/openid-configuration', + 'prompt' => ['select_account'], + 'maxAge' => 120, + 'enabled' => false, + ]); + + // Update only clientId — prompt and maxAge must be preserved. + $response = $this->updateOAuth2('oidc', [ + 'clientId' => 'oidc-rotated-client', + ]); + + $this->assertSame(200, $response['headers']['status-code']); + $this->assertSame('oidc-rotated-client', $response['body']['clientId']); + $this->assertSame(['select_account'], $response['body']['prompt']); + $this->assertSame(120, $response['body']['maxAge']); + + // Cleanup + $this->updateOAuth2('oidc', [ + 'clientId' => '', + 'clientSecret' => '', + 'wellKnownURL' => '', + 'prompt' => [], + 'enabled' => false, + ]); + } + + public function testUpdateOAuth2OidcPromptNoneAloneRejected(): void + { + $response = $this->updateOAuth2('oidc', [ + 'clientId' => 'oidc-prompt-none', + 'clientSecret' => 'oidc-prompt-none-secret', + 'prompt' => ['none', 'consent'], + 'enabled' => false, + ]); + + $this->assertSame(400, $response['headers']['status-code']); + $this->assertSame('general_argument_invalid', $response['body']['type']); + } + + public function testUpdateOAuth2OidcMaxAgeNegativeRejected(): void + { + $response = $this->updateOAuth2('oidc', [ + 'clientId' => 'oidc-maxage-negative', + 'clientSecret' => 'oidc-maxage-negative-secret', + 'maxAge' => -1, + 'enabled' => false, + ]); + + $this->assertSame(400, $response['headers']['status-code']); + } } diff --git a/tests/e2e/Services/Storage/StorageBase.php b/tests/e2e/Services/Storage/StorageBase.php index d2f27e4ed9..c2d90a2543 100644 --- a/tests/e2e/Services/Storage/StorageBase.php +++ b/tests/e2e/Services/Storage/StorageBase.php @@ -1921,4 +1921,5 @@ trait StorageBase /* will always be 0 in tests because the worker runs hourly! */ $this->assertGreaterThanOrEqual(0, $bucket['body']['totalSize']); } + } diff --git a/tests/e2e/Services/Storage/StorageCustomClientTest.php b/tests/e2e/Services/Storage/StorageCustomClientTest.php index 7f188241b4..32c92626d5 100644 --- a/tests/e2e/Services/Storage/StorageCustomClientTest.php +++ b/tests/e2e/Services/Storage/StorageCustomClientTest.php @@ -1606,4 +1606,5 @@ final class StorageCustomClientTest extends Scope ]); $this->assertEquals(204, $response['headers']['status-code']); } + } diff --git a/tests/unit/Platform/Modules/Project/OAuth2/OAuth2ProviderTest.php b/tests/unit/Platform/Modules/Project/OAuth2/OAuth2ProviderTest.php index b8eb48f748..4c66222256 100644 --- a/tests/unit/Platform/Modules/Project/OAuth2/OAuth2ProviderTest.php +++ b/tests/unit/Platform/Modules/Project/OAuth2/OAuth2ProviderTest.php @@ -91,7 +91,7 @@ final class OAuth2ProviderTest extends TestCase yield 'google' => [GoogleUpdate::class, ['clientId', 'clientSecret', 'prompt']]; yield 'keycloak' => [KeycloakUpdate::class, ['clientId', 'clientSecret', 'endpoint', 'realmName']]; yield 'microsoft' => [MicrosoftUpdate::class, ['applicationId', 'applicationSecret', 'tenant']]; - yield 'oidc' => [OidcUpdate::class, ['clientId', 'clientSecret', 'wellKnownURL', 'authorizationURL', 'tokenURL', 'userInfoURL']]; + yield 'oidc' => [OidcUpdate::class, ['clientId', 'clientSecret', 'wellKnownURL', 'authorizationURL', 'tokenURL', 'userInfoURL', 'prompt', 'maxAge']]; yield 'okta' => [OktaUpdate::class, ['clientId', 'clientSecret', 'domain', 'authorizationServerId']]; } @@ -347,6 +347,8 @@ final class OAuth2ProviderTest extends TestCase null, null, null, + null, + null, true, ]); @@ -365,6 +367,8 @@ final class OAuth2ProviderTest extends TestCase 'https://idp.example/oauth2/authorize', 'https://idp.example/oauth2/token', 'https://idp.example/oauth2/userinfo', + null, + null, true, ]); @@ -389,6 +393,8 @@ final class OAuth2ProviderTest extends TestCase 'https://idp.example/oauth2/authorize', null, 'https://idp.example/oauth2/userinfo', + null, + null, true, ], assertQueueParam: false, @@ -417,6 +423,8 @@ final class OAuth2ProviderTest extends TestCase 'https://idp.example/oauth2/authorize', 'https://idp.example/oauth2/token', 'https://idp.example/oauth2/userinfo', + null, + null, true, ], ); diff --git a/tests/unit/Utopia/Database/Validator/FolderTest.php b/tests/unit/Utopia/Database/Validator/FolderTest.php new file mode 100644 index 0000000000..c95165ef74 --- /dev/null +++ b/tests/unit/Utopia/Database/Validator/FolderTest.php @@ -0,0 +1,56 @@ +object = new Folder(); + } + + public function testValues(): void + { + // valid + $this->assertTrue($this->object->isValid('')); + $this->assertTrue($this->object->isValid('photos')); + $this->assertTrue($this->object->isValid('photos/')); + $this->assertTrue($this->object->isValid('photos/2026')); + $this->assertTrue($this->object->isValid('photos/2026/')); + $this->assertTrue($this->object->isValid('photos/2026/july')); + $this->assertTrue($this->object->isValid('with space/and-dash_underscore.dot')); + $this->assertTrue($this->object->isValid(\str_repeat('a', 2047) . '/')); + + // invalid + $this->assertFalse($this->object->isValid(null)); + $this->assertFalse($this->object->isValid(false)); + $this->assertFalse($this->object->isValid(123)); + $this->assertFalse($this->object->isValid('/')); + $this->assertFalse($this->object->isValid('/photos')); + $this->assertFalse($this->object->isValid('photos//2026')); + $this->assertFalse($this->object->isValid('photos/./2026')); + $this->assertFalse($this->object->isValid('photos/../2026')); + $this->assertFalse($this->object->isValid('..')); + $this->assertFalse($this->object->isValid('.')); + $this->assertFalse($this->object->isValid("photos/\x01")); + $this->assertFalse($this->object->isValid("photos\n")); + // 2048 chars without trailing slash normalizes to 2049 -- too long + $this->assertFalse($this->object->isValid(\str_repeat('a', 2048))); + $this->assertFalse($this->object->isValid(\str_repeat('a', 3000))); + } + + public function testNormalize(): void + { + $this->assertSame('', Folder::normalize('')); + $this->assertSame('photos/', Folder::normalize('photos')); + $this->assertSame('photos/', Folder::normalize('photos/')); + $this->assertSame('photos/2026/', Folder::normalize('photos/2026')); + } +}