|
|
@@ -123,11 +123,11 @@ class AuthComponentTest extends TestCase {
|
|
|
$this->Controller->Auth->initialize($event);
|
|
|
|
|
|
$this->Controller->name = 'Error';
|
|
|
- $this->assertTrue($this->Controller->Auth->startup($event));
|
|
|
+ $this->assertNull($this->Controller->Auth->startup($event));
|
|
|
|
|
|
$this->Controller->name = 'Post';
|
|
|
$this->Controller->request['action'] = 'thisdoesnotexist';
|
|
|
- $this->assertTrue($this->Controller->Auth->startup($event));
|
|
|
+ $this->assertNull($this->Controller->Auth->startup($event));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -215,16 +215,17 @@ class AuthComponentTest extends TestCase {
|
|
|
$this->Controller->request->addParams(Router::parse('auth_test/add'));
|
|
|
$this->Controller->Auth->initialize($event);
|
|
|
$result = $this->Controller->Auth->startup($event);
|
|
|
- $this->assertTrue($result);
|
|
|
+ $this->assertNull($result);
|
|
|
|
|
|
$this->Auth->Session->delete('Auth');
|
|
|
$result = $this->Controller->Auth->startup($event);
|
|
|
- $this->assertFalse($result);
|
|
|
+ $this->assertTrue($event->isStopped());
|
|
|
+ $this->assertInstanceOf('Cake\Network\Response', $result);
|
|
|
$this->assertTrue($this->Auth->Session->check('Message.auth'));
|
|
|
|
|
|
$this->Controller->request->addParams(Router::parse('auth_test/camelCase'));
|
|
|
$result = $this->Controller->Auth->startup($event);
|
|
|
- $this->assertFalse($result);
|
|
|
+ $this->assertInstanceOf('Cake\Network\Response', $result);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -381,52 +382,52 @@ class AuthComponentTest extends TestCase {
|
|
|
$this->Controller->Auth->deny('add', 'camelCase');
|
|
|
|
|
|
$this->Controller->request['action'] = 'delete';
|
|
|
- $this->assertTrue($this->Controller->Auth->startup($event));
|
|
|
+ $this->assertNull($this->Controller->Auth->startup($event));
|
|
|
|
|
|
$this->Controller->request['action'] = 'add';
|
|
|
- $this->assertFalse($this->Controller->Auth->startup($event));
|
|
|
+ $this->assertInstanceOf('Cake\Network\Response', $this->Controller->Auth->startup($event));
|
|
|
|
|
|
$this->Controller->request['action'] = 'camelCase';
|
|
|
- $this->assertFalse($this->Controller->Auth->startup($event));
|
|
|
+ $this->assertInstanceOf('Cake\Network\Response', $this->Controller->Auth->startup($event));
|
|
|
|
|
|
$this->Controller->Auth->allow();
|
|
|
$this->Controller->Auth->deny(array('add', 'camelCase'));
|
|
|
|
|
|
$this->Controller->request['action'] = 'delete';
|
|
|
- $this->assertTrue($this->Controller->Auth->startup($event));
|
|
|
+ $this->assertNull($this->Controller->Auth->startup($event));
|
|
|
|
|
|
$this->Controller->request['action'] = 'camelCase';
|
|
|
- $this->assertFalse($this->Controller->Auth->startup($event));
|
|
|
+ $this->assertInstanceOf('Cake\Network\Response', $this->Controller->Auth->startup($event));
|
|
|
|
|
|
- $this->Controller->Auth->allow('*');
|
|
|
+ $this->Controller->Auth->allow();
|
|
|
$this->Controller->Auth->deny();
|
|
|
|
|
|
$this->Controller->request['action'] = 'camelCase';
|
|
|
- $this->assertFalse($this->Controller->Auth->startup($event));
|
|
|
+ $this->assertInstanceOf('Cake\Network\Response', $this->Controller->Auth->startup($event));
|
|
|
|
|
|
$this->Controller->request['action'] = 'add';
|
|
|
- $this->assertFalse($this->Controller->Auth->startup($event));
|
|
|
+ $this->assertInstanceOf('Cake\Network\Response', $this->Controller->Auth->startup($event));
|
|
|
|
|
|
$this->Controller->Auth->allow('camelCase');
|
|
|
$this->Controller->Auth->deny();
|
|
|
|
|
|
$this->Controller->request['action'] = 'camelCase';
|
|
|
- $this->assertFalse($this->Controller->Auth->startup($event));
|
|
|
+ $this->assertInstanceOf('Cake\Network\Response', $this->Controller->Auth->startup($event));
|
|
|
|
|
|
$this->Controller->request['action'] = 'login';
|
|
|
- $this->assertFalse($this->Controller->Auth->startup($event));
|
|
|
+ $this->assertInstanceOf('Cake\Network\Response', $this->Controller->Auth->startup($event));
|
|
|
|
|
|
$this->Controller->Auth->deny();
|
|
|
$this->Controller->Auth->allow(null);
|
|
|
|
|
|
$this->Controller->request['action'] = 'camelCase';
|
|
|
- $this->assertTrue($this->Controller->Auth->startup($event));
|
|
|
+ $this->assertNull($this->Controller->Auth->startup($event));
|
|
|
|
|
|
$this->Controller->Auth->allow();
|
|
|
$this->Controller->Auth->deny(null);
|
|
|
|
|
|
$this->Controller->request['action'] = 'camelCase';
|
|
|
- $this->assertFalse($this->Controller->Auth->startup($event));
|
|
|
+ $this->assertInstanceOf('Cake\Network\Response', $this->Controller->Auth->startup($event));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -444,12 +445,12 @@ class AuthComponentTest extends TestCase {
|
|
|
$this->Controller->request->addParams(Router::parse($url));
|
|
|
$this->Controller->request->query['url'] = Router::normalize($url);
|
|
|
|
|
|
- $this->assertFalse($this->Controller->Auth->startup($event));
|
|
|
+ $this->assertInstanceOf('Cake\Network\Response', $this->Controller->Auth->startup($event));
|
|
|
|
|
|
$url = '/auth_test/CamelCase';
|
|
|
$this->Controller->request->addParams(Router::parse($url));
|
|
|
$this->Controller->request->query['url'] = Router::normalize($url);
|
|
|
- $this->assertFalse($this->Controller->Auth->startup($event));
|
|
|
+ $this->assertInstanceOf('Cake\Network\Response', $this->Controller->Auth->startup($event));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -467,7 +468,7 @@ class AuthComponentTest extends TestCase {
|
|
|
$this->Controller->Auth->userModel = 'AuthUsers';
|
|
|
$this->Controller->Auth->allow();
|
|
|
$result = $this->Controller->Auth->startup($event);
|
|
|
- $this->assertTrue($result, 'startup() should return true, as action is allowed. %s');
|
|
|
+ $this->assertNull($result, 'startup() should return null, as action is allowed. %s');
|
|
|
|
|
|
$url = '/auth_test/camelCase';
|
|
|
$this->Controller->request->addParams(Router::parse($url));
|
|
|
@@ -477,11 +478,10 @@ class AuthComponentTest extends TestCase {
|
|
|
$this->Controller->Auth->userModel = 'AuthUsers';
|
|
|
$this->Controller->Auth->allowedActions = array('delete', 'camelCase', 'add');
|
|
|
$result = $this->Controller->Auth->startup($event);
|
|
|
- $this->assertTrue($result, 'startup() should return true, as action is allowed. %s');
|
|
|
+ $this->assertNull($result, 'startup() should return null, as action is allowed. %s');
|
|
|
|
|
|
$this->Controller->Auth->allowedActions = array('delete', 'add');
|
|
|
- $result = $this->Controller->Auth->startup($event);
|
|
|
- $this->assertFalse($result, 'startup() should return false, as action is not allowed. %s');
|
|
|
+ $this->assertInstanceOf('Cake\Network\Response', $this->Controller->Auth->startup($event));
|
|
|
|
|
|
$url = '/auth_test/delete';
|
|
|
$this->Controller->request->addParams(Router::parse($url));
|
|
|
@@ -492,7 +492,7 @@ class AuthComponentTest extends TestCase {
|
|
|
|
|
|
$this->Controller->Auth->allow(array('delete', 'add'));
|
|
|
$result = $this->Controller->Auth->startup($event);
|
|
|
- $this->assertTrue($result, 'startup() should return true, as action is allowed. %s');
|
|
|
+ $this->assertNull($result, 'startup() should return null, as action is allowed. %s');
|
|
|
}
|
|
|
|
|
|
public function testAllowedActionsSetWithAllowMethod() {
|
|
|
@@ -687,7 +687,7 @@ class AuthComponentTest extends TestCase {
|
|
|
|
|
|
$event = new Event('Controller.startup', $this->Controller);
|
|
|
$return = $this->Auth->startup($event);
|
|
|
- $this->assertTrue($return);
|
|
|
+ $this->assertNull($return);
|
|
|
$this->assertNull($this->Controller->testUrl);
|
|
|
}
|
|
|
|
|
|
@@ -860,7 +860,7 @@ class AuthComponentTest extends TestCase {
|
|
|
$this->Auth->initialize($event);
|
|
|
$this->Auth->request->addParams(Router::parse('auth_test/something_totally_wrong'));
|
|
|
$result = $this->Auth->startup($event);
|
|
|
- $this->assertTrue($result, 'Auth redirected a missing action %s');
|
|
|
+ $this->assertNull($result, 'Auth redirected a missing action %s');
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -904,19 +904,20 @@ class AuthComponentTest extends TestCase {
|
|
|
'environment' => ['HTTP_X_REQUESTED_WITH' => 'XMLHttpRequest']
|
|
|
]);
|
|
|
$this->Controller->request->params['action'] = 'add';
|
|
|
- $this->Controller->response->expects($this->once())->method('stop');
|
|
|
|
|
|
$event = new Event('Controller.startup', $this->Controller);
|
|
|
$this->Auth->config('ajaxLogin', 'test_element');
|
|
|
$this->Auth->RequestHandler->ajaxLayout = 'ajax2';
|
|
|
$this->Auth->initialize($event);
|
|
|
|
|
|
- ob_start();
|
|
|
- $this->Auth->startup($event);
|
|
|
- $result = ob_get_clean();
|
|
|
+ $response = $this->Auth->startup($event);
|
|
|
|
|
|
- $this->assertEquals(403, $this->Controller->response->statusCode());
|
|
|
- $this->assertEquals("Ajax!\nthis is the test element", str_replace("\r\n", "\n", $result));
|
|
|
+ $this->assertTrue($event->isStopped());
|
|
|
+ $this->assertEquals(403, $response->statusCode());
|
|
|
+ $this->assertEquals(
|
|
|
+ "Ajax!\nthis is the test element",
|
|
|
+ str_replace("\r\n", "\n", $response->body())
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -1313,7 +1314,7 @@ class AuthComponentTest extends TestCase {
|
|
|
$this->Controller->request->env('PHP_AUTH_PW', 'cake');
|
|
|
|
|
|
$result = $this->Auth->startup($event);
|
|
|
- $this->assertTrue($result);
|
|
|
+ $this->assertNull($result);
|
|
|
|
|
|
$this->assertNull(Session::id());
|
|
|
}
|
|
|
@@ -1331,8 +1332,7 @@ class AuthComponentTest extends TestCase {
|
|
|
$this->Auth->response->expects($this->never())->method('statusCode');
|
|
|
$this->Auth->response->expects($this->never())->method('send');
|
|
|
|
|
|
- $result = $this->Auth->startup($event);
|
|
|
- $this->assertFalse($result);
|
|
|
+ $this->assertInstanceOf('Cake\Network\Response', $this->Auth->startup($event));
|
|
|
|
|
|
$this->assertEquals('/users/login', $this->Controller->testUrl);
|
|
|
}
|