Send the sign-in with native video playback
The native video player requests media itself, without the session cookie the app's file fetches send, so a video shown with show_file (or opened from Files) behind the web login was refused in the phone and Mac apps. Pass ServerSession.headersFor(uri) as the player's HTTP headers.
This commit is contained in:
@@ -2,6 +2,8 @@ import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:pipelines_app/core/session/server_session.dart';
|
||||
import 'package:pipelines_app/features/artifacts/domain/artifact_preview.dart';
|
||||
import 'package:pipelines_app/features/artifacts/domain/artifact_url.dart';
|
||||
import 'package:pipelines_app/features/artifacts/ui/artifact_video_player.dart';
|
||||
@@ -42,6 +44,34 @@ Widget _body(ArtifactVideoControllerFactory factory) => MaterialApp(
|
||||
);
|
||||
|
||||
void main() {
|
||||
test(
|
||||
'the default player sends the sign-in only to the signed-in server',
|
||||
() async {
|
||||
SharedPreferences.setMockInitialValues({
|
||||
'pipelines.session.v2.${Uri.encodeComponent('a')}.cookie': 'session=a',
|
||||
});
|
||||
await ServerSession.load();
|
||||
await ServerSession.activateServer(
|
||||
id: 'a',
|
||||
endpoints: [Uri.parse('wss://primary.example/connect')],
|
||||
migrateLegacy: false,
|
||||
);
|
||||
addTearDown(ServerSession.clearSelection);
|
||||
|
||||
final own = defaultArtifactVideoController(
|
||||
Uri.parse('https://primary.example/files/view?path=/a.mp4'),
|
||||
);
|
||||
addTearDown(own.dispose);
|
||||
expect(own.httpHeaders, {'Cookie': 'session=a'});
|
||||
|
||||
final other = defaultArtifactVideoController(
|
||||
Uri.parse('https://external.example/a.mp4'),
|
||||
);
|
||||
addTearDown(other.dispose);
|
||||
expect(other.httpHeaders, isEmpty);
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets('a video preview streams its resolved url and never autoplays', (
|
||||
tester,
|
||||
) async {
|
||||
|
||||
Reference in New Issue
Block a user