1
0
Fork 0
mirror of synced 2024-05-16 18:52:33 +12:00

Merge pull request #7341 from appwrite/collection-not-found

databases.php collection not found
This commit is contained in:
Jake Barnby 2024-04-29 21:04:31 +12:00 committed by GitHub
commit aeea5e8328
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 43 additions and 0 deletions

View file

@ -369,6 +369,19 @@ App::init()
});
*/
App::init()
->groups(['database', 'functions', 'storage', 'messaging'])
->inject('project')
->inject('request')
->action(function (Document $project, Request $request) {
if ($project->getId() === 'console') {
$message = empty($request->getHeader('x-appwrite-project')) ?
'No Appwrite project was specified. Please specify your project ID when initializing your Appwrite SDK.' :
'This endpoint is not available for the console project. The Appwrite Console is a reserved project ID and cannot be used with the Appwrite SDKs and APIs. Please check if your project ID is correct.';
throw new AppwriteException(AppwriteException::GENERAL_ACCESS_FORBIDDEN, $message);
}
});
App::init()
->groups(['api', 'web'])
->inject('utopia')

View file

@ -85,6 +85,36 @@ trait DatabasesBase
];
}
/**
* @depends testCreateCollection
*/
public function testConsoleProject(array $data)
{
$response = $this->client->call(
Client::METHOD_GET,
'/databases/console/collections/' . $data['moviesId'] . '/documents',
array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => 'console',
], $this->getHeaders())
);
$this->assertEquals(401, $response['headers']['status-code']);
$this->assertEquals('general_access_forbidden', $response['body']['type']);
$this->assertEquals('This endpoint is not available for the console project. The Appwrite Console is a reserved project ID and cannot be used with the Appwrite SDKs and APIs. Please check if your project ID is correct.', $response['body']['message']);
$response = $this->client->call(
Client::METHOD_GET,
'/databases/console/collections/' . $data['moviesId'] . '/documents',
array_merge([
'content-type' => 'application/json',
// 'x-appwrite-project' => '', empty header
], $this->getHeaders())
);
$this->assertEquals(401, $response['headers']['status-code']);
$this->assertEquals('No Appwrite project was specified. Please specify your project ID when initializing your Appwrite SDK.', $response['body']['message']);
}
/**
* @depends testCreateCollection
*/