summaryrefslogtreecommitdiff
path: root/tests/functionals
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2015-12-12 17:46:11 -0500
committerFrederic Guillot <fred@kanboard.net>2015-12-12 17:46:11 -0500
commit486238b5485d61cdc4e66244632f91357d014059 (patch)
tree75857aad9dc7532102e0c11eae78e4fe7745ebe6 /tests/functionals
parent7b997692273055ada47b5b97f0cc5eb22fb0c0ca (diff)
API: check project membership for task operations
Diffstat (limited to 'tests/functionals')
-rw-r--r--tests/functionals/ApiTest.php38
-rw-r--r--tests/functionals/UserApiTest.php11
2 files changed, 40 insertions, 9 deletions
diff --git a/tests/functionals/ApiTest.php b/tests/functionals/ApiTest.php
index 9be22023..fbb703c9 100644
--- a/tests/functionals/ApiTest.php
+++ b/tests/functionals/ApiTest.php
@@ -366,6 +366,33 @@ class Api extends PHPUnit_Framework_TestCase
$this->assertEquals('Swimlane A', $swimlanes[2]['name']);
}
+ public function testCreateTaskWithWrongMember()
+ {
+ $task = array(
+ 'title' => 'Task #1',
+ 'color_id' => 'blue',
+ 'owner_id' => 1,
+ 'project_id' => 1,
+ 'column_id' => 2,
+ );
+
+ $task_id = $this->client->createTask($task);
+
+ $this->assertFalse($task_id);
+ }
+
+ public function testGetAllowedUsers()
+ {
+ $users = $this->client->getMembers(1);
+ $this->assertNotFalse($users);
+ $this->assertEquals(array(), $users);
+ }
+
+ public function testAddMember()
+ {
+ $this->assertTrue($this->client->allowUser(1, 1));
+ }
+
public function testCreateTask()
{
$task = array(
@@ -573,20 +600,13 @@ class Api extends PHPUnit_Framework_TestCase
$this->assertEquals('titi@localhost', $user['email']);
}
- public function testGetAllowedUsers()
- {
- $users = $this->client->getMembers(1);
- $this->assertNotFalse($users);
- $this->assertEquals(array(), $users);
- }
-
public function testAllowedUser()
{
$this->assertTrue($this->client->allowUser(1, 2));
$users = $this->client->getMembers(1);
$this->assertNotFalse($users);
- $this->assertEquals(array(2 => 'Titi'), $users);
+ $this->assertEquals(array(1 => 'admin', 2 => 'Titi'), $users);
}
public function testRevokeUser()
@@ -595,7 +615,7 @@ class Api extends PHPUnit_Framework_TestCase
$users = $this->client->getMembers(1);
$this->assertNotFalse($users);
- $this->assertEquals(array(), $users);
+ $this->assertEquals(array(1 => 'admin'), $users);
}
public function testCreateComment()
diff --git a/tests/functionals/UserApiTest.php b/tests/functionals/UserApiTest.php
index 8a80c706..3c7fc04e 100644
--- a/tests/functionals/UserApiTest.php
+++ b/tests/functionals/UserApiTest.php
@@ -163,6 +163,12 @@ class UserApi extends PHPUnit_Framework_TestCase
$this->assertEquals(2, $this->admin->createTask('my admin title', 1));
}
+ public function testCreateTaskWithWrongMember()
+ {
+ $this->assertFalse($this->user->createTask(array('title' => 'something', 'project_id' => 2, 'owner_id' => 1)));
+ $this->assertFalse($this->app->createTask(array('title' => 'something', 'project_id' => 1, 'owner_id' => 2)));
+ }
+
public function testGetTask()
{
$task = $this->user->getTask(1);
@@ -218,6 +224,11 @@ class UserApi extends PHPUnit_Framework_TestCase
$this->assertTrue($this->user->moveTaskPosition(2, 1, 2, 1));
}
+ public function testUpdateTaskWithWrongMember()
+ {
+ $this->assertFalse($this->user->updateTask(array('id' => 1, 'title' => 'new title', 'reference' => 'test', 'owner_id' => 1)));
+ }
+
public function testUpdateTask()
{
$this->assertTrue($this->user->updateTask(array('id' => 1, 'title' => 'new title', 'reference' => 'test', 'owner_id' => 2)));