Rewrite of the authentication and authorization system

This commit is contained in:
Frederic Guillot
2015-12-05 20:31:27 -05:00
parent 346b8312e5
commit e9fedf3e5c
255 changed files with 14114 additions and 9820 deletions

View File

@@ -8,10 +8,11 @@ use Kanboard\Model\TaskDuplication;
use Kanboard\Model\TaskFinder;
use Kanboard\Model\TaskStatus;
use Kanboard\Model\Project;
use Kanboard\Model\ProjectPermission;
use Kanboard\Model\ProjectUserRole;
use Kanboard\Model\Category;
use Kanboard\Model\User;
use Kanboard\Model\Swimlane;
use Kanboard\Core\Security\Role;
class TaskDuplicationTest extends Base
{
@@ -127,7 +128,7 @@ class TaskDuplicationTest extends Base
// Check the values of the duplicated task
$task = $tf->getById(2);
$this->assertNotEmpty($task);
$this->assertEquals(1, $task['owner_id']);
$this->assertEquals(0, $task['owner_id']);
$this->assertEquals(0, $task['category_id']);
$this->assertEquals(0, $task['swimlane_id']);
$this->assertEquals(6, $task['column_id']);
@@ -333,7 +334,7 @@ class TaskDuplicationTest extends Base
$tc = new TaskCreation($this->container);
$tf = new TaskFinder($this->container);
$p = new Project($this->container);
$pp = new ProjectPermission($this->container);
$pp = new ProjectUserRole($this->container);
// We create 2 projects
$this->assertEquals(1, $p->create(array('name' => 'test1')));
@@ -357,10 +358,8 @@ class TaskDuplicationTest extends Base
// We create a new user for our project
$user = new User($this->container);
$this->assertNotFalse($user->create(array('username' => 'unittest#1', 'password' => 'unittest')));
$this->assertTrue($pp->addMember(1, 2));
$this->assertTrue($pp->addMember(2, 2));
$this->assertTrue($pp->isUserAllowed(1, 2));
$this->assertTrue($pp->isUserAllowed(2, 2));
$this->assertTrue($pp->addUser(1, 2, Role::PROJECT_MEMBER));
$this->assertTrue($pp->addUser(2, 2, Role::PROJECT_MEMBER));
// We duplicate our task to the 2nd project
$this->assertEquals(3, $td->duplicateToProject(1, 2));
@@ -391,7 +390,7 @@ class TaskDuplicationTest extends Base
$tc = new TaskCreation($this->container);
$tf = new TaskFinder($this->container);
$p = new Project($this->container);
$pp = new ProjectPermission($this->container);
$pr = new ProjectUserRole($this->container);
// We create 2 projects
$this->assertEquals(1, $p->create(array('name' => 'test1')));
@@ -399,6 +398,7 @@ class TaskDuplicationTest extends Base
// We create a task
$this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 2, 'owner_id' => 2)));
$this->assertTrue($pr->addUser(2, 1, Role::PROJECT_MEMBER));
// We duplicate our task to the 2nd project
$this->assertEquals(2, $td->duplicateToProject(1, 2, null, null, null, 1));
@@ -425,7 +425,6 @@ class TaskDuplicationTest extends Base
$tc = new TaskCreation($this->container);
$tf = new TaskFinder($this->container);
$p = new Project($this->container);
$pp = new ProjectPermission($this->container);
$user = new User($this->container);
// We create 2 projects
@@ -446,7 +445,7 @@ class TaskDuplicationTest extends Base
// Check the values of the moved task
$task = $tf->getById(1);
$this->assertNotEmpty($task);
$this->assertEquals(1, $task['owner_id']);
$this->assertEquals(0, $task['owner_id']);
$this->assertEquals(0, $task['category_id']);
$this->assertEquals(0, $task['swimlane_id']);
$this->assertEquals(2, $task['project_id']);
@@ -496,7 +495,7 @@ class TaskDuplicationTest extends Base
$tc = new TaskCreation($this->container);
$tf = new TaskFinder($this->container);
$p = new Project($this->container);
$pp = new ProjectPermission($this->container);
$pp = new ProjectUserRole($this->container);
$user = new User($this->container);
// We create 2 projects
@@ -505,10 +504,8 @@ class TaskDuplicationTest extends Base
// We create a new user for our project
$this->assertNotFalse($user->create(array('username' => 'unittest#1', 'password' => 'unittest')));
$this->assertTrue($pp->addMember(1, 2));
$this->assertTrue($pp->addMember(2, 2));
$this->assertTrue($pp->isUserAllowed(1, 2));
$this->assertTrue($pp->isUserAllowed(2, 2));
$this->assertTrue($pp->addUser(1, 2, Role::PROJECT_MEMBER));
$this->assertTrue($pp->addUser(2, 2, Role::PROJECT_MEMBER));
// We create a task
$this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 2, 'owner_id' => 2)));
@@ -531,7 +528,7 @@ class TaskDuplicationTest extends Base
$tc = new TaskCreation($this->container);
$tf = new TaskFinder($this->container);
$p = new Project($this->container);
$pp = new ProjectPermission($this->container);
$pp = new ProjectUserRole($this->container);
$user = new User($this->container);
// We create 2 projects
@@ -540,10 +537,8 @@ class TaskDuplicationTest extends Base
// We create a new user for our project
$this->assertNotFalse($user->create(array('username' => 'unittest#1', 'password' => 'unittest')));
$this->assertTrue($pp->addMember(1, 2));
$this->assertTrue($pp->addMember(2, 2));
$this->assertTrue($pp->isUserAllowed(1, 2));
$this->assertTrue($pp->isUserAllowed(2, 2));
$this->assertTrue($pp->addUser(1, 2, Role::PROJECT_MEMBER));
$this->assertTrue($pp->addUser(2, 2, Role::PROJECT_MEMBER));
// We create a task
$this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 2, 'owner_id' => 3)));