fix: count active HLS playback renditions
This commit is contained in:
@@ -79,6 +79,79 @@ final class SessionRepositoryTest extends TemporaryDirectoryTestCase
|
||||
);
|
||||
}
|
||||
|
||||
public function testDuplicateUrlsForTheSameRenditionUseOnePlaybackSlot(): void
|
||||
{
|
||||
$repository = $this->repository(maxSessions: 1);
|
||||
$principalHash = str_repeat('c', 64);
|
||||
$cacheKey = str_repeat('b', 64);
|
||||
|
||||
$first = $repository->create(
|
||||
$this->temporaryDirectory,
|
||||
7,
|
||||
'abcdef123456abcdef123456',
|
||||
$cacheKey,
|
||||
$principalHash,
|
||||
1000,
|
||||
);
|
||||
$second = $repository->create(
|
||||
$this->temporaryDirectory,
|
||||
7,
|
||||
'abcdef123456abcdef123456',
|
||||
$cacheKey,
|
||||
$principalHash,
|
||||
1001,
|
||||
);
|
||||
|
||||
self::assertNotSame($first['token'], $second['token']);
|
||||
self::assertSame(1, $repository->countActiveForPrincipal($this->temporaryDirectory, $principalHash, 1001));
|
||||
}
|
||||
|
||||
public function testInactiveSessionsDoNotConsumePlaybackSlots(): void
|
||||
{
|
||||
$config = new Config(sessionTtl: 1800, cacheTtl: 1800, maxSessionsPerPrincipal: 1);
|
||||
$repository = new SessionRepository($config, new CachePaths($config));
|
||||
$principalHash = str_repeat('c', 64);
|
||||
$repository->create(
|
||||
$this->temporaryDirectory,
|
||||
7,
|
||||
'abcdef123456abcdef123456',
|
||||
str_repeat('b', 64),
|
||||
$principalHash,
|
||||
1000,
|
||||
);
|
||||
|
||||
self::assertSame(0, $repository->countActiveForPrincipal($this->temporaryDirectory, $principalHash, 1091));
|
||||
$created = $repository->create(
|
||||
$this->temporaryDirectory,
|
||||
7,
|
||||
'abcdef123456abcdef123457',
|
||||
str_repeat('d', 64),
|
||||
$principalHash,
|
||||
1091,
|
||||
);
|
||||
self::assertTrue(OpaqueToken::isValid($created['token']));
|
||||
}
|
||||
|
||||
public function testAuthorizedAssetAccessKeepsAPlaybackSlotActive(): void
|
||||
{
|
||||
$config = new Config(sessionTtl: 1800, cacheTtl: 1800, maxSessionsPerPrincipal: 1);
|
||||
$repository = new SessionRepository($config, new CachePaths($config));
|
||||
$principalHash = str_repeat('c', 64);
|
||||
$created = $repository->create(
|
||||
$this->temporaryDirectory,
|
||||
7,
|
||||
'abcdef123456abcdef123456',
|
||||
str_repeat('b', 64),
|
||||
$principalHash,
|
||||
1000,
|
||||
);
|
||||
|
||||
$repository->markAccessed($this->temporaryDirectory, $created['token'], 1080);
|
||||
|
||||
self::assertSame(1, $repository->countActiveForPrincipal($this->temporaryDirectory, $principalHash, 1169));
|
||||
self::assertSame(0, $repository->countActiveForPrincipal($this->temporaryDirectory, $principalHash, 1171));
|
||||
}
|
||||
|
||||
public function testParallelCreatorsCannotExceedSessionLimit(): void
|
||||
{
|
||||
$worker = $this->temporaryDirectory . '/session-worker.php';
|
||||
|
||||
Reference in New Issue
Block a user