mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-09-07 10:11:17 +02:00
API CHANGE: augmentSQL is now passed a DataQuery object from which query parameters can be extracted. API CHANGE: DataObjectDecorators that manipulate the query can now define augmentDataQueryCreation(). API CHANGE: The container class argument for DataObject::get() is deprecated. API CHANGE: DataObject::buildSQL() and DataObject::extendedSQL() are deprecated; just use DataObject::get() now. API CHANGE: DataObject::instance_get() and DataObject::instance_get_one() are deprecated, and can no longer be overloaded. API CHANGE: DataObject::buildDataObjectSet() is deprecated. API CHANGE: Cant't call manual manipulation methods on DataList such as insertFirst()
49 lines
1.4 KiB
PHP
49 lines
1.4 KiB
PHP
<?php
|
|
class SecurityDefaultAdminTest extends SapphireTest {
|
|
|
|
function setUp() {
|
|
parent::setUp();
|
|
|
|
// TODO Workaround to force database clearing with no fixture present,
|
|
// and avoid sideeffects from other tests
|
|
if(!self::using_temp_db()) self::create_temp_db();
|
|
self::empty_temp_db();
|
|
}
|
|
|
|
function testCheckDefaultAdmin() {
|
|
// TODO There's currently no way to inspect default admin state,
|
|
// hence we don't override existing settings
|
|
if(Security::has_default_admin()) return;
|
|
|
|
Security::setDefaultAdmin('admin', 'password');
|
|
|
|
$this->assertTrue(Security::has_default_admin());
|
|
$this->assertTrue(
|
|
Security::check_default_admin('admin', 'password'),
|
|
'Succeeds with correct username and password'
|
|
);
|
|
$this->assertFalse(
|
|
Security::check_default_admin('wronguser', 'password'),
|
|
'Fails with incorrect username'
|
|
);
|
|
$this->assertFalse(
|
|
Security::check_default_admin('admin', 'wrongpassword'),
|
|
'Fails with incorrect password'
|
|
);
|
|
|
|
Security::setDefaultAdmin(null, null);
|
|
}
|
|
|
|
function testFindAnAdministratorCreatesNewUser() {
|
|
$adminMembers = Permission::get_members_by_permission('ADMIN');
|
|
$this->assertEquals(0, $adminMembers->count());
|
|
|
|
$admin = Security::findAnAdministrator();
|
|
|
|
$this->assertType('Member', $admin);
|
|
$this->assertTrue(Permission::checkMember($admin, 'ADMIN'));
|
|
$this->assertNull($admin->Email);
|
|
$this->assertNull($admin->Password);
|
|
}
|
|
|
|
} |