Removing skipped tests that cover features in other classes and tests.

This commit is contained in:
mark_story 2011-01-04 22:44:38 -05:00
parent 3f9c83c43d
commit e96b20b93e

View file

@ -676,31 +676,6 @@ class AuthTest extends CakeTestCase {
$this->assertFalse($result); $this->assertFalse($result);
} }
/**
* testAuthorizeController method
*
* @access public
* @return void
*/
function testAuthorizeController() {
$this->markTestSkipped('This is already tested in ControllerAuthorizeTest');
$this->AuthUser = new AuthUser();
$user = $this->AuthUser->find();
$this->Controller->Session->write('Auth', $user);
$this->Controller->Auth->userModel = 'AuthUser';
$this->Controller->Auth->authorize = 'controller';
$this->Controller->request->addParams(Router::parse('auth_test/add'));
$result = $this->Controller->Auth->startup($this->Controller);
$this->assertTrue($result);
$this->Controller->request['testControllerAuth'] = 1;
$result = $this->Controller->Auth->startup($this->Controller);
$this->assertTrue($this->Controller->Session->check('Message.auth'));
$this->assertFalse($result);
$this->Controller->Session->delete('Auth');
}
/** /**
* testAuthorizeModel method * testAuthorizeModel method
@ -730,99 +705,6 @@ class AuthTest extends CakeTestCase {
$this->assertFalse($result); $this->assertFalse($result);
} }
/**
* testAuthorizeCrud method
*
* @access public
* @return void
*/
function testAuthorizeCrud() {
$this->markTestSkipped('This is already tested in CrudAuthorizeTest');
$this->AuthUser = new AuthUser();
$user = $this->AuthUser->find();
$this->Controller->Session->write('Auth', $user);
$this->Controller->request['controller'] = 'auth_test';
$this->Controller->request['action'] = 'add';
$this->Controller->Acl->name = 'DbAclTest';
$this->Controller->Acl->Aro->id = null;
$this->Controller->Acl->Aro->create(array('alias' => 'Roles'));
$result = $this->Controller->Acl->Aro->save();
$this->assertFalse(empty($result));
$parent = $this->Controller->Acl->Aro->id;
$this->Controller->Acl->Aro->create(array('parent_id' => $parent, 'alias' => 'Admin'));
$result = $this->Controller->Acl->Aro->save();
$this->assertFalse(empty($result));
$parent = $this->Controller->Acl->Aro->id;
$this->Controller->Acl->Aro->create(array(
'model' => 'AuthUser', 'parent_id' => $parent, 'foreign_key' => 1, 'alias'=> 'mariano'
));
$result = $this->Controller->Acl->Aro->save();
$this->assertFalse(empty($result));
$this->Controller->Acl->Aco->create(array('alias' => 'Root'));
$result = $this->Controller->Acl->Aco->save();
$this->assertFalse(empty($result));
$parent = $this->Controller->Acl->Aco->id;
$this->Controller->Acl->Aco->create(array('parent_id' => $parent, 'alias' => 'AuthTest'));
$result = $this->Controller->Acl->Aco->save();
$this->assertFalse(empty($result));
$this->Controller->Acl->allow('Roles/Admin', 'Root');
$this->Controller->Acl->allow('Roles/Admin', 'Root/AuthTest');
$this->Controller->Auth->initialize($this->Controller);
$this->Controller->Auth->userModel = 'AuthUser';
$this->Controller->Auth->authorize = 'crud';
$this->Controller->Auth->actionPath = 'Root/';
$this->Controller->Auth->startup($this->Controller);
$this->assertTrue($this->Controller->Auth->isAuthorized());
$this->Controller->Session->delete('Auth');
$this->Controller->Auth->startup($this->Controller);
$this->assertTrue($this->Controller->Session->check('Message.auth'));
}
/**
* test authorize = 'actions' setting.
*
* @return void
*/
function testAuthorizeActions() {
$this->markTestSkipped('This is already tested in ActionsAuthorizeTest');
$this->AuthUser = new AuthUser();
$user = $this->AuthUser->find();
$this->Controller->Session->write('Auth', $user);
$this->Controller->request['controller'] = 'auth_test';
$this->Controller->request['action'] = 'add';
$this->Controller->Acl = $this->getMock('AclComponent', array(), array(), '', false);
$this->Controller->Acl->expects($this->atLeastOnce())->method('check')->will($this->returnValue(true));
$this->Controller->Auth->initialize($this->Controller);
$this->Controller->Auth->userModel = 'AuthUser';
$this->Controller->Auth->authorize = 'actions';
$this->Controller->Auth->actionPath = 'Root/';
$this->Controller->Acl->expects($this->at(0))->method('check')->with($user, 'Root/AuthTest/add');
$this->Controller->Auth->startup($this->Controller);
$this->assertTrue($this->Controller->Auth->isAuthorized());
}
/** /**
* @expectedException CakeException * @expectedException CakeException
* @return void * @return void
@ -1237,110 +1119,6 @@ class AuthTest extends CakeTestCase {
$this->assertTrue($result, 'Auth redirected a missing action %s'); $this->assertTrue($result, 'Auth redirected a missing action %s');
} }
/**
* testEmptyUsernameOrPassword method
*
* @access public
* @return void
*/
function testEmptyUsernameOrPassword() {
$this->markTestSkipped('This is already tested in FormAuthenticateTest');
$this->AuthUser = new AuthUser();
$user['id'] = 1;
$user['username'] = 'mariano';
$user['password'] = Security::hash(Configure::read('Security.salt') . 'cake');
$this->AuthUser->save($user, false);
$authUser = $this->AuthUser->find();
$this->Controller->request->data['AuthUser'] = array(
'username' => '', 'password' => ''
);
$this->Controller->request->addParams(Router::parse('auth_test/login'));
$this->Controller->request->query['url'] = 'auth_test/login';
$this->Controller->Auth->initialize($this->Controller);
$this->Controller->Auth->loginAction = 'auth_test/login';
$this->Controller->Auth->userModel = 'AuthUser';
$this->Controller->Auth->startup($this->Controller);
$user = $this->Controller->Auth->user();
$this->assertTrue($this->Controller->Session->check('Message.auth'));
$this->assertEqual($user, false);
$this->Controller->Session->delete('Auth');
}
/**
* testInjection method
*
* @access public
* @return void
*/
function testInjection() {
$this->markTestSkipped('This is already tested in FormAuthenticateTest');
$this->AuthUser = new AuthUser();
$this->AuthUser->id = 2;
$this->AuthUser->saveField('password', Security::hash(Configure::read('Security.salt') . 'cake'));
$this->Controller->request->data['AuthUser'] = array(
'username' => 'nate', 'password' => 'cake'
);
$this->Controller->request->addParams(Router::parse('auth_test/login'));
$this->Controller->request->query['url'] = 'auth_test/login';
$this->Controller->Auth->initialize($this->Controller);
$this->Controller->Auth->loginAction = 'auth_test/login';
$this->Controller->Auth->userModel = 'AuthUser';
$this->Controller->Auth->startup($this->Controller);
$this->assertTrue(is_array($this->Controller->Auth->user()));
$this->Controller->Session->delete($this->Controller->Auth->sessionKey);
$this->Controller->request->data = array(
'AuthUser' => array(
'username' => 'nate',
'password' => 'cake1'
)
);
$this->Controller->request->query['url'] = 'auth_test/login';
$this->Controller->Auth->initialize($this->Controller);
$this->Controller->Auth->loginAction = 'auth_test/login';
$this->Controller->Auth->userModel = 'AuthUser';
$this->Controller->Auth->startup($this->Controller);
$this->assertTrue(is_null($this->Controller->Auth->user()));
$this->Controller->Session->delete($this->Controller->Auth->sessionKey);
$this->Controller->request->data = array(
'AuthUser' => array(
'username' => '> n',
'password' => 'cake'
)
);
$this->Controller->Auth->initialize($this->Controller);
$this->Controller->Auth->startup($this->Controller);
$this->assertTrue(is_null($this->Controller->Auth->user()));
unset($this->Controller->request->data['AuthUser']['password']);
$this->Controller->request->data['AuthUser']['username'] = "1'1";
$this->Controller->Auth->initialize($this->Controller);
$this->Controller->Auth->startup($this->Controller);
$this->assertTrue(is_null($this->Controller->Auth->user()));
unset($this->Controller->request->data['AuthUser']['username']);
$this->Controller->request->data['AuthUser']['password'] = "1'1";
$this->Controller->Auth->initialize($this->Controller);
$this->Controller->Auth->startup($this->Controller);
$this->assertTrue(is_null($this->Controller->Auth->user()));
}
/** /**
* test Hashing of passwords * test Hashing of passwords
* *
@ -1431,41 +1209,6 @@ class AuthTest extends CakeTestCase {
$this->assertTrue(!!$user); $this->assertTrue(!!$user);
} }
/**
* testCustomField method
*
* @access public
* @return void
*/
function testCustomField() {
$this->markTestSkipped('This is already tested in FormAuthenticateTest');
Router::reload();
$this->AuthUserCustomField = new AuthUserCustomField();
$user = array(
'id' => 1, 'email' => 'harking@example.com',
'password' => Security::hash(Configure::read('Security.salt') . 'cake'
));
$user = $this->AuthUserCustomField->save($user, false);
Router::connect('/', array('controller' => 'people', 'action' => 'login'));
$url = '/';
$this->Controller->request->addParams(Router::parse($url));
Router::setRequestInfo($this->Controller->request);
$this->Controller->request->data['AuthUserCustomField'] = array(
'email' => 'harking@example.com', 'password' => 'cake'
);
$this->Controller->request->query['url'] = substr($url, 1);
$this->Controller->Auth->initialize($this->Controller);
$this->Controller->Auth->fields = array('username' => 'email', 'password' => 'password');
$this->Controller->Auth->loginAction = array('controller' => 'people', 'action' => 'login');
$this->Controller->Auth->userModel = 'AuthUserCustomField';
$this->Controller->Auth->startup($this->Controller);
$user = $this->Controller->Auth->user();
$this->assertTrue(!!$user);
}
/** /**
* testAdminRoute method * testAdminRoute method
* *