mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-11 11:06:16 -08:00
test(stalker): replay catalog and playback auth
This commit is contained in:
1 parent
829550e2c9
commit
85bee2dbb4
5 files changed
+920
-10
No files matched your search
@@ -59,6 +59,181 @@ test.describe('Electron Stalker authenticated sessions', () => {
|
||||
});
|
||||
});
|
||||
|
||||
test('@stalker @electron keeps authenticated catalog and playback identity in main', async ({
|
||||
dataDir,
|
||||
}) => {
|
||||
const replay = await withStalkerReplayRun(
|
||||
'e2e/full-session-catalog-playback',
|
||||
async (run) => {
|
||||
const app = await launchElectronApp(dataDir);
|
||||
|
||||
try {
|
||||
const { ready } = await openStatus2Session(
|
||||
app.mainWindow,
|
||||
run,
|
||||
'e2e-catalog-playback'
|
||||
);
|
||||
if (
|
||||
ready.kind !== 'ready' ||
|
||||
ready.recipe !== 'full-session' ||
|
||||
ready.connectionMode !== 'provisional'
|
||||
) {
|
||||
throw new Error(
|
||||
`expected-full-session:${JSON.stringify(ready)}`
|
||||
);
|
||||
}
|
||||
const committed = await app.mainWindow.evaluate(
|
||||
async ({ attemptRef }) => {
|
||||
const control =
|
||||
window.electron?.stalkerSessionControl;
|
||||
if (!control) {
|
||||
throw new Error(
|
||||
'stalker-session-control-unavailable'
|
||||
);
|
||||
}
|
||||
|
||||
return control({
|
||||
action: 'commit',
|
||||
attemptRef,
|
||||
});
|
||||
},
|
||||
{ attemptRef: ready.attemptRef }
|
||||
);
|
||||
expect(committed).toMatchObject({
|
||||
action: 'commit',
|
||||
kind: 'success',
|
||||
});
|
||||
|
||||
const catalog = await app.mainWindow.evaluate(
|
||||
async ({ leaseRef }) => {
|
||||
const request =
|
||||
window.electron?.stalkerSessionRequest;
|
||||
if (!request) {
|
||||
throw new Error(
|
||||
'stalker-session-request-unavailable'
|
||||
);
|
||||
}
|
||||
|
||||
return request({
|
||||
leaseRef,
|
||||
operation: 'get-ordered-list',
|
||||
parameters: {
|
||||
category: '*',
|
||||
contentType: 'itv',
|
||||
page: 1,
|
||||
},
|
||||
});
|
||||
},
|
||||
{ leaseRef: ready.leaseRef }
|
||||
);
|
||||
if (
|
||||
catalog.kind !== 'success' ||
|
||||
catalog.operation !== 'get-ordered-list'
|
||||
) {
|
||||
throw new Error(
|
||||
`expected-catalog-success:${JSON.stringify(catalog)}`
|
||||
);
|
||||
}
|
||||
expect(catalog).toMatchObject({
|
||||
kind: 'success',
|
||||
operation: 'get-ordered-list',
|
||||
payload: {
|
||||
hasMore: false,
|
||||
items: [
|
||||
{
|
||||
contentType: 'itv',
|
||||
id: 'channel-1',
|
||||
title: 'Synthetic Channel',
|
||||
},
|
||||
],
|
||||
page: 1,
|
||||
pageSize: 1,
|
||||
total: 1,
|
||||
totalPages: 1,
|
||||
},
|
||||
});
|
||||
const command = catalog.payload.items[0]?.command;
|
||||
if (!command) {
|
||||
throw new Error('expected-catalog-command');
|
||||
}
|
||||
|
||||
const link = await app.mainWindow.evaluate(
|
||||
async ({ command, leaseRef }) => {
|
||||
const request =
|
||||
window.electron?.stalkerSessionRequest;
|
||||
if (!request) {
|
||||
throw new Error(
|
||||
'stalker-session-request-unavailable'
|
||||
);
|
||||
}
|
||||
|
||||
return request({
|
||||
leaseRef,
|
||||
operation: 'create-link',
|
||||
parameters: {
|
||||
command,
|
||||
contentType: 'itv',
|
||||
},
|
||||
});
|
||||
},
|
||||
{
|
||||
command,
|
||||
leaseRef: ready.leaseRef,
|
||||
}
|
||||
);
|
||||
expect(link).toMatchObject({
|
||||
kind: 'success',
|
||||
operation: 'create-link',
|
||||
payload: {
|
||||
streamUrl: new URL(
|
||||
'/stream/ready.m3u8',
|
||||
requiredOrigin(run, 'portal')
|
||||
).toString(),
|
||||
},
|
||||
});
|
||||
if (
|
||||
link.kind !== 'success' ||
|
||||
link.operation !== 'create-link'
|
||||
) {
|
||||
throw new Error(
|
||||
`expected-create-link-success:${JSON.stringify(link)}`
|
||||
);
|
||||
}
|
||||
expect(Object.keys(link.payload).sort()).toEqual([
|
||||
'playbackContextRef',
|
||||
'streamUrl',
|
||||
]);
|
||||
expect(link.payload.playbackContextRef).toEqual(
|
||||
expect.any(String)
|
||||
);
|
||||
expect(link.payload.playbackContextRef).not.toHaveLength(0);
|
||||
expect(
|
||||
JSON.stringify({ catalog, committed, link, ready })
|
||||
).not.toMatch(/authorization|bearer|cookie|token/i);
|
||||
} finally {
|
||||
await closeElectronApp(app);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
expect(replay.finalization).toMatchObject({
|
||||
ledger: {
|
||||
mismatchCounts: {},
|
||||
operationCounts: {
|
||||
'anonymous-probe': 1,
|
||||
'catalog-page': 1,
|
||||
'create-link': 1,
|
||||
'do-auth': 1,
|
||||
handshake: 1,
|
||||
'profile-first': 1,
|
||||
'profile-second': 1,
|
||||
},
|
||||
terminalState: 'complete',
|
||||
},
|
||||
ok: true,
|
||||
});
|
||||
});
|
||||
|
||||
test('@stalker @electron keeps concurrent authenticated attempts isolated by replay run', async ({
|
||||
dataDir,
|
||||
}) => {
|
||||
@@ -160,7 +335,9 @@ async function openStatus2Session(
|
||||
}
|
||||
);
|
||||
if (challenge.kind !== 'credentials-required') {
|
||||
throw new Error('expected-credentials-challenge');
|
||||
throw new Error(
|
||||
`expected-credentials-challenge:${JSON.stringify(challenge)}`
|
||||
);
|
||||
}
|
||||
|
||||
const ready = await page.evaluate(
|
||||
|
||||
Reference in new issue
Block a user