From ef7770faab33790a16102f6a993c270726a3de08 Mon Sep 17 00:00:00 2001 From: harsh mahajan Date: Tue, 26 May 2026 17:14:43 +0530 Subject: [PATCH] Fix OAuth2 provider list ordering --- .../Modules/Project/Http/Project/OAuth2/XList.php | 9 +++++++-- tests/e2e/Services/Project/OAuth2Base.php | 13 +++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/Appwrite/Platform/Modules/Project/Http/Project/OAuth2/XList.php b/src/Appwrite/Platform/Modules/Project/Http/Project/OAuth2/XList.php index 6a84868286..9a0739e0e6 100644 --- a/src/Appwrite/Platform/Modules/Project/Http/Project/OAuth2/XList.php +++ b/src/Appwrite/Platform/Modules/Project/Http/Project/OAuth2/XList.php @@ -76,8 +76,13 @@ class XList extends Action $actions = Base::getProviderActions(); $documents = []; - foreach ($actions as $providerId => $updateClass) { - if (!($providers[$providerId]['enabled'] ?? false)) { + foreach ($providers as $providerId => $config) { + $updateClass = $actions[$providerId] ?? null; + if ($updateClass === null) { + continue; + } + + if (!($config['enabled'] ?? false)) { // Disabled by Appwrite configuration, exclude from response continue; } diff --git a/tests/e2e/Services/Project/OAuth2Base.php b/tests/e2e/Services/Project/OAuth2Base.php index 5959a584ea..8a317f3e1d 100644 --- a/tests/e2e/Services/Project/OAuth2Base.php +++ b/tests/e2e/Services/Project/OAuth2Base.php @@ -81,6 +81,19 @@ trait OAuth2Base } } + public function testListOAuth2ProvidersSortedAlphabetically(): void + { + $response = $this->listOAuth2Providers(); + + $this->assertSame(200, $response['headers']['status-code']); + + $ids = \array_column($response['body']['providers'], '$id'); + $sorted = $ids; + \sort($sorted); + + $this->assertSame($sorted, $ids); + } + /** * Pin the exact set of registered providers — adding or removing a * provider must be a deliberate change to this assertion. Catches