mirror of
https://github.com/Vateron-Media/XC_VM.git
synced 2026-10-03 12:02:29 +02:00
Port of Rosmi720/XC_VM@0d39e9bd. A mode-dropping deploy could leave core scripts non-executable and a php-fpm pool config missing, and an undefined HOST constant broke the unique-header cookie domain: - StartupCommand restores the executable bit on service/update/redis-server/ daemons.sh and regenerates any missing php-fpm pool config (1..4.conf) from the template on boot. - StreamAuthMiddleware derives the cookie domain through a HOST-guarded helper, so an undefined/empty host or a bare IP yields no domain instead of throwing or emitting a broken "." domain. Adapted to this tree: the added boot blocks were split into covered helpers (ensureExecutableScripts / ensurePhpFpmPoolConfigs / uniqueHeaderDomain) with unit tests to stay within the complexity ceiling, the sudo chown now runs only as root, and comments were translated to English.
41 lines
1.2 KiB
PHP
41 lines
1.2 KiB
PHP
<?php
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
use XcVm\Streaming\Auth\StreamAuthMiddleware;
|
|
|
|
/**
|
|
* Coverage for StreamAuthMiddleware::uniqueHeaderDomain — the HOST-guarded
|
|
* cookie-domain resolver. It must yield a dotted domain for a host name, and
|
|
* null for an undefined/empty host or a bare IP (a dot-prefixed IP is not a
|
|
* valid cookie domain and previously produced a broken "." domain).
|
|
*/
|
|
final class StreamAuthMiddlewareHostTest extends TestCase {
|
|
|
|
private function domain(): ?string {
|
|
$rM = new ReflectionMethod(StreamAuthMiddleware::class, 'uniqueHeaderDomain');
|
|
$rM->setAccessible(true);
|
|
return $rM->invoke(null);
|
|
}
|
|
|
|
protected function setUp(): void {
|
|
if (defined('HOST')) {
|
|
$this->markTestSkipped('HOST constant already defined; $_SERVER path not reachable');
|
|
}
|
|
}
|
|
|
|
public function testHostNameYieldsDottedDomain(): void {
|
|
$_SERVER['HTTP_HOST'] = 'cdn.example.com';
|
|
$this->assertSame('.cdn.example.com', $this->domain());
|
|
}
|
|
|
|
public function testBareIpYieldsNull(): void {
|
|
$_SERVER['HTTP_HOST'] = '203.0.113.9';
|
|
$this->assertNull($this->domain());
|
|
}
|
|
|
|
public function testEmptyHostYieldsNull(): void {
|
|
$_SERVER['HTTP_HOST'] = '';
|
|
$this->assertNull($this->domain());
|
|
}
|
|
}
|