Respect imported nzb category

This commit is contained in:
DariusIII
2026-08-03 23:49:54 +02:00
parent d09b96b525
commit de9007c9a5
4 changed files with 263 additions and 19 deletions
+30 -1
View File
@@ -5,8 +5,8 @@ declare(strict_types=1);
namespace Tests\Unit;
use App\Services\Nzb\NzbService;
use PHPUnit\Framework\TestCase;
use ReflectionClass;
use Tests\TestCase;
final class NzbServicePathResolutionTest extends TestCase
{
@@ -120,6 +120,35 @@ final class NzbServicePathResolutionTest extends TestCase
}
}
public function test_build_nzb_path_creates_group_writable_setgid_directories_despite_umask(): void
{
$tempDir = sys_get_temp_dir().'/nzb-path-permissions-'.uniqid('', true);
$basePath = $tempDir.'/';
mkdir($basePath, 0775, true);
$previousUmask = umask(0022);
try {
$service = $this->makeServiceWithoutConstructor();
\Closure::bind(
function (string $path): void {
$this->siteNzbPath = $path;
},
$service,
NzbService::class
)($basePath);
$path = $service->buildNzbPath('4aabfe07-daff-4d28-9d1d-d2a4ab7b6511', 4, true);
$this->assertSame($basePath.'4/a/a/b/', $path);
foreach ([$basePath.'4', $basePath.'4/a', $basePath.'4/a/a', $basePath.'4/a/a/b'] as $directory) {
$this->assertSame(02775, fileperms($directory) & 07777);
}
} finally {
umask($previousUmask);
$this->deleteDirectory($tempDir);
}
}
private function makeServiceWithoutConstructor(): NzbService
{
return (new ReflectionClass(NzbService::class))->newInstanceWithoutConstructor();