Files
plezy/test/services/jellyfin_auth_header_test.dart
T
edde746 d80a1ed15a feat: report real device identity to media servers
Resolve platform, hardware model, and friendly device name once via a
shared DeviceIdentityService and send them to both backends: Plex gets
a real X-Plex-Platform plus X-Plex-Device/X-Plex-Device-Name (shown as
Player in dashboards/Tautulli), Jellyfin gets the device name in the
MediaBrowser auth header. Transcode and live-TV decision requests keep
their pinned platform names, which Plex validates server-side.

close #1270
2026-07-05 01:22:20 +02:00

45 lines
1.3 KiB
Dart

import 'package:flutter_test/flutter_test.dart';
import 'package:plezy/services/jellyfin_auth_header.dart';
void main() {
group('buildJellyfinAuthHeader', () {
test('formats the SDK-style MediaBrowser header', () {
final header = buildJellyfinAuthHeader(
clientName: 'Plezy',
clientVersion: '1.2.3',
deviceName: 'Living Room TV',
deviceId: 'dev-1',
accessToken: 'tok',
);
expect(
header,
'MediaBrowser Client="Plezy", Device="Living Room TV", DeviceId="dev-1", Version="1.2.3", Token="tok"',
);
});
test('omits Token when access token is null or empty', () {
for (final token in [null, '']) {
final header = buildJellyfinAuthHeader(
clientName: 'Plezy',
clientVersion: '1.2.3',
deviceName: 'Plezy',
deviceId: 'dev-1',
accessToken: token,
);
expect(header, isNot(contains('Token=')));
}
});
test('strips embedded quotes so a device name cannot corrupt the header', () {
final header = buildJellyfinAuthHeader(
clientName: 'Plezy',
clientVersion: '1.2.3',
deviceName: 'My "cool" TV',
deviceId: 'dev-1',
accessToken: 'tok',
);
expect(header, contains('Device="My cool TV"'));
});
});
}