|
6 | 6 | * SPDX-License-Identifier: AGPL-3.0-or-later |
7 | 7 | */ |
8 | 8 |
|
| 9 | +namespace Test; |
| 10 | + |
| 11 | +/** |
| 12 | + * Overwrite opendir in the Test namespace. |
| 13 | + */ |
| 14 | + |
| 15 | +function testCaseWillIgnore(string $node): bool { |
| 16 | + $libresignPath = current(glob(\OC::$SERVERROOT . '/data/appdata_*/libresign')); |
| 17 | + $knownEntries = [ |
| 18 | + $libresignPath . '/aarch', |
| 19 | + $libresignPath . '/arm64', |
| 20 | + $libresignPath . '/cfssl_config', |
| 21 | + $libresignPath . '/x86_64', |
| 22 | + ]; |
| 23 | + foreach ($knownEntries as $ignored) { |
| 24 | + if (str_starts_with($node, $ignored)) { |
| 25 | + return true; |
| 26 | + } |
| 27 | + } |
| 28 | + return false; |
| 29 | +} |
| 30 | + |
| 31 | +function rmdir($dir) { |
| 32 | + if (testCaseWillIgnore($dir)) { |
| 33 | + return false; |
| 34 | + } |
| 35 | + return \rmdir($dir); |
| 36 | +} |
| 37 | + |
| 38 | +function unlink($file) { |
| 39 | + if (testCaseWillIgnore($file)) { |
| 40 | + return false; |
| 41 | + } |
| 42 | + return \unlink($file); |
| 43 | +} |
| 44 | + |
9 | 45 | namespace OCA\Libresign\Tests\Unit; |
10 | 46 |
|
11 | 47 | use donatj\MockWebServer\MockWebServer; |
@@ -204,11 +240,14 @@ private function getBinariesFromCache(): void { |
204 | 240 | } |
205 | 241 |
|
206 | 242 | private function getFullLiresignAppFolder(): string { |
207 | | - $libresignPath = glob('../../data/appdata_*/libresign'); |
208 | | - if (empty($libresignPath)) { |
209 | | - return ''; |
| 243 | + $path = '../../data/appdata_' . \OC_Util::getInstanceId() . '/libresign'; |
| 244 | + if (!is_dir($path)) { |
| 245 | + mkdir($path, 0777, true); |
| 246 | + $user = fileowner(__FILE__); |
| 247 | + chown($path, $user); |
| 248 | + chgrp($path, $user); |
210 | 249 | } |
211 | | - return realpath(current($libresignPath)); |
| 250 | + return realpath($path); |
212 | 251 | } |
213 | 252 |
|
214 | 253 | private function backupBinaries(): void { |
|
0 commit comments