2009-11-06 03:23:13 +01:00
|
|
|
<?php
|
|
|
|
/**
|
2012-04-12 08:02:46 +02:00
|
|
|
* @package framework
|
2009-11-06 03:23:13 +01:00
|
|
|
* @subpackage tests
|
|
|
|
*/
|
|
|
|
class EncryptAllPasswordsTaskTest extends SapphireTest {
|
2012-09-19 12:07:39 +02:00
|
|
|
public function testRun() {
|
2009-11-06 03:23:13 +01:00
|
|
|
$m = new Member();
|
|
|
|
$m->Password = 'plain';
|
|
|
|
$m->PasswordEncryption = 'none';
|
|
|
|
$m->write();
|
2014-08-15 08:53:05 +02:00
|
|
|
|
2009-11-06 03:23:13 +01:00
|
|
|
$t = new EncryptAllPasswordsTask();
|
2010-04-12 05:27:27 +02:00
|
|
|
$t->run(null);
|
2014-08-15 08:53:05 +02:00
|
|
|
|
2009-11-06 03:23:13 +01:00
|
|
|
$m = DataObject::get_by_id('Member', $m->ID);
|
2012-05-02 03:51:29 +02:00
|
|
|
$this->assertEquals($m->PasswordEncryption, 'blowfish');
|
2009-11-06 03:23:13 +01:00
|
|
|
$this->assertNotEquals($m->Password, 'plain');
|
2010-02-23 05:05:34 +01:00
|
|
|
$result = $m->checkPassword('plain');
|
|
|
|
$this->assertTrue($result->valid());
|
2009-11-06 03:23:13 +01:00
|
|
|
}
|
2010-04-12 05:27:27 +02:00
|
|
|
}
|