Merge pull request #4058 from appwrite/fix-deprecate-team-deletion-with-project
Deprecate team deletion with project
This commit is contained in:
commit
d0aedf33ba
|
@ -563,10 +563,6 @@ App::delete('/v1/projects/:projectId')
|
||||||
->setDocument($project)
|
->setDocument($project)
|
||||||
;
|
;
|
||||||
|
|
||||||
if (!$dbForConsole->deleteDocument('teams', $project->getAttribute('teamId', null))) {
|
|
||||||
throw new Exception(Exception::GENERAL_SERVER_ERROR, 'Failed to remove project team from DB');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$dbForConsole->deleteDocument('projects', $projectId)) {
|
if (!$dbForConsole->deleteDocument('projects', $projectId)) {
|
||||||
throw new Exception(Exception::GENERAL_SERVER_ERROR, 'Failed to remove project from DB');
|
throw new Exception(Exception::GENERAL_SERVER_ERROR, 'Failed to remove project from DB');
|
||||||
}
|
}
|
||||||
|
|
|
@ -2333,4 +2333,83 @@ class ProjectsConsoleClientTest extends Scope
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testDeleteProject(): array
|
||||||
|
{
|
||||||
|
$data = [];
|
||||||
|
|
||||||
|
// Create a team and a project
|
||||||
|
$team = $this->client->call(Client::METHOD_POST, '/teams', array_merge([
|
||||||
|
'content-type' => 'application/json',
|
||||||
|
'x-appwrite-project' => $this->getProject()['$id'],
|
||||||
|
], $this->getHeaders()), [
|
||||||
|
'teamId' => ID::unique(),
|
||||||
|
'name' => 'Amating Team',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->assertEquals(201, $team['headers']['status-code']);
|
||||||
|
$this->assertEquals('Amating Team', $team['body']['name']);
|
||||||
|
$this->assertNotEmpty($team['body']['$id']);
|
||||||
|
|
||||||
|
$teamId = $team['body']['$id'];
|
||||||
|
|
||||||
|
$project = $this->client->call(Client::METHOD_POST, '/projects', array_merge([
|
||||||
|
'content-type' => 'application/json',
|
||||||
|
'x-appwrite-project' => $this->getProject()['$id'],
|
||||||
|
], $this->getHeaders()), [
|
||||||
|
'projectId' => ID::unique(),
|
||||||
|
'name' => 'Amazing Project',
|
||||||
|
'teamId' => $teamId,
|
||||||
|
'region' => 'default'
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->assertEquals(201, $project['headers']['status-code']);
|
||||||
|
$this->assertEquals('Amazing Project', $project['body']['name']);
|
||||||
|
$this->assertEquals($teamId, $project['body']['teamId']);
|
||||||
|
$this->assertNotEmpty($project['body']['$id']);
|
||||||
|
|
||||||
|
$projectId = $project['body']['$id'];
|
||||||
|
|
||||||
|
// Ensure I can get both team and project
|
||||||
|
$team = $this->client->call(Client::METHOD_GET, '/teams/' . $teamId, array_merge([
|
||||||
|
'content-type' => 'application/json',
|
||||||
|
'x-appwrite-project' => $this->getProject()['$id'],
|
||||||
|
], $this->getHeaders()));
|
||||||
|
|
||||||
|
$this->assertEquals(200, $team['headers']['status-code']);
|
||||||
|
|
||||||
|
$project = $this->client->call(Client::METHOD_GET, '/projects/' . $projectId, array_merge([
|
||||||
|
'content-type' => 'application/json',
|
||||||
|
'x-appwrite-project' => $this->getProject()['$id'],
|
||||||
|
], $this->getHeaders()));
|
||||||
|
|
||||||
|
$this->assertEquals(200, $project['headers']['status-code']);
|
||||||
|
|
||||||
|
// Delete team
|
||||||
|
$team = $this->client->call(Client::METHOD_DELETE, '/projects/' . $projectId, array_merge([
|
||||||
|
'content-type' => 'application/json',
|
||||||
|
'x-appwrite-project' => $this->getProject()['$id'],
|
||||||
|
], $this->getHeaders()), [
|
||||||
|
'password' => 'password'
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->assertEquals(204, $team['headers']['status-code']);
|
||||||
|
|
||||||
|
// Ensure I can get team but not a project
|
||||||
|
$team = $this->client->call(Client::METHOD_GET, '/teams/' . $teamId, array_merge([
|
||||||
|
'content-type' => 'application/json',
|
||||||
|
'x-appwrite-project' => $this->getProject()['$id'],
|
||||||
|
], $this->getHeaders()));
|
||||||
|
|
||||||
|
$this->assertEquals(200, $team['headers']['status-code']);
|
||||||
|
|
||||||
|
$project = $this->client->call(Client::METHOD_GET, '/projects/' . $projectId, array_merge([
|
||||||
|
'content-type' => 'application/json',
|
||||||
|
'x-appwrite-project' => $this->getProject()['$id'],
|
||||||
|
], $this->getHeaders()));
|
||||||
|
|
||||||
|
$this->assertEquals(404, $project['headers']['status-code']);
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue