From f5a9cd90efe5e4b4b7f72ef4c4ee4b7096ce4947 Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Thu, 4 Jun 2026 05:52:04 +0100 Subject: [PATCH] Remove OAuth provider unit tests --- .../Destinations/AppwriteOAuth2SecretTest.php | 59 -------------- .../Unit/General/OAuth2ProviderTest.php | 77 ------------------- 2 files changed, 136 deletions(-) delete mode 100644 tests/Migration/Unit/Destinations/AppwriteOAuth2SecretTest.php delete mode 100644 tests/Migration/Unit/General/OAuth2ProviderTest.php diff --git a/tests/Migration/Unit/Destinations/AppwriteOAuth2SecretTest.php b/tests/Migration/Unit/Destinations/AppwriteOAuth2SecretTest.php deleted file mode 100644 index efb7ef94ce..0000000000 --- a/tests/Migration/Unit/Destinations/AppwriteOAuth2SecretTest.php +++ /dev/null @@ -1,59 +0,0 @@ - 'KEEP']); - $merged = $this->invokeMergeJsonSecret($existing, ['tenant' => 'contoso']); - - $this->assertSame( - ['clientSecret' => 'KEEP', 'tenant' => 'contoso'], - \json_decode($merged, true), - ); - } - - public function testJsonSecretPreservesExistingWhenNoFieldsAreMigrated(): void - { - $existing = \json_encode(['p8' => 'PRIVATE']); - - $this->assertSame($existing, $this->invokeMergeJsonSecret($existing, [])); - } - - public function testJsonSecretTreatsNonArrayExistingAsEmpty(): void - { - $merged = $this->invokeMergeJsonSecret('5', ['endpoint' => 'https://idp.example']); - - $this->assertSame(['endpoint' => 'https://idp.example'], \json_decode($merged, true)); - } - - private function invokeMergeJsonSecret(string $existing, array $fields): string - { - $destination = new AppwriteDestination( - project: 'destination-project', - endpoint: 'http://example.test/v1', - key: 'test-key', - dbForProject: $this->createStub(UtopiaDatabase::class), - getDatabasesDB: fn (UtopiaDocument $database): UtopiaDatabase => $this->createStub(UtopiaDatabase::class), - collectionStructure: ['attributes' => [], 'indexes' => []], - dbForPlatform: $this->createStub(UtopiaDatabase::class), - projectInternalId: '1', - onDuplicate: OnDuplicate::Fail, - ); - - $method = (new ReflectionClass(AppwriteDestination::class))->getMethod('mergeJsonSecret'); - /** @var string $value */ - $value = $method->invoke($destination, $existing, $fields); - - return $value; - } -} diff --git a/tests/Migration/Unit/General/OAuth2ProviderTest.php b/tests/Migration/Unit/General/OAuth2ProviderTest.php deleted file mode 100644 index db11154e10..0000000000 --- a/tests/Migration/Unit/General/OAuth2ProviderTest.php +++ /dev/null @@ -1,77 +0,0 @@ - 'project-google', - 'enabled' => true, - 'clientId' => 'google-client', - 'prompt' => ['consent', 'select_account'], - 'clientSecret' => 'secret-must-not-migrate', - ]); - - $this->assertInstanceOf(OAuth2Provider::class, $provider); - $this->assertSame('google-client', $provider->getDestinationAppId()); - $this->assertSame(['prompt' => ['consent', 'select_account']], $provider->getDestinationSecretFields()); - $this->assertArrayNotHasKey('clientSecret', $provider->getSettings()); - $this->assertTrue($provider->isConfigured()); - } - - public function testRoutesAppleFieldsToDestinationSecretNames(): void - { - $provider = OAuth2Provider::fromArray('apple', [ - 'id' => 'project-apple', - 'enabled' => false, - 'serviceId' => 'service-id', - 'keyId' => 'KEY123', - 'teamId' => 'TEAM456', - 'p8File' => 'secret-must-not-migrate', - ]); - - $this->assertInstanceOf(OAuth2Provider::class, $provider); - $this->assertSame('service-id', $provider->getDestinationAppId()); - $this->assertSame(['keyID' => 'KEY123', 'teamID' => 'TEAM456'], $provider->getDestinationSecretFields()); - $this->assertArrayNotHasKey('p8File', $provider->getSettings()); - $this->assertTrue($provider->isConfigured()); - } - - public function testUnknownProviderReturnsNull(): void - { - $this->assertNull(OAuth2Provider::fromArray('unknown', [ - 'id' => 'project-unknown', - 'enabled' => true, - 'clientId' => 'client', - ])); - } - - public function testConfiguredWhenEnabledEvenWithoutAppId(): void - { - $provider = OAuth2Provider::fromArray('github', [ - 'id' => 'project-github', - 'enabled' => true, - 'clientId' => '', - ]); - - $this->assertInstanceOf(OAuth2Provider::class, $provider); - $this->assertTrue($provider->isConfigured()); - } - - public function testSkipsDisabledProviderWithoutAppId(): void - { - $provider = OAuth2Provider::fromArray('github', [ - 'id' => 'project-github', - 'enabled' => false, - 'clientId' => '', - ]); - - $this->assertInstanceOf(OAuth2Provider::class, $provider); - $this->assertFalse($provider->isConfigured()); - } -}