mirror of
https://github.com/appwrite/appwrite.git
synced 2026-11-18 20:36:03 +00:00
Test OAuth provider migration mappings
This commit is contained in:
1 parent
0bf8ee6709
commit
275afb8e90
3 files changed
+91
-20
No files matched your search
+1
-1
@@ -75,7 +75,7 @@
|
||||
"utopia-php/lock": "0.2.*",
|
||||
"utopia-php/logger": "0.8.*",
|
||||
"utopia-php/messaging": "1.0.*",
|
||||
"utopia-php/migration": "1.*",
|
||||
"utopia-php/migration": "dev-add-oauth-providers-migration",
|
||||
"utopia-php/platform": "1.0.0-rc4",
|
||||
"utopia-php/pools": "1.*",
|
||||
"utopia-php/span": "1.1.*",
|
||||
|
||||
Generated
+9
-8
@@ -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": "0c23c30bba86ad84377d4d1abce0992a",
|
||||
"content-hash": "5d6823938d39a2ddbd3c40ada5fca362",
|
||||
"packages": [
|
||||
{
|
||||
"name": "adhocore/jwt",
|
||||
@@ -4657,16 +4657,16 @@
|
||||
},
|
||||
{
|
||||
"name": "utopia-php/migration",
|
||||
"version": "1.13.0",
|
||||
"version": "dev-add-oauth-providers-migration",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/utopia-php/migration.git",
|
||||
"reference": "0395af61922b52fb73bd9dbfb2dd10ac7aed2b01"
|
||||
"reference": "dede00a186d30265318c7d7e82c85907584878ca"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/utopia-php/migration/zipball/0395af61922b52fb73bd9dbfb2dd10ac7aed2b01",
|
||||
"reference": "0395af61922b52fb73bd9dbfb2dd10ac7aed2b01",
|
||||
"url": "https://api.github.com/repos/utopia-php/migration/zipball/dede00a186d30265318c7d7e82c85907584878ca",
|
||||
"reference": "dede00a186d30265318c7d7e82c85907584878ca",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -4706,9 +4706,9 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/utopia-php/migration/issues",
|
||||
"source": "https://github.com/utopia-php/migration/tree/1.13.0"
|
||||
"source": "https://github.com/utopia-php/migration/tree/add-oauth-providers-migration"
|
||||
},
|
||||
"time": "2026-06-03T06:15:27+00:00"
|
||||
"time": "2026-06-03T12:59:34+00:00"
|
||||
},
|
||||
{
|
||||
"name": "utopia-php/mongo",
|
||||
@@ -8552,7 +8552,8 @@
|
||||
"aliases": [],
|
||||
"minimum-stability": "dev",
|
||||
"stability-flags": {
|
||||
"utopia-php/http": 5
|
||||
"utopia-php/http": 5,
|
||||
"utopia-php/migration": 20
|
||||
},
|
||||
"prefer-stable": true,
|
||||
"prefer-lowest": false,
|
||||
|
||||
@@ -3377,11 +3377,6 @@ trait MigrationsBase
|
||||
'x-appwrite-key' => $this->getDestinationProject()['apiKey'],
|
||||
];
|
||||
|
||||
// Configure a GitHub OAuth2 provider on the source. enabled=false keeps the
|
||||
// PATCH from triggering live credential verification (enabling fires a real
|
||||
// network call to the provider). The migration carries the readable clientId
|
||||
// and the enabled flag; the clientSecret is write-only on the source API and
|
||||
// is never migrated.
|
||||
$clientId = 'gh-client-' . ID::unique();
|
||||
$configure = $this->client->call(Client::METHOD_PATCH, '/project/oauth2/github', $sourceKeyHeaders, [
|
||||
'clientId' => $clientId,
|
||||
@@ -3391,6 +3386,35 @@ trait MigrationsBase
|
||||
$this->assertEquals(200, $configure['headers']['status-code']);
|
||||
$this->assertSame($clientId, $configure['body']['clientId']);
|
||||
|
||||
$keycloak = $this->client->call(Client::METHOD_PATCH, '/project/oauth2/keycloak', $sourceKeyHeaders, [
|
||||
'clientId' => 'keycloak-client-' . ID::unique(),
|
||||
'clientSecret' => 'keycloak-secret-not-migrated',
|
||||
'endpoint' => 'keycloak.example.com',
|
||||
'realmName' => 'appwrite',
|
||||
'enabled' => false,
|
||||
]);
|
||||
$this->assertEquals(200, $keycloak['headers']['status-code']);
|
||||
|
||||
$oidc = $this->client->call(Client::METHOD_PATCH, '/project/oauth2/oidc', $sourceKeyHeaders, [
|
||||
'clientId' => 'oidc-client-' . ID::unique(),
|
||||
'clientSecret' => 'oidc-secret-not-migrated',
|
||||
'wellKnownURL' => 'https://idp.example.com/.well-known/openid-configuration',
|
||||
'authorizationURL' => 'https://idp.example.com/oauth2/authorize',
|
||||
'tokenURL' => 'https://idp.example.com/oauth2/token',
|
||||
'userInfoURL' => 'https://idp.example.com/oauth2/userinfo',
|
||||
'enabled' => false,
|
||||
]);
|
||||
$this->assertEquals(200, $oidc['headers']['status-code']);
|
||||
|
||||
$okta = $this->client->call(Client::METHOD_PATCH, '/project/oauth2/okta', $sourceKeyHeaders, [
|
||||
'clientId' => 'okta-client-' . ID::unique(),
|
||||
'clientSecret' => 'okta-secret-not-migrated',
|
||||
'domain' => 'trial-6400025.okta.com',
|
||||
'authorizationServerId' => 'aus000000000000000h7z',
|
||||
'enabled' => false,
|
||||
]);
|
||||
$this->assertEquals(200, $okta['headers']['status-code']);
|
||||
|
||||
$result = $this->performMigrationSync([
|
||||
'resources' => [
|
||||
Resource::TYPE_OAUTH2_PROVIDER,
|
||||
@@ -3408,19 +3432,40 @@ trait MigrationsBase
|
||||
$this->assertEquals(0, $oauthCounters['pending']);
|
||||
$this->assertEquals(0, $oauthCounters['processing']);
|
||||
$this->assertEquals(0, $oauthCounters['warning']);
|
||||
// Only configured providers migrate; this project set up GitHub alone.
|
||||
$this->assertEquals(1, $oauthCounters['success']);
|
||||
$this->assertEquals(4, $oauthCounters['success']);
|
||||
|
||||
// The GitHub provider must round-trip to the destination: the readable
|
||||
// clientId and enabled flag are carried; the secret is write-only and reads
|
||||
// back empty on every path.
|
||||
$fetched = $this->client->call(Client::METHOD_GET, '/project/oauth2/github', $destinationKeyHeaders);
|
||||
$this->assertEquals(200, $fetched['headers']['status-code']);
|
||||
$this->assertSame($clientId, $fetched['body']['clientId']);
|
||||
$this->assertFalse($fetched['body']['enabled']);
|
||||
$this->assertSame('', $fetched['body']['clientSecret']);
|
||||
|
||||
// Reset both projects so the test is idempotent.
|
||||
$fetched = $this->client->call(Client::METHOD_GET, '/project/oauth2/keycloak', $destinationKeyHeaders);
|
||||
$this->assertEquals(200, $fetched['headers']['status-code']);
|
||||
$this->assertSame($keycloak['body']['clientId'], $fetched['body']['clientId']);
|
||||
$this->assertSame('keycloak.example.com', $fetched['body']['endpoint']);
|
||||
$this->assertSame('appwrite', $fetched['body']['realmName']);
|
||||
$this->assertFalse($fetched['body']['enabled']);
|
||||
$this->assertSame('', $fetched['body']['clientSecret']);
|
||||
|
||||
$fetched = $this->client->call(Client::METHOD_GET, '/project/oauth2/oidc', $destinationKeyHeaders);
|
||||
$this->assertEquals(200, $fetched['headers']['status-code']);
|
||||
$this->assertSame($oidc['body']['clientId'], $fetched['body']['clientId']);
|
||||
$this->assertSame('https://idp.example.com/.well-known/openid-configuration', $fetched['body']['wellKnownURL']);
|
||||
$this->assertSame('https://idp.example.com/oauth2/authorize', $fetched['body']['authorizationURL']);
|
||||
$this->assertSame('https://idp.example.com/oauth2/token', $fetched['body']['tokenURL']);
|
||||
$this->assertSame('https://idp.example.com/oauth2/userinfo', $fetched['body']['userInfoURL']);
|
||||
$this->assertFalse($fetched['body']['enabled']);
|
||||
$this->assertSame('', $fetched['body']['clientSecret']);
|
||||
|
||||
$fetched = $this->client->call(Client::METHOD_GET, '/project/oauth2/okta', $destinationKeyHeaders);
|
||||
$this->assertEquals(200, $fetched['headers']['status-code']);
|
||||
$this->assertSame($okta['body']['clientId'], $fetched['body']['clientId']);
|
||||
$this->assertSame('trial-6400025.okta.com', $fetched['body']['domain']);
|
||||
$this->assertSame('aus000000000000000h7z', $fetched['body']['authorizationServerId']);
|
||||
$this->assertFalse($fetched['body']['enabled']);
|
||||
$this->assertSame('', $fetched['body']['clientSecret']);
|
||||
|
||||
$this->client->call(Client::METHOD_PATCH, '/project/oauth2/github', $sourceKeyHeaders, [
|
||||
'clientId' => '',
|
||||
'clientSecret' => '',
|
||||
@@ -3431,6 +3476,31 @@ trait MigrationsBase
|
||||
'clientSecret' => '',
|
||||
'enabled' => false,
|
||||
]);
|
||||
foreach ([$sourceKeyHeaders, $destinationKeyHeaders] as $headers) {
|
||||
$this->client->call(Client::METHOD_PATCH, '/project/oauth2/keycloak', $headers, [
|
||||
'clientId' => '',
|
||||
'clientSecret' => '',
|
||||
'endpoint' => '',
|
||||
'realmName' => '',
|
||||
'enabled' => false,
|
||||
]);
|
||||
$this->client->call(Client::METHOD_PATCH, '/project/oauth2/oidc', $headers, [
|
||||
'clientId' => '',
|
||||
'clientSecret' => '',
|
||||
'wellKnownURL' => '',
|
||||
'authorizationURL' => '',
|
||||
'tokenURL' => '',
|
||||
'userInfoURL' => '',
|
||||
'enabled' => false,
|
||||
]);
|
||||
$this->client->call(Client::METHOD_PATCH, '/project/oauth2/okta', $headers, [
|
||||
'clientId' => '',
|
||||
'clientSecret' => '',
|
||||
'domain' => '',
|
||||
'authorizationServerId' => '',
|
||||
'enabled' => false,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user