Skip to content
Snippets Groups Projects
Commit d5e48a48 authored by Bernhard Posselt's avatar Bernhard Posselt
Browse files

fix assertions

parent 5e9ea2b3
Branches
No related tags found
No related merge requests found
...@@ -119,11 +119,17 @@ class SecurityMiddlewareTest extends \PHPUnit_Framework_TestCase { ...@@ -119,11 +119,17 @@ class SecurityMiddlewareTest extends \PHPUnit_Framework_TestCase {
} catch (SecurityException $ex){ } catch (SecurityException $ex){
$this->assertEquals($status, $ex->getCode()); $this->assertEquals($status, $ex->getCode());
} }
// add assertion if everything should work fine otherwise phpunit will
// complain
if ($status === 0) {
$this->assertTrue(true);
}
} }
public function testAjaxStatusLoggedInCheck() { public function testAjaxStatusLoggedInCheck() {
$this->ajaxExceptionStatus( $this->ajaxExceptionStatus(
'testAjaxStatusLoggedInCheck', __FUNCTION__,
'isLoggedIn', 'isLoggedIn',
Http::STATUS_UNAUTHORIZED Http::STATUS_UNAUTHORIZED
); );
...@@ -131,11 +137,10 @@ class SecurityMiddlewareTest extends \PHPUnit_Framework_TestCase { ...@@ -131,11 +137,10 @@ class SecurityMiddlewareTest extends \PHPUnit_Framework_TestCase {
/** /**
* @NoCSRFRequired * @NoCSRFRequired
* @NoAdminRequired
*/ */
public function testAjaxNotAdminCheck() { public function testAjaxNotAdminCheck() {
$this->ajaxExceptionStatus( $this->ajaxExceptionStatus(
'testAjaxNotAdminCheck', __FUNCTION__,
'isAdminUser', 'isAdminUser',
Http::STATUS_FORBIDDEN Http::STATUS_FORBIDDEN
); );
...@@ -146,7 +151,7 @@ class SecurityMiddlewareTest extends \PHPUnit_Framework_TestCase { ...@@ -146,7 +151,7 @@ class SecurityMiddlewareTest extends \PHPUnit_Framework_TestCase {
*/ */
public function testAjaxStatusCSRFCheck() { public function testAjaxStatusCSRFCheck() {
$this->ajaxExceptionStatus( $this->ajaxExceptionStatus(
'testAjaxStatusCSRFCheck', __FUNCTION__,
'passesCSRFCheck', 'passesCSRFCheck',
Http::STATUS_PRECONDITION_FAILED Http::STATUS_PRECONDITION_FAILED
); );
...@@ -158,22 +163,22 @@ class SecurityMiddlewareTest extends \PHPUnit_Framework_TestCase { ...@@ -158,22 +163,22 @@ class SecurityMiddlewareTest extends \PHPUnit_Framework_TestCase {
*/ */
public function testAjaxStatusAllGood() { public function testAjaxStatusAllGood() {
$this->ajaxExceptionStatus( $this->ajaxExceptionStatus(
'testAjaxStatusAllGood', __FUNCTION__,
'isLoggedIn', 'isLoggedIn',
0 0
); );
$this->ajaxExceptionStatus( $this->ajaxExceptionStatus(
'testAjaxStatusAllGood', __FUNCTION__,
'isAdminUser', 'isAdminUser',
0 0
); );
$this->ajaxExceptionStatus( $this->ajaxExceptionStatus(
'testAjaxStatusAllGood', __FUNCTION__,
'isSubAdminUser', 'isSubAdminUser',
0 0
); );
$this->ajaxExceptionStatus( $this->ajaxExceptionStatus(
'testAjaxStatusAllGood', __FUNCTION__,
'passesCSRFCheck', 'passesCSRFCheck',
0 0
); );
...@@ -215,7 +220,7 @@ class SecurityMiddlewareTest extends \PHPUnit_Framework_TestCase { ...@@ -215,7 +220,7 @@ class SecurityMiddlewareTest extends \PHPUnit_Framework_TestCase {
if($shouldFail){ if($shouldFail){
$this->setExpectedException('\OC\AppFramework\Middleware\Security\SecurityException'); $this->setExpectedException('\OC\AppFramework\Middleware\Security\SecurityException');
} else { } else {
$this->setExpectedException(null); $this->assertTrue(true);
} }
$this->reader->reflect(__CLASS__, $method); $this->reader->reflect(__CLASS__, $method);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment