web/website/integrations/mybb/test-system-board-provision.php

13 lines
1.1 KiB
PHP

<?php
define('IN_MYBB',1);
require __DIR__.'/system-board-provision.php';
$grant=['kind'=>'clan','id'=>'11111111-1111-4111-8111-111111111111','name'=>'Fixture Clan','read'=>true,'post'=>true];
$projection=['version'=>1,'organisations'=>[$grant,$grant,array_merge($grant,['kind'=>'unknown']),array_merge($grant,['read'=>false])]];
$missing=dune_missing_system_boards($projection,[]);
if(count($missing)!==1 || $missing[0]['name']!=='Fixture Clan')throw new RuntimeException('Missing verified clan must be deduplicated and provisioned');
if(dune_missing_system_boards($projection,['clan:'.$grant['id']=>['fid'=>10]])!==[])throw new RuntimeException('Existing board must not be recreated');
foreach([array_merge($grant,['id'=>'injected']),array_merge($grant,['name'=>''])] as $invalid){
$rejected=false;try{dune_missing_system_boards(['version'=>1,'organisations'=>[$invalid]],[]);}catch(RuntimeException $e){$rejected=true;}
if(!$rejected)throw new RuntimeException('Invalid verified identity must fail closed');
}
echo "Automatic System Boards provisioning policy checks passed\n";