Skip to content

Commit

Permalink
add unauthorized admin access test
Browse files Browse the repository at this point in the history
  • Loading branch information
andrej-griniuk committed Sep 8, 2017
1 parent 2decca9 commit dd13066
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/TestCase/Controller/Admin/CategoriesControllerTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
namespace CakeDC\Forum\Test\TestCase\Controller\Admin;

use Cake\Network\Exception\UnauthorizedException;
use Cake\ORM\TableRegistry;
use Cake\TestSuite\IntegrationTestCase;

Expand Down Expand Up @@ -66,6 +67,29 @@ public function testIndex()
$this->assertEquals('Consumer Electronics', $categories[2]->title);
}

/**
* Test index unauthorized method
*
* @return void
*/
public function testIndexUnauthorized()
{
$this->session([
'Auth' => [
'User' => [
'id' => 2,
'username' => 'testing',
'is_superuser' => false,
]
]
]);

$this->get('/forum/admin');

// Access denied for user who is not superuser
$this->assertResponseError();
}

/**
* Test view method
*
Expand Down

0 comments on commit dd13066

Please sign in to comment.