MC/website/integrations/mybb/test-central-account-controls.php
2026-11-27 23:43:05 +00:00

17 lines
2.2 KiB
PHP

<?php
if(PHP_SAPI!=='cli')exit(1);
require __DIR__.'/central-account-controls.php';
$checks=0;$check=static function($ok)use(&$checks){if(!$ok)throw new RuntimeException('Central account policy check failed');$checks++;};
$human=['nativePermissionManagement'=>false];$dev=['username'=>'dev','permissions'=>['web.forum.admin']];
$check(dune_central_account_target($human,'/private.php','send')==='https://cp.dunerealms.com/#post/mail-inbox');
foreach(['profile','do_profile','changename','do_changename','avatar','do_avatar','editsig','do_editsig']as$action)$check(dune_central_account_target($human,'usercp.php',$action)==='https://cp.dunerealms.com/#realm/site-profile');
foreach(['email','do_email','password','do_password']as$action)$check(dune_central_account_target($human,'usercp.php',$action)==='https://cp.dunerealms.com/#realm/security');
foreach(['options','do_options','subscriptions','attachments']as$action)$check(dune_central_account_target($human,'usercp.php',$action)===null);
$check(dune_central_account_target($dev,'private.php')===null);$check(dune_central_account_target($dev,'usercp.php','do_password')===null);
$GLOBALS['dune_central_account_user']=true;$mybb=(object)['usergroup'=>['canusepms'=>1,'cansendpms'=>1,'canusercp'=>1,'canusesig'=>1]];dune_central_account_permissions();
$check($mybb->usergroup['canusepms']===0&&$mybb->usergroup['cansendpms']===0);$check($mybb->usergroup['canusercp']===1&&$mybb->usergroup['canusesig']===1);
$templates=(object)['cache'=>[]];dune_central_account_menu();$check(str_contains($templates->cache['usercp_nav_profile'],'Manage profile &amp; identity'));
$html='<a href="private.php">Private Messages (Unread 0, Total 0)</a><a href="usercp.php?action=options">Forum preferences</a><a href="https://other.invalid/private.php">External</a>';
$result=dune_central_account_output($html);$check(!str_contains($result,'Private Messages'));$check(str_contains($result,'#post/mail-inbox'));$check(str_contains($result,'usercp.php?action=options'));$check(str_contains($result,'https://other.invalid/private.php'));
$GLOBALS['dune_central_account_user']=false;$check(dune_central_account_output($html)===$html);
echo json_encode(['passed'=>$checks,'devNativeToolsPreserved'=>true,'forumPreferencesPreserved'=>true]).PHP_EOL;