|
44 | 44 | use OCP\Files\IMimeTypeDetector; |
45 | 45 | use OCP\Files\IRootFolder; |
46 | 46 | use OCP\Files\NotFoundException; |
| 47 | +use OCP\Group\ISubAdmin; |
47 | 48 | use OCP\IAppConfig; |
48 | 49 | use OCP\IGroupManager; |
49 | 50 | use OCP\IL10N; |
@@ -77,6 +78,7 @@ final class AccountServiceTest extends \OCA\Libresign\Tests\Unit\TestCase { |
77 | 78 | private ValidateHelper&MockObject $validateHelper; |
78 | 79 | private IURLGenerator&MockObject $urlGenerator; |
79 | 80 | private IGroupManager&MockObject $groupManager; |
| 81 | + private ISubAdmin&MockObject $subAdmin; |
80 | 82 | private IdDocsService&MockObject $idDocsService; |
81 | 83 | private SignerElementsService&MockObject $signerElementsService; |
82 | 84 | private UserElementMapper&MockObject $userElementMapper; |
@@ -114,6 +116,7 @@ public function setUp(): void { |
114 | 116 | $this->urlGenerator = $this->createMock(IURLGenerator::class); |
115 | 117 | $this->pkcs12Handler = $this->createMock(Pkcs12Handler::class); |
116 | 118 | $this->groupManager = $this->createMock(IGroupManager::class); |
| 119 | + $this->subAdmin = $this->createMock(ISubAdmin::class); |
117 | 120 | $this->idDocsService = $this->createMock(IdDocsService::class); |
118 | 121 | $this->signerElementsService = $this->createMock(SignerElementsService::class); |
119 | 122 | $this->userElementMapper = $this->createMock(UserElementMapper::class); |
@@ -147,6 +150,7 @@ private function getService(): AccountService { |
147 | 150 | $this->urlGenerator, |
148 | 151 | $this->pkcs12Handler, |
149 | 152 | $this->groupManager, |
| 153 | + $this->subAdmin, |
150 | 154 | $this->idDocsService, |
151 | 155 | $this->signerElementsService, |
152 | 156 | $this->userElementMapper, |
@@ -179,6 +183,25 @@ public function testDeletePfxRevokesCertificatesWithReasonAndDeletesPfx(): void |
179 | 183 | $this->getService()->deletePfx($user); |
180 | 184 | } |
181 | 185 |
|
| 186 | + public function testGetConfigSetsCanManageGroupPoliciesForSubAdmin(): void { |
| 187 | + $user = $this->createMock(IUser::class); |
| 188 | + $user->method('getUID')->willReturn('group-admin-user'); |
| 189 | + |
| 190 | + $this->groupManager->method('isAdmin') |
| 191 | + ->with('group-admin-user') |
| 192 | + ->willReturn(false); |
| 193 | + |
| 194 | + $this->subAdmin->expects($this->once()) |
| 195 | + ->method('isSubAdmin') |
| 196 | + ->with($user) |
| 197 | + ->willReturn(true); |
| 198 | + |
| 199 | + $config = $this->getService()->getConfig($user); |
| 200 | + |
| 201 | + $this->assertArrayHasKey('can_manage_group_policies', $config); |
| 202 | + $this->assertTrue($config['can_manage_group_policies']); |
| 203 | + } |
| 204 | + |
182 | 205 | #[DataProvider('provideValidateCertificateDataCases')] |
183 | 206 | public function testValidateCertificateDataUsingDataProvider($arguments, $expectedErrorMessage):void { |
184 | 207 | if (is_callable($arguments)) { |
|
0 commit comments