88
99namespace OCA \Libresign \Tests \Unit \Service \Policy \Runtime ;
1010
11+ require_once __DIR__ . '/../../../../../../lib/Service/Policy/Contract/IPolicySource.php ' ;
12+
1113use OCA \Libresign \Service \Policy \Contract \IPolicySource ;
1214use OCA \Libresign \Service \Policy \Model \PolicyContext ;
1315use OCA \Libresign \Service \Policy \Model \PolicyLayer ;
@@ -334,11 +336,13 @@ final class InMemoryPolicySource implements IPolicySource {
334336 public array $ groupLayers = [];
335337 /** @var list<PolicyLayer> */
336338 public array $ circleLayers = [];
339+ public ?PolicyLayer $ userPolicy = null ;
337340 public ?PolicyLayer $ userPreference = null ;
338341 public ?PolicyLayer $ requestOverride = null ;
339342 public bool $ userPreferenceCleared = false ;
340343 public bool $ circlePoliciesLoaded = false ;
341344 public bool $ bulkGroupPoliciesLoaded = false ;
345+ public bool $ bulkUserPoliciesLoaded = false ;
342346 public bool $ bulkUserPrefsLoaded = false ;
343347
344348 public function loadSystemPolicy (string $ policyKey ): ?PolicyLayer {
@@ -358,6 +362,10 @@ public function loadCirclePolicies(string $policyKey, PolicyContext $context): a
358362 return $ this ->circleLayers ;
359363 }
360364
365+ public function loadUserPolicy (string $ policyKey , PolicyContext $ context ): ?PolicyLayer {
366+ return $ this ->userPolicy ;
367+ }
368+
361369 public function loadUserPreference (string $ policyKey , PolicyContext $ context ): ?PolicyLayer {
362370 return $ this ->userPreference ;
363371 }
@@ -372,6 +380,15 @@ public function loadAllGroupPolicies(array $policyKeys, PolicyContext $context):
372380 return array_fill_keys ($ policyKeys , $ this ->groupLayers );
373381 }
374382
383+ /** @param list<string> $policyKeys */
384+ public function loadAllUserPolicies (array $ policyKeys , PolicyContext $ context ): array {
385+ $ this ->bulkUserPoliciesLoaded = true ;
386+ if ($ this ->userPolicy === null ) {
387+ return [];
388+ }
389+ return array_fill_keys ($ policyKeys , $ this ->userPolicy );
390+ }
391+
375392 /** @param list<string> $policyKeys */
376393 public function loadAllUserPreferences (array $ policyKeys , PolicyContext $ context ): array {
377394 $ this ->bulkUserPrefsLoaded = true ;
@@ -387,13 +404,23 @@ public function saveSystemPolicy(string $policyKey, mixed $value, bool $allowChi
387404 public function saveGroupPolicy (string $ policyKey , string $ groupId , mixed $ value , bool $ allowChildOverride ): void {
388405 }
389406
407+ public function loadUserPolicyConfig (string $ policyKey , string $ userId ): ?PolicyLayer {
408+ return $ this ->userPolicy ;
409+ }
410+
390411 public function saveUserPreference (string $ policyKey , PolicyContext $ context , mixed $ value ): void {
391412 }
392413
414+ public function saveUserPolicy (string $ policyKey , PolicyContext $ context , mixed $ value , bool $ allowChildOverride ): void {
415+ }
416+
393417 public function clearGroupPolicy (string $ policyKey , string $ groupId ): void {
394418 }
395419
396420 public function clearUserPreference (string $ policyKey , PolicyContext $ context ): void {
397421 $ this ->userPreferenceCleared = true ;
398422 }
423+
424+ public function clearUserPolicy (string $ policyKey , PolicyContext $ context ): void {
425+ }
399426}
0 commit comments