Merge pull request #7951 from appwrite/fix-admin-mode-on-console
fix: admin mode on console
This commit is contained in:
commit
143b73deef
2 changed files with 40 additions and 0 deletions
|
@ -367,6 +367,16 @@ function router(App $utopia, Database $dbForConsole, callable $getProjectDB, Swo
|
|||
return false;
|
||||
}
|
||||
|
||||
App::init()
|
||||
->groups(['api'])
|
||||
->inject('project')
|
||||
->inject('mode')
|
||||
->action(function (Document $project, string $mode) {
|
||||
if ($mode === APP_MODE_ADMIN && $project->getId() === 'console') {
|
||||
throw new AppwriteException(AppwriteException::GENERAL_BAD_REQUEST, 'Admin mode is not allowed for console project');
|
||||
}
|
||||
});
|
||||
|
||||
App::init()
|
||||
->groups(['api', 'web'])
|
||||
->inject('utopia')
|
||||
|
|
30
tests/e2e/General/ModeTest.php
Normal file
30
tests/e2e/General/ModeTest.php
Normal file
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\E2E\Services\Console;
|
||||
|
||||
use Appwrite\Extend\Exception;
|
||||
use Tests\E2E\Client;
|
||||
use Tests\E2E\Scopes\ProjectConsole;
|
||||
use Tests\E2E\Scopes\Scope;
|
||||
use Tests\E2E\Scopes\SideClient;
|
||||
|
||||
class ModeTest extends Scope
|
||||
{
|
||||
use ProjectConsole;
|
||||
use SideClient;
|
||||
|
||||
public function testConsoleWithAdminMode(): void
|
||||
{
|
||||
/**
|
||||
* Test for SUCCESS
|
||||
*/
|
||||
$response = $this->client->call(Client::METHOD_GET, '/account', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'x-appwrite-mode' => 'admin',
|
||||
], $this->getHeaders()));
|
||||
|
||||
$this->assertEquals(400, $response['headers']['status-code']);
|
||||
$this->assertEquals(Exception::GENERAL_BAD_REQUEST, $response['body']['type']);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue