mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
Merge pull request #1536 from open-sausages/pulls/4.0/namespace-security
API Apply SilverStripe\Security namespace
This commit is contained in:
commit
d2485a60fd
@ -3,6 +3,7 @@
|
|||||||
use SilverStripe\ORM\SS_List;
|
use SilverStripe\ORM\SS_List;
|
||||||
use SilverStripe\ORM\ArrayList;
|
use SilverStripe\ORM\ArrayList;
|
||||||
use SilverStripe\ORM\Versioning\Versioned;
|
use SilverStripe\ORM\Versioning\Versioned;
|
||||||
|
use SilverStripe\Security\Permission;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Publish items batch action.
|
* Publish items batch action.
|
||||||
|
@ -5,6 +5,9 @@ use SilverStripe\ORM\ArrayList;
|
|||||||
use SilverStripe\ORM\Versioning\Versioned;
|
use SilverStripe\ORM\Versioning\Versioned;
|
||||||
use SilverStripe\ORM\DataObject;
|
use SilverStripe\ORM\DataObject;
|
||||||
use SilverStripe\ORM\SS_List;
|
use SilverStripe\ORM\SS_List;
|
||||||
|
use SilverStripe\Security\Security;
|
||||||
|
use SilverStripe\Security\PermissionProvider;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AssetAdmin is the 'file store' section of the CMS.
|
* AssetAdmin is the 'file store' section of the CMS.
|
||||||
|
@ -7,6 +7,12 @@ use SilverStripe\ORM\ArrayList;
|
|||||||
use SilverStripe\ORM\DataObject;
|
use SilverStripe\ORM\DataObject;
|
||||||
use SilverStripe\ORM\DataList;
|
use SilverStripe\ORM\DataList;
|
||||||
use SilverStripe\ORM\DB;
|
use SilverStripe\ORM\DB;
|
||||||
|
use SilverStripe\Security\Member;
|
||||||
|
use SilverStripe\Security\Security;
|
||||||
|
use SilverStripe\Security\SecurityToken;
|
||||||
|
use SilverStripe\Security\Permission;
|
||||||
|
use SilverStripe\Security\PermissionProvider;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -35,7 +41,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
|
|
||||||
private static $tree_class = "SiteTree";
|
private static $tree_class = "SiteTree";
|
||||||
|
|
||||||
private static $subitem_class = "Member";
|
private static $subitem_class = "SilverStripe\\Security\\Member";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Amount of results showing on a single page.
|
* Amount of results showing on a single page.
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
use SilverStripe\ORM\DataObject;
|
use SilverStripe\ORM\DataObject;
|
||||||
use SilverStripe\ORM\ValidationException;
|
use SilverStripe\ORM\ValidationException;
|
||||||
|
use SilverStripe\Security\Member;
|
||||||
|
use SilverStripe\Security\Security;
|
||||||
|
|
||||||
class CMSPageAddController extends CMSPageEditController {
|
class CMSPageAddController extends CMSPageEditController {
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
use SilverStripe\ORM\DataObject;
|
use SilverStripe\ORM\DataObject;
|
||||||
use SilverStripe\ORM\Versioning\Versioned;
|
use SilverStripe\ORM\Versioning\Versioned;
|
||||||
|
use SilverStripe\Security\Security;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @package cms
|
* @package cms
|
||||||
|
@ -8,6 +8,11 @@ use SilverStripe\ORM\SS_List;
|
|||||||
use SilverStripe\ORM\Versioning\Versioned;
|
use SilverStripe\ORM\Versioning\Versioned;
|
||||||
use SilverStripe\ORM\FieldType\DBVarchar;
|
use SilverStripe\ORM\FieldType\DBVarchar;
|
||||||
use SilverStripe\ORM\FieldType\DBHTMLText;
|
use SilverStripe\ORM\FieldType\DBHTMLText;
|
||||||
|
use SilverStripe\Security\Security;
|
||||||
|
use SilverStripe\Security\MemberAuthenticator;
|
||||||
|
use SilverStripe\Security\Member;
|
||||||
|
use SilverStripe\Security\Permission;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -119,6 +124,7 @@ class ContentController extends Controller {
|
|||||||
if($this->redirectedTo()) return;
|
if($this->redirectedTo()) return;
|
||||||
|
|
||||||
// Check page permissions
|
// Check page permissions
|
||||||
|
/** @skipUpgrade */
|
||||||
if($this->dataRecord && $this->URLSegment != 'Security' && !$this->dataRecord->canView()) {
|
if($this->dataRecord && $this->URLSegment != 'Security' && !$this->dataRecord->canView()) {
|
||||||
return Security::permissionFailure($this);
|
return Security::permissionFailure($this);
|
||||||
}
|
}
|
||||||
@ -294,7 +300,7 @@ class ContentController extends Controller {
|
|||||||
$logInMessage = sprintf(
|
$logInMessage = sprintf(
|
||||||
'%s - <a href="%s">%s</a>' ,
|
'%s - <a href="%s">%s</a>' ,
|
||||||
_t('ContentController.NOTLOGGEDIN', 'Not logged in') ,
|
_t('ContentController.NOTLOGGEDIN', 'Not logged in') ,
|
||||||
Config::inst()->get('Security', 'login_url'),
|
Security::config()->login_url,
|
||||||
_t('ContentController.LOGIN', 'Login') ."</a>"
|
_t('ContentController.LOGIN', 'Login') ."</a>"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,11 @@ use SilverStripe\ORM\ArrayList;
|
|||||||
use SilverStripe\ORM\DB;
|
use SilverStripe\ORM\DB;
|
||||||
use SilverStripe\ORM\DataList;
|
use SilverStripe\ORM\DataList;
|
||||||
use SilverStripe\ORM\HiddenClass;
|
use SilverStripe\ORM\HiddenClass;
|
||||||
|
use SilverStripe\Security\Member;
|
||||||
|
use SilverStripe\Security\Permission;
|
||||||
|
use SilverStripe\Security\Group;
|
||||||
|
use SilverStripe\Security\PermissionProvider;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Basic data-object representing all pages within the site tree. All page types that live within the hierarchy should
|
* Basic data-object representing all pages within the site tree. All page types that live within the hierarchy should
|
||||||
@ -138,8 +143,8 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
);
|
);
|
||||||
|
|
||||||
private static $many_many = array(
|
private static $many_many = array(
|
||||||
"ViewerGroups" => "Group",
|
"ViewerGroups" => "SilverStripe\\Security\\Group",
|
||||||
"EditorGroups" => "Group",
|
"EditorGroups" => "SilverStripe\\Security\\Group",
|
||||||
);
|
);
|
||||||
|
|
||||||
private static $has_many = array(
|
private static $has_many = array(
|
||||||
@ -783,7 +788,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
* @return bool True if the the member is allowed to do the given action
|
* @return bool True if the the member is allowed to do the given action
|
||||||
*/
|
*/
|
||||||
public function can($perm, $member = null, $context = array()) {
|
public function can($perm, $member = null, $context = array()) {
|
||||||
if(!$member || !(is_a($member, 'Member')) || is_numeric($member)) {
|
if(!$member || !($member instanceof Member) || is_numeric($member)) {
|
||||||
$member = Member::currentUserID();
|
$member = Member::currentUserID();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -822,7 +827,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$member || !(is_a($member, 'Member')) || is_numeric($member)) {
|
if(!$member || !($member instanceof Member) || is_numeric($member)) {
|
||||||
$member = Member::currentUserID();
|
$member = Member::currentUserID();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -857,7 +862,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
* @return bool True if the current user can view this page
|
* @return bool True if the current user can view this page
|
||||||
*/
|
*/
|
||||||
public function canView($member = null) {
|
public function canView($member = null) {
|
||||||
if(!$member || !(is_a($member, 'Member')) || is_numeric($member)) {
|
if(!$member || !($member instanceof Member) || is_numeric($member)) {
|
||||||
$member = Member::currentUserID();
|
$member = Member::currentUserID();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -895,7 +900,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
|
|
||||||
// check for specific groups
|
// check for specific groups
|
||||||
if($member && is_numeric($member)) {
|
if($member && is_numeric($member)) {
|
||||||
$member = DataObject::get_by_id('Member', $member);
|
$member = DataObject::get_by_id('SilverStripe\\Security\\Member', $member);
|
||||||
}
|
}
|
||||||
if(
|
if(
|
||||||
$this->CanViewType == 'OnlyTheseUsers'
|
$this->CanViewType == 'OnlyTheseUsers'
|
||||||
@ -965,7 +970,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
* @return bool True if the current user can create pages on this class.
|
* @return bool True if the current user can create pages on this class.
|
||||||
*/
|
*/
|
||||||
public function canCreate($member = null, $context = array()) {
|
public function canCreate($member = null, $context = array()) {
|
||||||
if(!$member || !(is_a($member, 'Member')) || is_numeric($member)) {
|
if(!$member || !(is_a($member, 'SilverStripe\\Security\\Member')) || is_numeric($member)) {
|
||||||
$member = Member::currentUserID();
|
$member = Member::currentUserID();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1140,7 +1145,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
//$ids = array_keys(array_filter(self::can_view_multiple($ids, $memberID)));
|
//$ids = array_keys(array_filter(self::can_view_multiple($ids, $memberID)));
|
||||||
|
|
||||||
// Get the groups that the given member belongs to
|
// Get the groups that the given member belongs to
|
||||||
$groupIDs = DataObject::get_by_id('Member', $memberID)->Groups()->column("ID");
|
$groupIDs = DataObject::get_by_id('SilverStripe\\Security\\Member', $memberID)->Groups()->column("ID");
|
||||||
$SQL_groupList = implode(", ", $groupIDs);
|
$SQL_groupList = implode(", ", $groupIDs);
|
||||||
if (!$SQL_groupList) $SQL_groupList = '0';
|
if (!$SQL_groupList) $SQL_groupList = '0';
|
||||||
|
|
||||||
|
@ -3,6 +3,9 @@
|
|||||||
use SilverStripe\ORM\Versioning\Versioned;
|
use SilverStripe\ORM\Versioning\Versioned;
|
||||||
use SilverStripe\ORM\DataObject;
|
use SilverStripe\ORM\DataObject;
|
||||||
use SilverStripe\ORM\ArrayList;
|
use SilverStripe\ORM\ArrayList;
|
||||||
|
use SilverStripe\Security\Permission;
|
||||||
|
use SilverStripe\Security\Security;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -90,7 +93,7 @@ in the other stage:<br />
|
|||||||
$orphans = $this->getOrphanedPages($this->orphanedSearchClass);
|
$orphans = $this->getOrphanedPages($this->orphanedSearchClass);
|
||||||
if($orphans) foreach($orphans as $orphan) {
|
if($orphans) foreach($orphans as $orphan) {
|
||||||
$latestVersion = Versioned::get_latest_version($this->orphanedSearchClass, $orphan->ID);
|
$latestVersion = Versioned::get_latest_version($this->orphanedSearchClass, $orphan->ID);
|
||||||
$latestAuthor = DataObject::get_by_id('Member', $latestVersion->AuthorID);
|
$latestAuthor = DataObject::get_by_id('SilverStripe\\Security\\Member', $latestVersion->AuthorID);
|
||||||
$orphanBaseTable = DataObject::getSchema()->baseDataTable($this->orphanedSearchClass);
|
$orphanBaseTable = DataObject::getSchema()->baseDataTable($this->orphanedSearchClass);
|
||||||
$liveRecord = Versioned::get_one_by_stage(
|
$liveRecord = Versioned::get_one_by_stage(
|
||||||
$this->orphanedSearchClass,
|
$this->orphanedSearchClass,
|
||||||
|
@ -36,8 +36,8 @@ class UpgradeSiteTreePermissionSchemaTask extends BuildTask {
|
|||||||
$pageIDs = DB::query("SELECT ID FROM SiteTree")->column('ID');
|
$pageIDs = DB::query("SELECT ID FROM SiteTree")->column('ID');
|
||||||
foreach($pageIDs as $pageID) {
|
foreach($pageIDs as $pageID) {
|
||||||
$page = DataObject::get_by_id('SiteTree', $pageID);
|
$page = DataObject::get_by_id('SiteTree', $pageID);
|
||||||
if($page->ViewersGroup && DataObject::get_by_id("Group", $page->ViewersGroup)) $page->ViewerGroups()->add($page->ViewersGroup);
|
if($page->ViewersGroup && DataObject::get_by_id("SilverStripe\\Security\\Group", $page->ViewersGroup)) $page->ViewerGroups()->add($page->ViewersGroup);
|
||||||
if($page->EditorsGroup && DataObject::get_by_id("Group", $page->EditorsGroup)) $page->EditorGroups()->add($page->EditorsGroup);
|
if($page->EditorsGroup && DataObject::get_by_id("SilverStripe\\Security\\Group", $page->EditorsGroup)) $page->EditorGroups()->add($page->EditorsGroup);
|
||||||
|
|
||||||
$page->destroy();
|
$page->destroy();
|
||||||
unset($page);
|
unset($page);
|
||||||
|
@ -30,7 +30,7 @@ class CMSMainTest extends FunctionalTest {
|
|||||||
function testSiteTreeHints() {
|
function testSiteTreeHints() {
|
||||||
$cache = SS_Cache::factory('CMSMain_SiteTreeHints');
|
$cache = SS_Cache::factory('CMSMain_SiteTreeHints');
|
||||||
// Login as user with root creation privileges
|
// Login as user with root creation privileges
|
||||||
$user = $this->objFromFixture('Member', 'rootedituser');
|
$user = $this->objFromFixture('SilverStripe\\Security\\Member', 'rootedituser');
|
||||||
$user->logIn();
|
$user->logIn();
|
||||||
$cache->clean(Zend_Cache::CLEANING_MODE_ALL);
|
$cache->clean(Zend_Cache::CLEANING_MODE_ALL);
|
||||||
|
|
||||||
@ -105,7 +105,7 @@ class CMSMainTest extends FunctionalTest {
|
|||||||
public function testPublish() {
|
public function testPublish() {
|
||||||
$page1 = $this->objFromFixture('Page', "page1");
|
$page1 = $this->objFromFixture('Page', "page1");
|
||||||
$page2 = $this->objFromFixture('Page', "page2");
|
$page2 = $this->objFromFixture('Page', "page2");
|
||||||
$this->session()->inst_set('loggedInAs', $this->idFromFixture('Member', 'admin'));
|
$this->session()->inst_set('loggedInAs', $this->idFromFixture('SilverStripe\\Security\\Member', 'admin'));
|
||||||
|
|
||||||
$response = $this->get('admin/pages/publishall?confirm=1');
|
$response = $this->get('admin/pages/publishall?confirm=1');
|
||||||
$this->assertContains(
|
$this->assertContains(
|
||||||
@ -215,7 +215,7 @@ class CMSMainTest extends FunctionalTest {
|
|||||||
* Test that a draft-deleted page can still be opened in the CMS
|
* Test that a draft-deleted page can still be opened in the CMS
|
||||||
*/
|
*/
|
||||||
public function testDraftDeletedPageCanBeOpenedInCMS() {
|
public function testDraftDeletedPageCanBeOpenedInCMS() {
|
||||||
$this->session()->inst_set('loggedInAs', $this->idFromFixture('Member', 'admin'));
|
$this->session()->inst_set('loggedInAs', $this->idFromFixture('SilverStripe\\Security\\Member', 'admin'));
|
||||||
|
|
||||||
// Set up a page that is delete from live
|
// Set up a page that is delete from live
|
||||||
$page = $this->objFromFixture('Page', 'page1');
|
$page = $this->objFromFixture('Page', 'page1');
|
||||||
@ -273,8 +273,8 @@ class CMSMainTest extends FunctionalTest {
|
|||||||
$origFollow = $this->autoFollowRedirection;
|
$origFollow = $this->autoFollowRedirection;
|
||||||
$this->autoFollowRedirection = false;
|
$this->autoFollowRedirection = false;
|
||||||
|
|
||||||
$cmsUser = $this->objFromFixture('Member', 'allcmssectionsuser');
|
$cmsUser = $this->objFromFixture('SilverStripe\\Security\\Member', 'allcmssectionsuser');
|
||||||
$rootEditUser = $this->objFromFixture('Member', 'rootedituser');
|
$rootEditUser = $this->objFromFixture('SilverStripe\\Security\\Member', 'rootedituser');
|
||||||
|
|
||||||
// with insufficient permissions
|
// with insufficient permissions
|
||||||
$cmsUser->logIn();
|
$cmsUser->logIn();
|
||||||
@ -324,7 +324,7 @@ class CMSMainTest extends FunctionalTest {
|
|||||||
$origFollow = $this->autoFollowRedirection;
|
$origFollow = $this->autoFollowRedirection;
|
||||||
$this->autoFollowRedirection = false;
|
$this->autoFollowRedirection = false;
|
||||||
|
|
||||||
$adminUser = $this->objFromFixture('Member', 'admin');
|
$adminUser = $this->objFromFixture('SilverStripe\\Security\\Member', 'admin');
|
||||||
$adminUser->logIn();
|
$adminUser->logIn();
|
||||||
|
|
||||||
// Create toplevel page
|
// Create toplevel page
|
||||||
@ -395,7 +395,7 @@ class CMSMainTest extends FunctionalTest {
|
|||||||
public function testBreadcrumbs() {
|
public function testBreadcrumbs() {
|
||||||
$page3 = $this->objFromFixture('Page', 'page3');
|
$page3 = $this->objFromFixture('Page', 'page3');
|
||||||
$page31 = $this->objFromFixture('Page', 'page31');
|
$page31 = $this->objFromFixture('Page', 'page31');
|
||||||
$adminuser = $this->objFromFixture('Member', 'admin');
|
$adminuser = $this->objFromFixture('SilverStripe\\Security\\Member', 'admin');
|
||||||
$this->session()->inst_set('loggedInAs', $adminuser->ID);
|
$this->session()->inst_set('loggedInAs', $adminuser->ID);
|
||||||
|
|
||||||
$response = $this->get('admin/pages/edit/show/' . $page31->ID);
|
$response = $this->get('admin/pages/edit/show/' . $page31->ID);
|
||||||
|
@ -89,7 +89,7 @@ Page:
|
|||||||
Title: Home
|
Title: Home
|
||||||
URLSegment: home
|
URLSegment: home
|
||||||
Sort: 27
|
Sort: 27
|
||||||
Group:
|
SilverStripe\Security\Group:
|
||||||
admin:
|
admin:
|
||||||
Title: Administrators
|
Title: Administrators
|
||||||
empty:
|
empty:
|
||||||
@ -100,41 +100,41 @@ Group:
|
|||||||
Title: allcmssections
|
Title: allcmssections
|
||||||
rooteditusers:
|
rooteditusers:
|
||||||
Title: rooteditusers
|
Title: rooteditusers
|
||||||
Member:
|
SilverStripe\Security\Member:
|
||||||
admin:
|
admin:
|
||||||
Email: admin@example.com
|
Email: admin@example.com
|
||||||
Password: ZXXlkwecxz2390232233
|
Password: ZXXlkwecxz2390232233
|
||||||
Groups: =>Group.admin
|
Groups: =>SilverStripe\Security\Group.admin
|
||||||
assetsonlyuser:
|
assetsonlyuser:
|
||||||
Email: assetsonlyuser@test.com
|
Email: assetsonlyuser@test.com
|
||||||
Groups: =>Group.assetsonly
|
Groups: =>SilverStripe\Security\Group.assetsonly
|
||||||
allcmssectionsuser:
|
allcmssectionsuser:
|
||||||
Email: allcmssectionsuser@test.com
|
Email: allcmssectionsuser@test.com
|
||||||
Groups: =>Group.allcmssections
|
Groups: =>SilverStripe\Security\Group.allcmssections
|
||||||
rootedituser:
|
rootedituser:
|
||||||
Email: rootedituser@test.com
|
Email: rootedituser@test.com
|
||||||
Groups: =>Group.rooteditusers
|
Groups: =>SilverStripe\Security\Group.rooteditusers
|
||||||
Permission:
|
SilverStripe\Security\Permission:
|
||||||
admin:
|
admin:
|
||||||
Code: ADMIN
|
Code: ADMIN
|
||||||
GroupID: =>Group.admin
|
GroupID: =>SilverStripe\Security\Group.admin
|
||||||
assetsonly:
|
assetsonly:
|
||||||
Code: CMS_ACCESS_AssetAdmin
|
Code: CMS_ACCESS_AssetAdmin
|
||||||
GroupID: =>Group.assetsonly
|
GroupID: =>SilverStripe\Security\Group.assetsonly
|
||||||
allcmssections:
|
allcmssections:
|
||||||
Code: CMS_ACCESS_LeftAndMain
|
Code: CMS_ACCESS_LeftAndMain
|
||||||
GroupID: =>Group.allcmssections
|
GroupID: =>SilverStripe\Security\Group.allcmssections
|
||||||
allcmssections2:
|
allcmssections2:
|
||||||
Code: CMS_ACCESS_LeftAndMain
|
Code: CMS_ACCESS_LeftAndMain
|
||||||
GroupID: =>Group.rooteditusers
|
GroupID: =>SilverStripe\Security\Group.rooteditusers
|
||||||
SiteConfig:
|
SiteConfig:
|
||||||
siteconfig1:
|
siteconfig1:
|
||||||
EditorGroups: =>Group.rooteditusers
|
EditorGroups: =>SilverStripe\Security\Group.rooteditusers
|
||||||
CanCreateTopLevelType: 'OnlyTheseUsers'
|
CanCreateTopLevelType: 'OnlyTheseUsers'
|
||||||
SiteConfig_CreateTopLevelGroups:
|
SiteConfig_CreateTopLevelGroups:
|
||||||
createtoplevelgroups1:
|
createtoplevelgroups1:
|
||||||
SiteConfigID: =>SiteConfig.siteconfig1
|
SiteConfigID: =>SiteConfig.siteconfig1
|
||||||
GroupID: =>Group.rooteditusers
|
GroupID: =>SilverStripe\Security\Group.rooteditusers
|
||||||
RedirectorPage:
|
RedirectorPage:
|
||||||
page5:
|
page5:
|
||||||
Title: Page 5
|
Title: Page 5
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
Page:
|
Page:
|
||||||
page1:
|
page1:
|
||||||
Title: Page 1
|
Title: Page 1
|
||||||
Sort: 1
|
Sort: 1
|
||||||
page2:
|
page2:
|
||||||
Title: Page 2
|
Title: Page 2
|
||||||
Sort: 2
|
Sort: 2
|
||||||
page3:
|
page3:
|
||||||
Title: Page 3
|
Title: Page 3
|
||||||
Sort: 3
|
Sort: 3
|
||||||
|
@ -1,31 +1,31 @@
|
|||||||
Page:
|
Page:
|
||||||
page1:
|
page1:
|
||||||
Title: Page 1
|
Title: Page 1
|
||||||
page2:
|
page2:
|
||||||
Title: Page 2
|
Title: Page 2
|
||||||
page3:
|
page3:
|
||||||
Title: Page 3
|
Title: Page 3
|
||||||
page4:
|
page4:
|
||||||
Title: Page 4
|
Title: Page 4
|
||||||
page5:
|
page5:
|
||||||
Title: Page 5
|
Title: Page 5
|
||||||
Content: 'Default text'
|
Content: 'Default text'
|
||||||
page6:
|
page6:
|
||||||
Title: Page 6
|
Title: Page 6
|
||||||
page7:
|
page7:
|
||||||
Title: Page 7
|
Title: Page 7
|
||||||
page7a:
|
page7a:
|
||||||
Parent: =>Page.page7
|
Parent: =>Page.page7
|
||||||
Title: Page 7a
|
Title: Page 7a
|
||||||
page2a:
|
page2a:
|
||||||
Parent: =>Page.page2
|
Parent: =>Page.page2
|
||||||
Title: Page 2a
|
Title: Page 2a
|
||||||
page2b:
|
page2b:
|
||||||
Parent: =>Page.page2
|
Parent: =>Page.page2
|
||||||
Title: Page 2b
|
Title: Page 2b
|
||||||
page3a:
|
page3a:
|
||||||
Parent: =>Page.page3
|
Parent: =>Page.page3
|
||||||
Title: Page 3a
|
Title: Page 3a
|
||||||
page3b:
|
page3b:
|
||||||
Parent: =>Page.page3
|
Parent: =>Page.page3
|
||||||
Title: Page 3b
|
Title: Page 3b
|
||||||
|
@ -37,7 +37,7 @@ class ContentControllerPermissionsTest extends FunctionalTest {
|
|||||||
// should redirect to login
|
// should redirect to login
|
||||||
$this->assertEquals($response->getStatusCode(), 302, 'Redirects to login page when not logged in for draft stage');
|
$this->assertEquals($response->getStatusCode(), 302, 'Redirects to login page when not logged in for draft stage');
|
||||||
$this->assertContains(
|
$this->assertContains(
|
||||||
Config::inst()->get('Security', 'login_url'),
|
Config::inst()->get('SilverStripe\\Security\\Security', 'login_url'),
|
||||||
$response->getHeader('Location')
|
$response->getHeader('Location')
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -1,26 +1,25 @@
|
|||||||
Group:
|
SilverStripe\Security\Group:
|
||||||
editors:
|
editors:
|
||||||
Title: Editors
|
Title: Editors
|
||||||
admins:
|
admins:
|
||||||
Title: Administrators
|
Title: Administrators
|
||||||
|
|
||||||
Permission:
|
SilverStripe\Security\Permission:
|
||||||
admins:
|
admins:
|
||||||
Code: VIEW_DRAFT_CONTENT
|
Code: VIEW_DRAFT_CONTENT
|
||||||
Group: =>Group.admins
|
Group: =>SilverStripe\Security\Group.admins
|
||||||
editors:
|
editors:
|
||||||
Group: =>Group.editors
|
Group: =>SilverStripe\Security\Group.editors
|
||||||
|
|
||||||
Member:
|
|
||||||
editor:
|
|
||||||
FirstName: Test
|
|
||||||
Surname: Editor
|
|
||||||
Groups: =>Group.editors
|
|
||||||
admin:
|
|
||||||
FirstName: Test
|
|
||||||
Surname: Administrator
|
|
||||||
Groups: =>Group.admins
|
|
||||||
|
|
||||||
|
SilverStripe\Security\Member:
|
||||||
|
editor:
|
||||||
|
FirstName: Test
|
||||||
|
Surname: Editor
|
||||||
|
Groups: =>SilverStripe\Security\Group.editors
|
||||||
|
admin:
|
||||||
|
FirstName: Test
|
||||||
|
Surname: Administrator
|
||||||
|
Groups: =>SilverStripe\Security\Group.admins
|
||||||
|
|
||||||
ContentControllerTest_Page:
|
ContentControllerTest_Page:
|
||||||
root_page:
|
root_page:
|
||||||
@ -42,5 +41,4 @@ ContentControllerTest_Page:
|
|||||||
Title: Contact Page
|
Title: Contact Page
|
||||||
URLSegment: contact
|
URLSegment: contact
|
||||||
CanViewType: OnlyTheseUsers
|
CanViewType: OnlyTheseUsers
|
||||||
EditorGroups: =>Group.admins
|
EditorGroups: =>SilverStripe\Security\Group.admins
|
||||||
|
|
||||||
|
@ -10,8 +10,6 @@ class ModelAsControllerTest extends FunctionalTest {
|
|||||||
|
|
||||||
protected $usesDatabase = true;
|
protected $usesDatabase = true;
|
||||||
|
|
||||||
protected static $fixture_file = 'ModelAsControllerTest.yml';
|
|
||||||
|
|
||||||
protected $autoFollowRedirection = false;
|
protected $autoFollowRedirection = false;
|
||||||
|
|
||||||
protected $orig = array();
|
protected $orig = array();
|
||||||
|
@ -1,18 +1,18 @@
|
|||||||
Page:
|
Page:
|
||||||
home:
|
home:
|
||||||
Title: Home
|
Title: Home
|
||||||
nested:
|
nested:
|
||||||
Title: Nested Home
|
Title: Nested Home
|
||||||
Parent: =>Page.home
|
Parent: =>Page.home
|
||||||
page1:
|
page1:
|
||||||
Title: First Page
|
Title: First Page
|
||||||
URLSegment: page1
|
URLSegment: page1
|
||||||
HomepageForDomain: page.co.nz, help.com,something.com, www.something.com
|
HomepageForDomain: page.co.nz, help.com,something.com, www.something.com
|
||||||
page2:
|
page2:
|
||||||
Title: Second Page
|
Title: Second Page
|
||||||
URLSegment: page2
|
URLSegment: page2
|
||||||
HomepageForDomain: other.co.nz, right
|
HomepageForDomain: other.co.nz, right
|
||||||
page3:
|
page3:
|
||||||
Title: Third Page
|
Title: Third Page
|
||||||
URLSegment: page3
|
URLSegment: page3
|
||||||
HomepageForDomain: only.com
|
HomepageForDomain: only.com
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\Security\Member;
|
||||||
|
use SilverStripe\Security\Permission;
|
||||||
/**
|
/**
|
||||||
* @package cms
|
* @package cms
|
||||||
* @subpackage tests
|
* @subpackage tests
|
||||||
@ -25,8 +28,8 @@ class SilverStripeNavigatorTest extends SapphireTest {
|
|||||||
|
|
||||||
public function testCanView() {
|
public function testCanView() {
|
||||||
$page = $this->objFromFixture('Page', 'page1');
|
$page = $this->objFromFixture('Page', 'page1');
|
||||||
$admin = $this->objFromFixture('Member', 'admin');
|
$admin = $this->objFromFixture('SilverStripe\\Security\\Member', 'admin');
|
||||||
$author = $this->objFromFixture('Member', 'assetsonlyuser');
|
$author = $this->objFromFixture('SilverStripe\\Security\\Member', 'assetsonlyuser');
|
||||||
$navigator = new SilverStripeNavigator($page);
|
$navigator = new SilverStripeNavigator($page);
|
||||||
|
|
||||||
// TODO Shouldn't be necessary but SapphireTest logs in as ADMIN by default
|
// TODO Shouldn't be necessary but SapphireTest logs in as ADMIN by default
|
||||||
|
@ -1,39 +1,39 @@
|
|||||||
Page:
|
Page:
|
||||||
dest:
|
dest:
|
||||||
Title: Redirection Dest
|
Title: Redirection Dest
|
||||||
URLSegment: redirection-dest
|
URLSegment: redirection-dest
|
||||||
|
|
||||||
RedirectorPage:
|
RedirectorPage:
|
||||||
goodexternal:
|
goodexternal:
|
||||||
Title: Good External
|
Title: Good External
|
||||||
URLSegment: good-external
|
URLSegment: good-external
|
||||||
RedirectionType: External
|
RedirectionType: External
|
||||||
ExternalURL: http://www.google.com
|
ExternalURL: http://www.google.com
|
||||||
goodinternal:
|
goodinternal:
|
||||||
Title: Good Internal
|
Title: Good Internal
|
||||||
URLSegment: good-internal
|
URLSegment: good-internal
|
||||||
RedirectionType: Internal
|
RedirectionType: Internal
|
||||||
LinkTo: =>Page.dest
|
LinkTo: =>Page.dest
|
||||||
badexternal:
|
badexternal:
|
||||||
Title: Bad External
|
Title: Bad External
|
||||||
RedirectionType: External
|
RedirectionType: External
|
||||||
URLSegment: bad-external
|
URLSegment: bad-external
|
||||||
externalnoprefix:
|
externalnoprefix:
|
||||||
Title: External no prefix
|
Title: External no prefix
|
||||||
RedirectionType: External
|
RedirectionType: External
|
||||||
URLSegment: external-no-prefix
|
URLSegment: external-no-prefix
|
||||||
ExternalURL: google.com
|
ExternalURL: google.com
|
||||||
badinternal:
|
badinternal:
|
||||||
Title: Bad Internal
|
Title: Bad Internal
|
||||||
RedirectionType: Internal
|
RedirectionType: Internal
|
||||||
URLSegment: bad-internal
|
URLSegment: bad-internal
|
||||||
reflexive:
|
reflexive:
|
||||||
Title: Reflexive
|
Title: Reflexive
|
||||||
RedirectionType: Internal
|
RedirectionType: Internal
|
||||||
LinkTo: =>RedirectorPage.reflexive
|
LinkTo: =>RedirectorPage.reflexive
|
||||||
URLSegment: reflexive
|
URLSegment: reflexive
|
||||||
transitive:
|
transitive:
|
||||||
Title: Transitive
|
Title: Transitive
|
||||||
RedirectionType: Internal
|
RedirectionType: Internal
|
||||||
LinkTo: =>RedirectorPage.goodinternal
|
LinkTo: =>RedirectorPage.goodinternal
|
||||||
URLSegment: transitive
|
URLSegment: transitive
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
use SilverStripe\ORM\Versioning\Versioned;
|
use SilverStripe\ORM\Versioning\Versioned;
|
||||||
use SilverStripe\ORM\DB;
|
use SilverStripe\ORM\DB;
|
||||||
|
use SilverStripe\Security\Permission;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Possible actions:
|
* Possible actions:
|
||||||
@ -23,7 +24,7 @@ class SiteTreeActionsTest extends FunctionalTest {
|
|||||||
public function testActionsReadonly() {
|
public function testActionsReadonly() {
|
||||||
if(class_exists('SiteTreeCMSWorkflow')) return true;
|
if(class_exists('SiteTreeCMSWorkflow')) return true;
|
||||||
|
|
||||||
$readonlyEditor = $this->objFromFixture('Member', 'cmsreadonlyeditor');
|
$readonlyEditor = $this->objFromFixture('SilverStripe\\Security\\Member', 'cmsreadonlyeditor');
|
||||||
$this->session()->inst_set('loggedInAs', $readonlyEditor->ID);
|
$this->session()->inst_set('loggedInAs', $readonlyEditor->ID);
|
||||||
|
|
||||||
$page = new SiteTreeActionsTest_Page();
|
$page = new SiteTreeActionsTest_Page();
|
||||||
@ -59,14 +60,14 @@ class SiteTreeActionsTest extends FunctionalTest {
|
|||||||
$this->assertInstanceOf("SiteTree", $page);
|
$this->assertInstanceOf("SiteTree", $page);
|
||||||
|
|
||||||
// Check that someone without the right permission can't delete the page
|
// Check that someone without the right permission can't delete the page
|
||||||
$editor = $this->objFromFixture('Member', 'cmsnodeleteeditor');
|
$editor = $this->objFromFixture('SilverStripe\\Security\\Member', 'cmsnodeleteeditor');
|
||||||
$this->session()->inst_set('loggedInAs', $editor->ID);
|
$this->session()->inst_set('loggedInAs', $editor->ID);
|
||||||
|
|
||||||
$actions = $page->getCMSActions();
|
$actions = $page->getCMSActions();
|
||||||
$this->assertNull($actions->dataFieldByName('action_deletefromlive'));
|
$this->assertNull($actions->dataFieldByName('action_deletefromlive'));
|
||||||
|
|
||||||
// Check that someone with the right permission can delete the page
|
// Check that someone with the right permission can delete the page
|
||||||
$this->objFromFixture('Member', 'cmseditor')->logIn();
|
$this->objFromFixture('SilverStripe\\Security\\Member', 'cmseditor')->logIn();
|
||||||
$actions = $page->getCMSActions();
|
$actions = $page->getCMSActions();
|
||||||
$this->assertNotNull($actions->dataFieldByName('action_deletefromlive'));
|
$this->assertNotNull($actions->dataFieldByName('action_deletefromlive'));
|
||||||
}
|
}
|
||||||
@ -74,7 +75,7 @@ class SiteTreeActionsTest extends FunctionalTest {
|
|||||||
public function testActionsPublishedRecord() {
|
public function testActionsPublishedRecord() {
|
||||||
if(class_exists('SiteTreeCMSWorkflow')) return true;
|
if(class_exists('SiteTreeCMSWorkflow')) return true;
|
||||||
|
|
||||||
$author = $this->objFromFixture('Member', 'cmseditor');
|
$author = $this->objFromFixture('SilverStripe\\Security\\Member', 'cmseditor');
|
||||||
$this->session()->inst_set('loggedInAs', $author->ID);
|
$this->session()->inst_set('loggedInAs', $author->ID);
|
||||||
|
|
||||||
$page = new Page();
|
$page = new Page();
|
||||||
@ -96,7 +97,7 @@ class SiteTreeActionsTest extends FunctionalTest {
|
|||||||
public function testActionsDeletedFromStageRecord() {
|
public function testActionsDeletedFromStageRecord() {
|
||||||
if(class_exists('SiteTreeCMSWorkflow')) return true;
|
if(class_exists('SiteTreeCMSWorkflow')) return true;
|
||||||
|
|
||||||
$author = $this->objFromFixture('Member', 'cmseditor');
|
$author = $this->objFromFixture('SilverStripe\\Security\\Member', 'cmseditor');
|
||||||
$this->session()->inst_set('loggedInAs', $author->ID);
|
$this->session()->inst_set('loggedInAs', $author->ID);
|
||||||
|
|
||||||
$page = new Page();
|
$page = new Page();
|
||||||
@ -124,7 +125,7 @@ class SiteTreeActionsTest extends FunctionalTest {
|
|||||||
public function testActionsChangedOnStageRecord() {
|
public function testActionsChangedOnStageRecord() {
|
||||||
if(class_exists('SiteTreeCMSWorkflow')) return true;
|
if(class_exists('SiteTreeCMSWorkflow')) return true;
|
||||||
|
|
||||||
$author = $this->objFromFixture('Member', 'cmseditor');
|
$author = $this->objFromFixture('SilverStripe\\Security\\Member', 'cmseditor');
|
||||||
$this->session()->inst_set('loggedInAs', $author->ID);
|
$this->session()->inst_set('loggedInAs', $author->ID);
|
||||||
|
|
||||||
$page = new Page();
|
$page = new Page();
|
||||||
|
@ -1,33 +1,33 @@
|
|||||||
Permission:
|
SilverStripe\Security\Permission:
|
||||||
cmsmain1:
|
cmsmain1:
|
||||||
Code: CMS_ACCESS_CMSMain
|
Code: CMS_ACCESS_CMSMain
|
||||||
cmsmain2:
|
cmsmain2:
|
||||||
Code: CMS_ACCESS_CMSMain
|
Code: CMS_ACCESS_CMSMain
|
||||||
cmsmain3:
|
cmsmain3:
|
||||||
Code: CMS_ACCESS_CMSMain
|
Code: CMS_ACCESS_CMSMain
|
||||||
candelete:
|
candelete:
|
||||||
Code: SiteTreeActionsTest_Page_CANDELETE
|
Code: SiteTreeActionsTest_Page_CANDELETE
|
||||||
canedit1:
|
canedit1:
|
||||||
Code: SiteTreeActionsTest_Page_CANEDIT
|
Code: SiteTreeActionsTest_Page_CANEDIT
|
||||||
canedit2:
|
canedit2:
|
||||||
Code: SiteTreeActionsTest_Page_CANEDIT
|
Code: SiteTreeActionsTest_Page_CANEDIT
|
||||||
Group:
|
SilverStripe\Security\Group:
|
||||||
cmseditors:
|
cmseditors:
|
||||||
Title: CMS Editors
|
Title: CMS Editors
|
||||||
Permissions: =>Permission.cmsmain1,=>Permission.canedit1,=>Permission.candelete
|
Permissions: =>SilverStripe\Security\Permission.cmsmain1,=>SilverStripe\Security\Permission.canedit1,=>SilverStripe\Security\Permission.candelete
|
||||||
cmsreadonly:
|
cmsreadonly:
|
||||||
Title: CMS Readonly
|
Title: CMS Readonly
|
||||||
Permissions: =>Permission.cmsmain2
|
Permissions: =>SilverStripe\Security\Permission.cmsmain2
|
||||||
cmsnodelete:
|
cmsnodelete:
|
||||||
Title: CMS No Delete
|
Title: CMS No Delete
|
||||||
Permissions: =>Permission.cmsmain3,=>Permission.canedit2
|
Permissions: =>SilverStripe\Security\Permission.cmsmain3,=>SilverStripe\Security\Permission.canedit2
|
||||||
Member:
|
SilverStripe\Security\Member:
|
||||||
cmseditor:
|
cmseditor:
|
||||||
Email: cmseditor@test.com
|
Email: cmseditor@test.com
|
||||||
Groups: =>Group.cmseditors
|
Groups: =>SilverStripe\Security\Group.cmseditors
|
||||||
cmsreadonlyeditor:
|
cmsreadonlyeditor:
|
||||||
Email: cmsreadonlyeditor@test.com
|
Email: cmsreadonlyeditor@test.com
|
||||||
Groups: =>Group.cmsreadonly
|
Groups: =>SilverStripe\Security\Group.cmsreadonly
|
||||||
cmsnodeleteeditor:
|
cmsnodeleteeditor:
|
||||||
Email: cmsnodeleteeditor@test.com
|
Email: cmsnodeleteeditor@test.com
|
||||||
Groups: =>Group.cmsnodelete
|
Groups: =>SilverStripe\Security\Group.cmsnodelete
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
Page:
|
Page:
|
||||||
page1:
|
page1:
|
||||||
ID: 1
|
ID: 1
|
||||||
Title: page1
|
Title: page1
|
||||||
URLSegment: page1
|
URLSegment: page1
|
||||||
|
|
||||||
page2:
|
page2:
|
||||||
Title: page2
|
Title: page2
|
||||||
URLSegment: page2
|
URLSegment: page2
|
||||||
|
|
||||||
page3:
|
page3:
|
||||||
Title: page3
|
Title: page3
|
||||||
URLSegment: page3
|
URLSegment: page3
|
||||||
Content: '<p><a href="[sitetree_link,id=1]">Testing page 1 link</a></p>'
|
Content: '<p><a href="[sitetree_link,id=1]">Testing page 1 link</a></p>'
|
||||||
LinkTracking: =>Page.page1
|
LinkTracking: =>Page.page1
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use SilverStripe\ORM\Versioning\Versioned;
|
use SilverStripe\ORM\Versioning\Versioned;
|
||||||
|
use SilverStripe\Security\Member;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @package cms
|
* @package cms
|
||||||
@ -50,7 +51,7 @@ class SiteTreePermissionsTest extends FunctionalTest {
|
|||||||
}
|
}
|
||||||
$this->assertEquals($response->getStatusCode(), '302');
|
$this->assertEquals($response->getStatusCode(), '302');
|
||||||
$this->assertContains(
|
$this->assertContains(
|
||||||
Config::inst()->get('Security', 'login_url'),
|
Config::inst()->get('SilverStripe\\Security\\Security', 'login_url'),
|
||||||
$response->getHeader('Location')
|
$response->getHeader('Location')
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -78,7 +79,7 @@ class SiteTreePermissionsTest extends FunctionalTest {
|
|||||||
$page = Versioned::get_one_by_stage('SiteTree', 'Live', "\"SiteTree\".\"ID\" = $pageID");
|
$page = Versioned::get_one_by_stage('SiteTree', 'Live', "\"SiteTree\".\"ID\" = $pageID");
|
||||||
|
|
||||||
// subadmin has edit rights on that page
|
// subadmin has edit rights on that page
|
||||||
$member = $this->objFromFixture('Member','subadmin');
|
$member = $this->objFromFixture('SilverStripe\\Security\\Member','subadmin');
|
||||||
$member->logIn();
|
$member->logIn();
|
||||||
|
|
||||||
// Test can_edit_multiple
|
// Test can_edit_multiple
|
||||||
@ -100,7 +101,7 @@ class SiteTreePermissionsTest extends FunctionalTest {
|
|||||||
$page->doUnpublish();
|
$page->doUnpublish();
|
||||||
|
|
||||||
// subadmin has edit rights on that page
|
// subadmin has edit rights on that page
|
||||||
$member = $this->objFromFixture('Member','subadmin');
|
$member = $this->objFromFixture('SilverStripe\\Security\\Member','subadmin');
|
||||||
$member->logIn();
|
$member->logIn();
|
||||||
|
|
||||||
// Test can_edit_multiple
|
// Test can_edit_multiple
|
||||||
@ -126,7 +127,7 @@ class SiteTreePermissionsTest extends FunctionalTest {
|
|||||||
$page = Versioned::get_latest_version('SiteTree', $pageID);
|
$page = Versioned::get_latest_version('SiteTree', $pageID);
|
||||||
|
|
||||||
// subadmin had edit rights on that page, but now it's gone
|
// subadmin had edit rights on that page, but now it's gone
|
||||||
$member = $this->objFromFixture('Member','subadmin');
|
$member = $this->objFromFixture('SilverStripe\\Security\\Member','subadmin');
|
||||||
$member->logIn();
|
$member->logIn();
|
||||||
|
|
||||||
$this->assertFalse($page->canEdit());
|
$this->assertFalse($page->canEdit());
|
||||||
@ -143,8 +144,8 @@ class SiteTreePermissionsTest extends FunctionalTest {
|
|||||||
$page->Title = 1;
|
$page->Title = 1;
|
||||||
$page->write();
|
$page->write();
|
||||||
|
|
||||||
$editor = $this->objFromFixture('Member', 'editor');
|
$editor = $this->objFromFixture('SilverStripe\\Security\\Member', 'editor');
|
||||||
$websiteuser = $this->objFromFixture('Member', 'websiteuser');
|
$websiteuser = $this->objFromFixture('SilverStripe\\Security\\Member', 'websiteuser');
|
||||||
|
|
||||||
$this->assertTrue($page->canViewStage('Live', $websiteuser));
|
$this->assertTrue($page->canViewStage('Live', $websiteuser));
|
||||||
$this->assertFalse($page->canViewStage('Stage', $websiteuser));
|
$this->assertFalse($page->canViewStage('Stage', $websiteuser));
|
||||||
@ -158,7 +159,7 @@ class SiteTreePermissionsTest extends FunctionalTest {
|
|||||||
public function testAccessTabOnlyDisplaysWithGrantAccessPermissions() {
|
public function testAccessTabOnlyDisplaysWithGrantAccessPermissions() {
|
||||||
$page = $this->objFromFixture('Page', 'standardpage');
|
$page = $this->objFromFixture('Page', 'standardpage');
|
||||||
|
|
||||||
$subadminuser = $this->objFromFixture('Member', 'subadmin');
|
$subadminuser = $this->objFromFixture('SilverStripe\\Security\\Member', 'subadmin');
|
||||||
$this->session()->inst_set('loggedInAs', $subadminuser->ID);
|
$this->session()->inst_set('loggedInAs', $subadminuser->ID);
|
||||||
$fields = $page->getSettingsFields();
|
$fields = $page->getSettingsFields();
|
||||||
$this->assertFalse(
|
$this->assertFalse(
|
||||||
@ -170,7 +171,7 @@ class SiteTreePermissionsTest extends FunctionalTest {
|
|||||||
'Users with SITETREE_GRANT_ACCESS permission can change "edit" permissions in cms fields'
|
'Users with SITETREE_GRANT_ACCESS permission can change "edit" permissions in cms fields'
|
||||||
);
|
);
|
||||||
|
|
||||||
$editoruser = $this->objFromFixture('Member', 'editor');
|
$editoruser = $this->objFromFixture('SilverStripe\\Security\\Member', 'editor');
|
||||||
$this->session()->inst_set('loggedInAs', $editoruser->ID);
|
$this->session()->inst_set('loggedInAs', $editoruser->ID);
|
||||||
$fields = $page->getSettingsFields();
|
$fields = $page->getSettingsFields();
|
||||||
$this->assertTrue(
|
$this->assertTrue(
|
||||||
@ -202,7 +203,7 @@ class SiteTreePermissionsTest extends FunctionalTest {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// website users
|
// website users
|
||||||
$websiteuser = $this->objFromFixture('Member', 'websiteuser');
|
$websiteuser = $this->objFromFixture('SilverStripe\\Security\\Member', 'websiteuser');
|
||||||
$this->assertTrue(
|
$this->assertTrue(
|
||||||
$page->canView($websiteuser),
|
$page->canView($websiteuser),
|
||||||
'Authenticated members can view a page marked as "Viewable for any logged in users" even if they dont have access to the CMS'
|
'Authenticated members can view a page marked as "Viewable for any logged in users" even if they dont have access to the CMS'
|
||||||
@ -234,7 +235,7 @@ class SiteTreePermissionsTest extends FunctionalTest {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// subadmin users
|
// subadmin users
|
||||||
$subadminuser = $this->objFromFixture('Member', 'subadmin');
|
$subadminuser = $this->objFromFixture('SilverStripe\\Security\\Member', 'subadmin');
|
||||||
$this->assertFalse(
|
$this->assertFalse(
|
||||||
$page->canView($subadminuser),
|
$page->canView($subadminuser),
|
||||||
'Authenticated members cant view a page marked as "Viewable by these groups" if theyre not in the listed groups'
|
'Authenticated members cant view a page marked as "Viewable by these groups" if theyre not in the listed groups'
|
||||||
@ -249,7 +250,7 @@ class SiteTreePermissionsTest extends FunctionalTest {
|
|||||||
$this->session()->inst_set('loggedInAs', null);
|
$this->session()->inst_set('loggedInAs', null);
|
||||||
|
|
||||||
// website users
|
// website users
|
||||||
$websiteuser = $this->objFromFixture('Member', 'websiteuser');
|
$websiteuser = $this->objFromFixture('SilverStripe\\Security\\Member', 'websiteuser');
|
||||||
$this->assertTrue(
|
$this->assertTrue(
|
||||||
$page->canView($websiteuser),
|
$page->canView($websiteuser),
|
||||||
'Authenticated members can view a page marked as "Viewable by these groups" if theyre in the listed groups'
|
'Authenticated members can view a page marked as "Viewable by these groups" if theyre in the listed groups'
|
||||||
@ -274,7 +275,7 @@ class SiteTreePermissionsTest extends FunctionalTest {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// website users
|
// website users
|
||||||
$websiteuser = $this->objFromFixture('Member', 'websiteuser');
|
$websiteuser = $this->objFromFixture('SilverStripe\\Security\\Member', 'websiteuser');
|
||||||
$websiteuser->logIn();
|
$websiteuser->logIn();
|
||||||
$this->assertFalse(
|
$this->assertFalse(
|
||||||
$page->canEdit($websiteuser),
|
$page->canEdit($websiteuser),
|
||||||
@ -282,7 +283,7 @@ class SiteTreePermissionsTest extends FunctionalTest {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// subadmin users
|
// subadmin users
|
||||||
$subadminuser = $this->objFromFixture('Member', 'subadmin');
|
$subadminuser = $this->objFromFixture('SilverStripe\\Security\\Member', 'subadmin');
|
||||||
$this->assertTrue(
|
$this->assertTrue(
|
||||||
$page->canEdit($subadminuser),
|
$page->canEdit($subadminuser),
|
||||||
'Authenticated members can edit a page marked as "Editable by logged in users" if they have cms permissions and belong to any of these groups'
|
'Authenticated members can edit a page marked as "Editable by logged in users" if they have cms permissions and belong to any of these groups'
|
||||||
@ -299,14 +300,14 @@ class SiteTreePermissionsTest extends FunctionalTest {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// subadmin users
|
// subadmin users
|
||||||
$subadminuser = $this->objFromFixture('Member', 'subadmin');
|
$subadminuser = $this->objFromFixture('SilverStripe\\Security\\Member', 'subadmin');
|
||||||
$this->assertTrue(
|
$this->assertTrue(
|
||||||
$page->canEdit($subadminuser),
|
$page->canEdit($subadminuser),
|
||||||
'Authenticated members can view a page marked as "Editable by these groups" if theyre in the listed groups'
|
'Authenticated members can view a page marked as "Editable by these groups" if theyre in the listed groups'
|
||||||
);
|
);
|
||||||
|
|
||||||
// website users
|
// website users
|
||||||
$websiteuser = $this->objFromFixture('Member', 'websiteuser');
|
$websiteuser = $this->objFromFixture('SilverStripe\\Security\\Member', 'websiteuser');
|
||||||
$this->assertFalse(
|
$this->assertFalse(
|
||||||
$page->canEdit($websiteuser),
|
$page->canEdit($websiteuser),
|
||||||
'Authenticated members cant edit a page marked as "Editable by these groups" if theyre not in the listed groups'
|
'Authenticated members cant edit a page marked as "Editable by these groups" if theyre not in the listed groups'
|
||||||
@ -331,7 +332,7 @@ class SiteTreePermissionsTest extends FunctionalTest {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// subadmin users
|
// subadmin users
|
||||||
$subadminuser = $this->objFromFixture('Member', 'subadmin');
|
$subadminuser = $this->objFromFixture('SilverStripe\\Security\\Member', 'subadmin');
|
||||||
$this->assertTrue(
|
$this->assertTrue(
|
||||||
$childPage->canView($subadminuser),
|
$childPage->canView($subadminuser),
|
||||||
'Authenticated members can view a page marked as "Viewable by these groups" if theyre in the listed groups by inherited permission'
|
'Authenticated members can view a page marked as "Viewable by these groups" if theyre in the listed groups by inherited permission'
|
||||||
@ -357,7 +358,7 @@ class SiteTreePermissionsTest extends FunctionalTest {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// subadmin users
|
// subadmin users
|
||||||
$subadminuser = $this->objFromFixture('Member', 'subadmin');
|
$subadminuser = $this->objFromFixture('SilverStripe\\Security\\Member', 'subadmin');
|
||||||
$this->assertTrue(
|
$this->assertTrue(
|
||||||
$childPage->canEdit($subadminuser),
|
$childPage->canEdit($subadminuser),
|
||||||
'Authenticated members can edit a page marked as "Editable by these groups" if theyre in the listed groups by inherited permission'
|
'Authenticated members can edit a page marked as "Editable by these groups" if theyre in the listed groups by inherited permission'
|
||||||
@ -393,7 +394,7 @@ class SiteTreePermissionsTest extends FunctionalTest {
|
|||||||
$this->assertTrue(is_object($page), 'Versioned::get_one_by_stage() is returning an object');
|
$this->assertTrue(is_object($page), 'Versioned::get_one_by_stage() is returning an object');
|
||||||
|
|
||||||
// subadmin users
|
// subadmin users
|
||||||
$subadminuser = $this->objFromFixture('Member', 'subadmin');
|
$subadminuser = $this->objFromFixture('SilverStripe\\Security\\Member', 'subadmin');
|
||||||
$this->assertTrue(
|
$this->assertTrue(
|
||||||
$page->canEdit($subadminuser),
|
$page->canEdit($subadminuser),
|
||||||
'Authenticated members can edit a page that was deleted from stage and marked as "Editable by logged in users" if they have cms permissions and belong to any of these groups'
|
'Authenticated members can edit a page that was deleted from stage and marked as "Editable by logged in users" if they have cms permissions and belong to any of these groups'
|
||||||
@ -403,8 +404,8 @@ class SiteTreePermissionsTest extends FunctionalTest {
|
|||||||
public function testInheritCanViewFromSiteConfig() {
|
public function testInheritCanViewFromSiteConfig() {
|
||||||
$page = $this->objFromFixture('Page', 'inheritWithNoParent');
|
$page = $this->objFromFixture('Page', 'inheritWithNoParent');
|
||||||
$siteconfig = $this->objFromFixture('SiteConfig', 'default');
|
$siteconfig = $this->objFromFixture('SiteConfig', 'default');
|
||||||
$editor = $this->objFromFixture('Member', 'editor');
|
$editor = $this->objFromFixture('SilverStripe\\Security\\Member', 'editor');
|
||||||
$editorGroup = $this->objFromFixture('Group', 'editorgroup');
|
$editorGroup = $this->objFromFixture('SilverStripe\\Security\\Group', 'editorgroup');
|
||||||
|
|
||||||
$siteconfig->CanViewType = 'Anyone';
|
$siteconfig->CanViewType = 'Anyone';
|
||||||
$siteconfig->write();
|
$siteconfig->write();
|
||||||
@ -428,9 +429,9 @@ class SiteTreePermissionsTest extends FunctionalTest {
|
|||||||
public function testInheritCanEditFromSiteConfig() {
|
public function testInheritCanEditFromSiteConfig() {
|
||||||
$page = $this->objFromFixture('Page', 'inheritWithNoParent');
|
$page = $this->objFromFixture('Page', 'inheritWithNoParent');
|
||||||
$siteconfig = $this->objFromFixture('SiteConfig', 'default');
|
$siteconfig = $this->objFromFixture('SiteConfig', 'default');
|
||||||
$editor = $this->objFromFixture('Member', 'editor');
|
$editor = $this->objFromFixture('SilverStripe\\Security\\Member', 'editor');
|
||||||
$user = $this->objFromFixture('Member', 'websiteuser');
|
$user = $this->objFromFixture('SilverStripe\\Security\\Member', 'websiteuser');
|
||||||
$editorGroup = $this->objFromFixture('Group', 'editorgroup');
|
$editorGroup = $this->objFromFixture('SilverStripe\\Security\\Group', 'editorgroup');
|
||||||
|
|
||||||
$siteconfig->CanEditType = 'LoggedInUsers';
|
$siteconfig->CanEditType = 'LoggedInUsers';
|
||||||
$siteconfig->write();
|
$siteconfig->write();
|
||||||
|
@ -1,88 +1,88 @@
|
|||||||
SiteConfig:
|
SiteConfig:
|
||||||
default:
|
default:
|
||||||
Title: My test site
|
Title: My test site
|
||||||
Tagline: There is no doubt this is a great test site
|
Tagline: There is no doubt this is a great test site
|
||||||
CanViewType: Anyone
|
CanViewType: Anyone
|
||||||
CanEditType: LoggedInUsers
|
CanEditType: LoggedInUsers
|
||||||
Permission:
|
SilverStripe\Security\Permission:
|
||||||
cmsmain1:
|
cmsmain1:
|
||||||
Code: CMS_ACCESS_CMSMain
|
Code: CMS_ACCESS_CMSMain
|
||||||
cmsmain2:
|
cmsmain2:
|
||||||
Code: CMS_ACCESS_CMSMain
|
Code: CMS_ACCESS_CMSMain
|
||||||
grantaccess:
|
grantaccess:
|
||||||
Code: SITETREE_GRANT_ACCESS
|
Code: SITETREE_GRANT_ACCESS
|
||||||
Group:
|
SilverStripe\Security\Group:
|
||||||
subadmingroup:
|
subadmingroup:
|
||||||
Title: Create, edit and delete pages
|
Title: Create, edit and delete pages
|
||||||
Code: subadmingroup
|
Code: subadmingroup
|
||||||
Permissions: =>Permission.cmsmain1,=>Permission.grantaccess
|
Permissions: =>SilverStripe\Security\Permission.cmsmain1,=>SilverStripe\Security\Permission.grantaccess
|
||||||
editorgroup:
|
editorgroup:
|
||||||
Title: Edit existing pages
|
Title: Edit existing pages
|
||||||
Code: editorgroup
|
Code: editorgroup
|
||||||
Permissions: =>Permission.cmsmain2
|
Permissions: =>SilverStripe\Security\Permission.cmsmain2
|
||||||
websiteusers:
|
websiteusers:
|
||||||
Title: View certain restricted pages
|
Title: View certain restricted pages
|
||||||
Member:
|
SilverStripe\Security\Member:
|
||||||
subadmin:
|
subadmin:
|
||||||
Email: subadmin@test.com
|
Email: subadmin@test.com
|
||||||
Password: test
|
Password: test
|
||||||
Groups: =>Group.subadmingroup
|
Groups: =>SilverStripe\Security\Group.subadmingroup
|
||||||
editor:
|
editor:
|
||||||
Email: editor@test.com
|
Email: editor@test.com
|
||||||
Password: test
|
Password: test
|
||||||
Groups: =>Group.editorgroup
|
Groups: =>SilverStripe\Security\Group.editorgroup
|
||||||
websiteuser:
|
websiteuser:
|
||||||
Email: websiteuser@test.com
|
Email: websiteuser@test.com
|
||||||
Password: test
|
Password: test
|
||||||
Groups: =>Group.websiteusers
|
Groups: =>SilverStripe\Security\Group.websiteusers
|
||||||
Page:
|
Page:
|
||||||
standardpage:
|
standardpage:
|
||||||
URLSegment: standardpage
|
URLSegment: standardpage
|
||||||
restrictedViewLoggedInUsers:
|
restrictedViewLoggedInUsers:
|
||||||
CanViewType: LoggedInUsers
|
CanViewType: LoggedInUsers
|
||||||
URLSegment: restrictedViewLoggedInUsers
|
URLSegment: restrictedViewLoggedInUsers
|
||||||
restrictedViewOnlyWebsiteUsers:
|
restrictedViewOnlyWebsiteUsers:
|
||||||
CanViewType: OnlyTheseUsers
|
CanViewType: OnlyTheseUsers
|
||||||
ViewerGroups: =>Group.websiteusers
|
ViewerGroups: =>SilverStripe\Security\Group.websiteusers
|
||||||
URLSegment: restrictedViewOnlyWebsiteUsers
|
URLSegment: restrictedViewOnlyWebsiteUsers
|
||||||
restrictedViewOnlySubadminGroup:
|
restrictedViewOnlySubadminGroup:
|
||||||
CanViewType: OnlyTheseUsers
|
CanViewType: OnlyTheseUsers
|
||||||
ViewerGroups: =>Group.subadmingroup
|
ViewerGroups: =>SilverStripe\Security\Group.subadmingroup
|
||||||
URLSegment: restrictedViewOnlySubadminGroup
|
URLSegment: restrictedViewOnlySubadminGroup
|
||||||
restrictedEditLoggedInUsers:
|
restrictedEditLoggedInUsers:
|
||||||
CanEditType: LoggedInUsers
|
CanEditType: LoggedInUsers
|
||||||
URLSegment: restrictedEditLoggedInUsers
|
URLSegment: restrictedEditLoggedInUsers
|
||||||
restrictedEditOnlySubadminGroup:
|
restrictedEditOnlySubadminGroup:
|
||||||
CanEditType: OnlyTheseUsers
|
CanEditType: OnlyTheseUsers
|
||||||
EditorGroups: =>Group.subadmingroup
|
EditorGroups: =>SilverStripe\Security\Group.subadmingroup
|
||||||
URLSegment: restrictedEditOnlySubadminGroup
|
URLSegment: restrictedEditOnlySubadminGroup
|
||||||
inheritWithNoParent:
|
inheritWithNoParent:
|
||||||
CanEditType: Inherit
|
CanEditType: Inherit
|
||||||
CanViewType: Inherit
|
CanViewType: Inherit
|
||||||
URLSegment: inheritWithNoParent
|
URLSegment: inheritWithNoParent
|
||||||
parent_restrictedViewOnlySubadminGroup:
|
parent_restrictedViewOnlySubadminGroup:
|
||||||
CanViewType: OnlyTheseUsers
|
CanViewType: OnlyTheseUsers
|
||||||
ViewerGroups: =>Group.subadmingroup
|
ViewerGroups: =>SilverStripe\Security\Group.subadmingroup
|
||||||
URLSegment: parent-restrictedViewOnlySubadminGroup
|
URLSegment: parent-restrictedViewOnlySubadminGroup
|
||||||
child_restrictedViewOnlySubadminGroup:
|
child_restrictedViewOnlySubadminGroup:
|
||||||
CanViewType: Inherit
|
CanViewType: Inherit
|
||||||
Parent: =>Page.parent_restrictedViewOnlySubadminGroup
|
Parent: =>Page.parent_restrictedViewOnlySubadminGroup
|
||||||
URLSegment: child-restrictedViewOnlySubadminGroup
|
URLSegment: child-restrictedViewOnlySubadminGroup
|
||||||
parent_restrictedEditOnlySubadminGroup:
|
parent_restrictedEditOnlySubadminGroup:
|
||||||
CanEditType: OnlyTheseUsers
|
CanEditType: OnlyTheseUsers
|
||||||
EditorGroups: =>Group.subadmingroup
|
EditorGroups: =>SilverStripe\Security\Group.subadmingroup
|
||||||
URLSegment: parent-restrictedEditOnlySubadminGroup
|
URLSegment: parent-restrictedEditOnlySubadminGroup
|
||||||
child_restrictedEditOnlySubadminGroup:
|
child_restrictedEditOnlySubadminGroup:
|
||||||
CanEditType: Inherit
|
CanEditType: Inherit
|
||||||
Parent: =>Page.parent_restrictedEditOnlySubadminGroup
|
Parent: =>Page.parent_restrictedEditOnlySubadminGroup
|
||||||
URLSegment: child-restrictedEditOnlySubadminGroup
|
URLSegment: child-restrictedEditOnlySubadminGroup
|
||||||
deleteTestParentPage:
|
deleteTestParentPage:
|
||||||
CanEditType: Inherit
|
CanEditType: Inherit
|
||||||
URLSegment: deleteTestParentPage
|
URLSegment: deleteTestParentPage
|
||||||
deleteTestChildPage:
|
deleteTestChildPage:
|
||||||
CanEditType: OnlyTheseUsers
|
CanEditType: OnlyTheseUsers
|
||||||
EditorGroups: =>Group.subadmingroup
|
EditorGroups: =>SilverStripe\Security\Group.subadmingroup
|
||||||
URLSegment: deleteTestChildPage
|
URLSegment: deleteTestChildPage
|
||||||
draftOnlyPage:
|
draftOnlyPage:
|
||||||
CanViewType: Anyone
|
CanViewType: Anyone
|
||||||
URLSegment: draft-only
|
URLSegment: draft-only
|
||||||
|
@ -5,6 +5,9 @@ use SilverStripe\ORM\Versioning\Versioned;
|
|||||||
use SilverStripe\ORM\DataObject;
|
use SilverStripe\ORM\DataObject;
|
||||||
use SilverStripe\ORM\ValidationException;
|
use SilverStripe\ORM\ValidationException;
|
||||||
use SilverStripe\ORM\DataExtension;
|
use SilverStripe\ORM\DataExtension;
|
||||||
|
use SilverStripe\Security\Member;
|
||||||
|
use SilverStripe\Security\Permission;
|
||||||
|
use SilverStripe\Security\Group;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @package cms
|
* @package cms
|
||||||
@ -459,7 +462,7 @@ class SiteTreeTest extends SapphireTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function testEditPermissions() {
|
public function testEditPermissions() {
|
||||||
$editor = $this->objFromFixture("Member", "editor");
|
$editor = $this->objFromFixture("SilverStripe\\Security\\Member", "editor");
|
||||||
|
|
||||||
$home = $this->objFromFixture("Page", "home");
|
$home = $this->objFromFixture("Page", "home");
|
||||||
$staff = $this->objFromFixture("Page", "staff");
|
$staff = $this->objFromFixture("Page", "staff");
|
||||||
@ -487,8 +490,8 @@ class SiteTreeTest extends SapphireTest {
|
|||||||
public function testCanEditWithAccessToAllSections() {
|
public function testCanEditWithAccessToAllSections() {
|
||||||
$page = new Page();
|
$page = new Page();
|
||||||
$page->write();
|
$page->write();
|
||||||
$allSectionMember = $this->objFromFixture('Member', 'allsections');
|
$allSectionMember = $this->objFromFixture('SilverStripe\\Security\\Member', 'allsections');
|
||||||
$securityAdminMember = $this->objFromFixture('Member', 'securityadmin');
|
$securityAdminMember = $this->objFromFixture('SilverStripe\\Security\\Member', 'securityadmin');
|
||||||
|
|
||||||
$this->assertTrue($page->canEdit($allSectionMember));
|
$this->assertTrue($page->canEdit($allSectionMember));
|
||||||
$this->assertFalse($page->canEdit($securityAdminMember));
|
$this->assertFalse($page->canEdit($securityAdminMember));
|
||||||
@ -532,31 +535,31 @@ class SiteTreeTest extends SapphireTest {
|
|||||||
// Lock down the site config
|
// Lock down the site config
|
||||||
$sc = $page->SiteConfig;
|
$sc = $page->SiteConfig;
|
||||||
$sc->CanEditType = 'OnlyTheseUsers';
|
$sc->CanEditType = 'OnlyTheseUsers';
|
||||||
$sc->EditorGroups()->add($this->idFromFixture('Group', 'admins'));
|
$sc->EditorGroups()->add($this->idFromFixture('SilverStripe\\Security\\Group', 'admins'));
|
||||||
$sc->write();
|
$sc->write();
|
||||||
|
|
||||||
// Confirm that Member.editor can't edit the page
|
// Confirm that Member.editor can't edit the page
|
||||||
$this->objFromFixture('Member','editor')->logIn();
|
$this->objFromFixture('SilverStripe\\Security\\Member','editor')->logIn();
|
||||||
$this->assertFalse($page->canEdit());
|
$this->assertFalse($page->canEdit());
|
||||||
|
|
||||||
// Change the page to be editable by Group.editors, but do not publish
|
// Change the page to be editable by Group.editors, but do not publish
|
||||||
$this->objFromFixture('Member','admin')->logIn();
|
$this->objFromFixture('SilverStripe\\Security\\Member','admin')->logIn();
|
||||||
$page->CanEditType = 'OnlyTheseUsers';
|
$page->CanEditType = 'OnlyTheseUsers';
|
||||||
$page->EditorGroups()->add($this->idFromFixture('Group', 'editors'));
|
$page->EditorGroups()->add($this->idFromFixture('SilverStripe\\Security\\Group', 'editors'));
|
||||||
$page->write();
|
$page->write();
|
||||||
// Clear permission cache
|
// Clear permission cache
|
||||||
SiteTree::on_db_reset();
|
SiteTree::on_db_reset();
|
||||||
|
|
||||||
// Confirm that Member.editor can now edit the page
|
// Confirm that Member.editor can now edit the page
|
||||||
$this->objFromFixture('Member','editor')->logIn();
|
$this->objFromFixture('SilverStripe\\Security\\Member','editor')->logIn();
|
||||||
$this->assertTrue($page->canEdit());
|
$this->assertTrue($page->canEdit());
|
||||||
|
|
||||||
// Publish the changes to the page
|
// Publish the changes to the page
|
||||||
$this->objFromFixture('Member','admin')->logIn();
|
$this->objFromFixture('SilverStripe\\Security\\Member','admin')->logIn();
|
||||||
$page->publishRecursive();
|
$page->publishRecursive();
|
||||||
|
|
||||||
// Confirm that Member.editor can still edit the page
|
// Confirm that Member.editor can still edit the page
|
||||||
$this->objFromFixture('Member','editor')->logIn();
|
$this->objFromFixture('SilverStripe\\Security\\Member','editor')->logIn();
|
||||||
$this->assertTrue($page->canEdit());
|
$this->assertTrue($page->canEdit());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -592,7 +595,7 @@ class SiteTreeTest extends SapphireTest {
|
|||||||
if($member) {
|
if($member) {
|
||||||
$memberID = $member->ID;
|
$memberID = $member->ID;
|
||||||
} else {
|
} else {
|
||||||
$memberID = $this->idFromFixture("Member", "admin");
|
$memberID = $this->idFromFixture("SilverStripe\\Security\\Member", "admin");
|
||||||
Session::set("loggedInAs", $memberID);
|
Session::set("loggedInAs", $memberID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ SiteConfig:
|
|||||||
CanEditType: LoggedInUsers
|
CanEditType: LoggedInUsers
|
||||||
CanCreateTopLevelType: LoggedInUsers
|
CanCreateTopLevelType: LoggedInUsers
|
||||||
|
|
||||||
Group:
|
SilverStripe\Security\Group:
|
||||||
editors:
|
editors:
|
||||||
Title: Editors
|
Title: Editors
|
||||||
admins:
|
admins:
|
||||||
@ -16,43 +16,43 @@ Group:
|
|||||||
securityadmins:
|
securityadmins:
|
||||||
Title: Security Admins
|
Title: Security Admins
|
||||||
|
|
||||||
Permission:
|
SilverStripe\Security\Permission:
|
||||||
admins:
|
admins:
|
||||||
Code: ADMIN
|
Code: ADMIN
|
||||||
Group: =>Group.admins
|
Group: =>SilverStripe\Security\Group.admins
|
||||||
editors:
|
editors:
|
||||||
Code: CMS_ACCESS_CMSMain
|
Code: CMS_ACCESS_CMSMain
|
||||||
Group: =>Group.editors
|
Group: =>SilverStripe\Security\Group.editors
|
||||||
allsections:
|
allsections:
|
||||||
Code: CMS_ACCESS_LeftAndMain
|
Code: CMS_ACCESS_LeftAndMain
|
||||||
Group: =>Group.allsections
|
Group: =>SilverStripe\Security\Group.allsections
|
||||||
securityadmins:
|
securityadmins:
|
||||||
Code: CMS_ACCESS_SecurityAdmin
|
Code: CMS_ACCESS_SecurityAdmin
|
||||||
Group: =>Group.securityadmins
|
Group: =>SilverStripe\Security\Group.securityadmins
|
||||||
|
|
||||||
Member:
|
SilverStripe\Security\Member:
|
||||||
editor:
|
editor:
|
||||||
FirstName: Test
|
FirstName: Test
|
||||||
Surname: Editor
|
Surname: Editor
|
||||||
Groups: =>Group.editors
|
Groups: =>SilverStripe\Security\Group.editors
|
||||||
admin:
|
admin:
|
||||||
FirstName: Test
|
FirstName: Test
|
||||||
Surname: Administrator
|
Surname: Administrator
|
||||||
Groups: =>Group.admins
|
Groups: =>SilverStripe\Security\Group.admins
|
||||||
allsections:
|
allsections:
|
||||||
Groups: =>Group.allsections
|
Groups: =>SilverStripe\Security\Group.allsections
|
||||||
securityadmin:
|
securityadmin:
|
||||||
Groups: =>Group.securityadmins
|
Groups: =>SilverStripe\Security\Group.securityadmins
|
||||||
|
|
||||||
Page:
|
Page:
|
||||||
home:
|
home:
|
||||||
Title: Home
|
Title: Home
|
||||||
CanEditType: OnlyTheseUsers
|
CanEditType: OnlyTheseUsers
|
||||||
EditorGroups: =>Group.admins
|
EditorGroups: =>SilverStripe\Security\Group.admins
|
||||||
about:
|
about:
|
||||||
Title: About Us
|
Title: About Us
|
||||||
CanEditType: OnlyTheseUsers
|
CanEditType: OnlyTheseUsers
|
||||||
EditorGroups: =>Group.admins
|
EditorGroups: =>SilverStripe\Security\Group.admins
|
||||||
staff:
|
staff:
|
||||||
Title: Staff
|
Title: Staff
|
||||||
URLSegment: my-staff
|
URLSegment: my-staff
|
||||||
@ -68,7 +68,7 @@ Page:
|
|||||||
products:
|
products:
|
||||||
Title: Products
|
Title: Products
|
||||||
CanEditType: OnlyTheseUsers
|
CanEditType: OnlyTheseUsers
|
||||||
EditorGroups: =>Group.editors
|
EditorGroups: =>SilverStripe\Security\Group.editors
|
||||||
product1:
|
product1:
|
||||||
Title: 1.1 Test Product
|
Title: 1.1 Test Product
|
||||||
Parent: =>Page.products
|
Parent: =>Page.products
|
||||||
@ -85,7 +85,7 @@ Page:
|
|||||||
Title: Another Product
|
Title: Another Product
|
||||||
Parent: =>Page.products
|
Parent: =>Page.products
|
||||||
CanEditType: OnlyTheseUsers
|
CanEditType: OnlyTheseUsers
|
||||||
EditorGroups: =>Group.admins
|
EditorGroups: =>SilverStripe\Security\Group.admins
|
||||||
contact:
|
contact:
|
||||||
Title: Contact Us
|
Title: Contact Us
|
||||||
object:
|
object:
|
||||||
|
@ -229,8 +229,8 @@ class VirtualPageTest extends FunctionalTest {
|
|||||||
public function testCanEdit() {
|
public function testCanEdit() {
|
||||||
$parentPage = $this->objFromFixture('Page', 'master3');
|
$parentPage = $this->objFromFixture('Page', 'master3');
|
||||||
$virtualPage = $this->objFromFixture('VirtualPage', 'vp3');
|
$virtualPage = $this->objFromFixture('VirtualPage', 'vp3');
|
||||||
$bob = $this->objFromFixture('Member', 'bob');
|
$bob = $this->objFromFixture('SilverStripe\\Security\\Member', 'bob');
|
||||||
$andrew = $this->objFromFixture('Member', 'andrew');
|
$andrew = $this->objFromFixture('SilverStripe\\Security\\Member', 'andrew');
|
||||||
|
|
||||||
// Bob can edit the mirrored page, but he shouldn't be able to edit the virtual page.
|
// Bob can edit the mirrored page, but he shouldn't be able to edit the virtual page.
|
||||||
$this->logInAs($bob);
|
$this->logInAs($bob);
|
||||||
@ -248,8 +248,8 @@ class VirtualPageTest extends FunctionalTest {
|
|||||||
$parentPage->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
$parentPage->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||||
$virtualPage = $this->objFromFixture('VirtualPage', 'vp3');
|
$virtualPage = $this->objFromFixture('VirtualPage', 'vp3');
|
||||||
$virtualPage->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
$virtualPage->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||||
$cindy = $this->objFromFixture('Member', 'cindy');
|
$cindy = $this->objFromFixture('SilverStripe\\Security\\Member', 'cindy');
|
||||||
$alice = $this->objFromFixture('Member', 'alice');
|
$alice = $this->objFromFixture('SilverStripe\\Security\\Member', 'alice');
|
||||||
|
|
||||||
// Cindy can see both pages
|
// Cindy can see both pages
|
||||||
$this->logInAs($cindy);
|
$this->logInAs($cindy);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
Group:
|
SilverStripe\Security\Group:
|
||||||
bobgroup:
|
bobgroup:
|
||||||
Title: BobGroup
|
Title: BobGroup
|
||||||
code: bobgroup
|
code: bobgroup
|
||||||
@ -10,27 +10,27 @@ Group:
|
|||||||
code: cindygroup
|
code: cindygroup
|
||||||
alicegroup:
|
alicegroup:
|
||||||
Title: AliceGroup
|
Title: AliceGroup
|
||||||
code: alicegrouip
|
code: alicegroup
|
||||||
Permission:
|
SilverStripe\Security\Permission:
|
||||||
bobpermission:
|
bobpermission:
|
||||||
Code: CMS_ACCESS_CMSMain
|
Code: CMS_ACCESS_CMSMain
|
||||||
Group: =>Group.bobgroup
|
Group: =>SilverStripe\Security\Group.bobgroup
|
||||||
andrewpermission:
|
andrewpermission:
|
||||||
Code: CMS_ACCESS_CMSMain
|
Code: CMS_ACCESS_CMSMain
|
||||||
Group: =>Group.andrewgroup
|
Group: =>SilverStripe\Security\Group.andrewgroup
|
||||||
Member:
|
SilverStripe\Security\Member:
|
||||||
bob:
|
bob:
|
||||||
Email: bob@bobby.com
|
Email: bob@bobby.com
|
||||||
Groups: =>Group.bobgroup
|
Groups: =>SilverStripe\Security\Group.bobgroup
|
||||||
andrew:
|
andrew:
|
||||||
Email: andrew@andrew.com
|
Email: andrew@andrew.com
|
||||||
Groups: =>Group.andrewgroup
|
Groups: =>SilverStripe\Security\Group.andrewgroup
|
||||||
cindy:
|
cindy:
|
||||||
Email: cindy@cindy.com
|
Email: cindy@cindy.com
|
||||||
Groups: =>Group.cindygroup
|
Groups: =>SilverStripe\Security\Group.cindygroup
|
||||||
alice:
|
alice:
|
||||||
Email: alice@alice.com
|
Email: alice@alice.com
|
||||||
Groups: =>Group.alicegroup
|
Groups: =>SilverStripe\Security\Group.alicegroup
|
||||||
Page:
|
Page:
|
||||||
master:
|
master:
|
||||||
Title: My Page
|
Title: My Page
|
||||||
@ -44,7 +44,7 @@ Page:
|
|||||||
Title: CanEditBob
|
Title: CanEditBob
|
||||||
CanEditType: OnlyTheseUsers
|
CanEditType: OnlyTheseUsers
|
||||||
CanViewType: Inherit
|
CanViewType: Inherit
|
||||||
EditorGroups: =>Group.bobgroup
|
EditorGroups: =>SilverStripe\Security\Group.bobgroup
|
||||||
VirtualPage:
|
VirtualPage:
|
||||||
vp1:
|
vp1:
|
||||||
Title: vp1
|
Title: vp1
|
||||||
@ -59,5 +59,5 @@ VirtualPage:
|
|||||||
Parent: =>Page.holder
|
Parent: =>Page.holder
|
||||||
CanEditType: OnlyTheseUsers
|
CanEditType: OnlyTheseUsers
|
||||||
CanViewType: OnlyTheseUsers
|
CanViewType: OnlyTheseUsers
|
||||||
EditorGroups: =>Group.andrewgroup
|
EditorGroups: =>SilverStripe\Security\Group.andrewgroup
|
||||||
ViewerGroups: =>Group.cindygroup
|
ViewerGroups: =>SilverStripe\Security\Group.cindygroup
|
||||||
|
@ -4,7 +4,7 @@ class CMSMainSearchFormTest extends FunctionalTest {
|
|||||||
protected static $fixture_file = '../controller/CMSMainTest.yml';
|
protected static $fixture_file = '../controller/CMSMainTest.yml';
|
||||||
|
|
||||||
public function testTitleFilter() {
|
public function testTitleFilter() {
|
||||||
$this->session()->inst_set('loggedInAs', $this->idFromFixture('Member', 'admin'));
|
$this->session()->inst_set('loggedInAs', $this->idFromFixture('SilverStripe\\Security\\Member', 'admin'));
|
||||||
|
|
||||||
$response = $this->get(
|
$response = $this->get(
|
||||||
'admin/pages/SearchForm/?' .
|
'admin/pages/SearchForm/?' .
|
||||||
|
@ -2,6 +2,9 @@
|
|||||||
|
|
||||||
use SilverStripe\ORM\DB;
|
use SilverStripe\ORM\DB;
|
||||||
use SilverStripe\ORM\Versioning\Versioned;
|
use SilverStripe\ORM\Versioning\Versioned;
|
||||||
|
use SilverStripe\MSSQL\MSSQLDatabase;
|
||||||
|
use SilverStripe\PostgreSQL\PostgreSQLDatabase;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @package cms
|
* @package cms
|
||||||
@ -51,7 +54,7 @@ class ZZZSearchFormTest extends FunctionalTest {
|
|||||||
*/
|
*/
|
||||||
protected function checkFulltextSupport() {
|
protected function checkFulltextSupport() {
|
||||||
$conn = DB::get_conn();
|
$conn = DB::get_conn();
|
||||||
if(class_exists('MSSQLDatabase') && $conn instanceof MSSQLDatabase) {
|
if(class_exists('SilverStripe\\MSSQL\\MSSQLDatabase') && $conn instanceof MSSQLDatabase) {
|
||||||
$supports = $conn->fullTextEnabled();
|
$supports = $conn->fullTextEnabled();
|
||||||
} else {
|
} else {
|
||||||
$supports = true;
|
$supports = true;
|
||||||
@ -137,7 +140,7 @@ class ZZZSearchFormTest extends FunctionalTest {
|
|||||||
'Page with "Restrict to logged in users" doesnt show without valid login'
|
'Page with "Restrict to logged in users" doesnt show without valid login'
|
||||||
);
|
);
|
||||||
|
|
||||||
$member = $this->objFromFixture('Member', 'randomuser');
|
$member = $this->objFromFixture('SilverStripe\\Security\\Member', 'randomuser');
|
||||||
$member->logIn();
|
$member->logIn();
|
||||||
$results = $sf->getResults(null, array('Search'=>'restrictedViewLoggedInUsers'));
|
$results = $sf->getResults(null, array('Search'=>'restrictedViewLoggedInUsers'));
|
||||||
$this->assertContains(
|
$this->assertContains(
|
||||||
@ -162,7 +165,7 @@ class ZZZSearchFormTest extends FunctionalTest {
|
|||||||
'Page with "Restrict to these users" doesnt show without valid login'
|
'Page with "Restrict to these users" doesnt show without valid login'
|
||||||
);
|
);
|
||||||
|
|
||||||
$member = $this->objFromFixture('Member', 'randomuser');
|
$member = $this->objFromFixture('SilverStripe\\Security\\Member', 'randomuser');
|
||||||
$member->logIn();
|
$member->logIn();
|
||||||
$results = $sf->getResults(null, array('Search'=>'restrictedViewOnlyWebsiteUsers'));
|
$results = $sf->getResults(null, array('Search'=>'restrictedViewOnlyWebsiteUsers'));
|
||||||
$this->assertNotContains(
|
$this->assertNotContains(
|
||||||
@ -172,7 +175,7 @@ class ZZZSearchFormTest extends FunctionalTest {
|
|||||||
);
|
);
|
||||||
$member->logOut();
|
$member->logOut();
|
||||||
|
|
||||||
$member = $this->objFromFixture('Member', 'websiteuser');
|
$member = $this->objFromFixture('SilverStripe\\Security\\Member', 'websiteuser');
|
||||||
$member->logIn();
|
$member->logIn();
|
||||||
$results = $sf->getResults(null, array('Search'=>'restrictedViewOnlyWebsiteUsers'));
|
$results = $sf->getResults(null, array('Search'=>'restrictedViewOnlyWebsiteUsers'));
|
||||||
$this->assertContains(
|
$this->assertContains(
|
||||||
@ -198,7 +201,7 @@ class ZZZSearchFormTest extends FunctionalTest {
|
|||||||
'Page inheriting "Restrict to loggedin users" doesnt show without valid login'
|
'Page inheriting "Restrict to loggedin users" doesnt show without valid login'
|
||||||
);
|
);
|
||||||
|
|
||||||
$member = $this->objFromFixture('Member', 'websiteuser');
|
$member = $this->objFromFixture('SilverStripe\\Security\\Member', 'websiteuser');
|
||||||
$member->logIn();
|
$member->logIn();
|
||||||
$results = $sf->getResults(null, array('Search'=>'inheritRestrictedView'));
|
$results = $sf->getResults(null, array('Search'=>'inheritRestrictedView'));
|
||||||
$this->assertContains(
|
$this->assertContains(
|
||||||
@ -251,7 +254,7 @@ class ZZZSearchFormTest extends FunctionalTest {
|
|||||||
public function testSearchTitleAndContentWithSpecialCharacters() {
|
public function testSearchTitleAndContentWithSpecialCharacters() {
|
||||||
if(!$this->checkFulltextSupport()) return;
|
if(!$this->checkFulltextSupport()) return;
|
||||||
|
|
||||||
if(class_exists('PostgreSQLDatabase') && DB::get_conn() instanceof PostgreSQLDatabase) {
|
if(class_exists('SilverStripe\\PostgreSQL\\PostgreSQLDatabase') && DB::get_conn() instanceof PostgreSQLDatabase) {
|
||||||
$this->markTestSkipped("PostgreSQLDatabase doesn't support entity-encoded searches");
|
$this->markTestSkipped("PostgreSQLDatabase doesn't support entity-encoded searches");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
Group:
|
SilverStripe\Security\Group:
|
||||||
websiteusers:
|
websiteusers:
|
||||||
Title: View certain restricted pages
|
Title: View certain restricted pages
|
||||||
Member:
|
SilverStripe\Security\Member:
|
||||||
randomuser:
|
randomuser:
|
||||||
Email: randomuser@test.com
|
Email: randomuser@test.com
|
||||||
Password: test
|
Password: test
|
||||||
websiteuser:
|
websiteuser:
|
||||||
Email: websiteuser@test.com
|
Email: websiteuser@test.com
|
||||||
Password: test
|
Password: test
|
||||||
Groups: =>Group.websiteusers
|
Groups: =>SilverStripe\Security\Group.websiteusers
|
||||||
SiteTree:
|
SiteTree:
|
||||||
searchformholder:
|
searchformholder:
|
||||||
URLSegment: searchformholder
|
URLSegment: searchformholder
|
||||||
@ -22,7 +22,7 @@ SiteTree:
|
|||||||
Title: restrictedViewLoggedInUsers
|
Title: restrictedViewLoggedInUsers
|
||||||
restrictedViewOnlyWebsiteUsers:
|
restrictedViewOnlyWebsiteUsers:
|
||||||
CanViewType: OnlyTheseUsers
|
CanViewType: OnlyTheseUsers
|
||||||
ViewerGroups: =>Group.websiteusers
|
ViewerGroups: =>SilverStripe\Security\Group.websiteusers
|
||||||
Title: restrictedViewOnlyWebsiteUsers
|
Title: restrictedViewOnlyWebsiteUsers
|
||||||
inheritRestrictedView:
|
inheritRestrictedView:
|
||||||
CanViewType: Inherit
|
CanViewType: Inherit
|
||||||
|
Loading…
Reference in New Issue
Block a user