mirror of
https://github.com/appwrite/appwrite.git
synced 2026-11-18 20:36:03 +00:00
(fix): pin console URL scheme in webhook tests and reuse legacy flag in magic-url handler
This commit is contained in:
2 files changed
+36
-30
No files matched your search
@@ -2252,7 +2252,7 @@ Http::post('/v1/account/tokens/magic-url')
|
||||
->inject('proofForPassword')
|
||||
->inject('platform')
|
||||
->inject('authorization')
|
||||
->action(function (string $userId, string $email, string $url, bool $phrase, Request $request, Response $response, Document $user, Document $project, Database $dbForProject, Locale $locale, Event $queueForEvents, MailPublisher $publisherForMails, array $plan, ProofsPassword $proofForPassword, array $platform, Authorization $authorization) {
|
||||
->action(function (string $userId, string $email, string $url, bool $phrase, Request $request, Response $response, Document $user, Document $project, Database $dbForProject, Locale $locale, Event $queueForEvents, MailPublisher $publisherForMails, array $plan, ProofsPassword $proofForPassword, array $platform, Authorization $authorization) use ($legacyConsolePaths) {
|
||||
if (empty(System::getEnv('_APP_SMTP_HOST'))) {
|
||||
throw new Exception(Exception::GENERAL_SMTP_DISABLED, 'SMTP disabled');
|
||||
}
|
||||
@@ -2398,7 +2398,7 @@ Http::post('/v1/account/tokens/magic-url')
|
||||
} elseif ($protocol === 'http' && $port !== '80') {
|
||||
$callbackBase .= ':' . $port;
|
||||
}
|
||||
$url = System::getEnv('_APP_CONSOLE_URL_SCHEME', 'legacy') !== 'root'
|
||||
$url = $legacyConsolePaths
|
||||
? "{$callbackBase}/console/auth/magic-url"
|
||||
: "{$callbackBase}/auth/magic-url";
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ final class WebhooksTest extends TestCase
|
||||
$publisherForNotifications = new NotificationPublisher($publisher, new Queue('v1-notifications'));
|
||||
$worker = new Webhooks();
|
||||
|
||||
$worker->sendAlert(
|
||||
$this->withConsoleUrlScheme('legacy', fn () => $worker->sendAlert(
|
||||
attempts: 10,
|
||||
statusCode: 500,
|
||||
webhook: new Document([
|
||||
@@ -51,7 +51,7 @@ final class WebhooksTest extends TestCase
|
||||
dbForPlatform: $database,
|
||||
publisherForNotifications: $publisherForNotifications,
|
||||
plan: []
|
||||
);
|
||||
));
|
||||
|
||||
$events = $publisher->getEvents('v1-notifications');
|
||||
|
||||
@@ -105,32 +105,26 @@ final class WebhooksTest extends TestCase
|
||||
$publisherForNotifications = new NotificationPublisher($publisher, new Queue('v1-notifications'));
|
||||
$worker = new Webhooks();
|
||||
|
||||
\putenv('_APP_CONSOLE_URL_SCHEME=root');
|
||||
|
||||
try {
|
||||
$worker->sendAlert(
|
||||
attempts: 10,
|
||||
statusCode: 500,
|
||||
webhook: new Document([
|
||||
'$id' => 'webhook-1',
|
||||
'$updatedAt' => '2026-01-01T00:00:00.000+00:00',
|
||||
'name' => 'Payments',
|
||||
'url' => 'https://example.test/webhook',
|
||||
]),
|
||||
project: new Document([
|
||||
'$id' => 'project-1',
|
||||
'$sequence' => 'project-internal-1',
|
||||
'name' => 'Production',
|
||||
'teamInternalId' => 'team-internal-1',
|
||||
'region' => 'fra',
|
||||
]),
|
||||
dbForPlatform: $database,
|
||||
publisherForNotifications: $publisherForNotifications,
|
||||
plan: []
|
||||
);
|
||||
} finally {
|
||||
\putenv('_APP_CONSOLE_URL_SCHEME');
|
||||
}
|
||||
$this->withConsoleUrlScheme('root', fn () => $worker->sendAlert(
|
||||
attempts: 10,
|
||||
statusCode: 500,
|
||||
webhook: new Document([
|
||||
'$id' => 'webhook-1',
|
||||
'$updatedAt' => '2026-01-01T00:00:00.000+00:00',
|
||||
'name' => 'Payments',
|
||||
'url' => 'https://example.test/webhook',
|
||||
]),
|
||||
project: new Document([
|
||||
'$id' => 'project-1',
|
||||
'$sequence' => 'project-internal-1',
|
||||
'name' => 'Production',
|
||||
'teamInternalId' => 'team-internal-1',
|
||||
'region' => 'fra',
|
||||
]),
|
||||
dbForPlatform: $database,
|
||||
publisherForNotifications: $publisherForNotifications,
|
||||
plan: []
|
||||
));
|
||||
|
||||
$events = $publisher->getEvents('v1-notifications');
|
||||
|
||||
@@ -266,6 +260,18 @@ final class WebhooksTest extends TestCase
|
||||
yield 'invalid roles' => [null, false];
|
||||
}
|
||||
|
||||
private function withConsoleUrlScheme(string $scheme, callable $callback): void
|
||||
{
|
||||
$original = \getenv('_APP_CONSOLE_URL_SCHEME');
|
||||
\putenv("_APP_CONSOLE_URL_SCHEME={$scheme}");
|
||||
|
||||
try {
|
||||
$callback();
|
||||
} finally {
|
||||
\putenv($original === false ? '_APP_CONSOLE_URL_SCHEME' : "_APP_CONSOLE_URL_SCHEME={$original}");
|
||||
}
|
||||
}
|
||||
|
||||
private function createPlatformDatabase(): Database
|
||||
{
|
||||
$authorization = new Authorization();
|
||||
|
||||
Reference in new issue
Block a user