Merge pull request #7341 from appwrite/collection-not-found
databases.php collection not found
This commit is contained in:
commit
aeea5e8328
|
@ -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')
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue