Paginate tag (and ASC) lists via GQL with integrity retry; mint follow integrity from a WebView because Dio /integrity tokens are bad_bot. Co-authored-by: Cursor <cursoragent@cursor.com>
42 lines
1.2 KiB
Dart
42 lines
1.2 KiB
Dart
import 'dart:convert';
|
|
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:frosty/apis/twitch_integrity.dart';
|
|
|
|
String _tokenFor(Map<String, Object?> payload) {
|
|
final encoded = base64Url.encode(utf8.encode(jsonEncode(payload)));
|
|
return 'v4.public.$encoded.fakesig';
|
|
}
|
|
|
|
void main() {
|
|
group('TwitchIntegrity', () {
|
|
test('detects is_bad_bot string flag', () {
|
|
final token = _tokenFor({
|
|
'client_id': 'kimne78kx3ncx6brgo4mv6wki5h1ko',
|
|
'device_id': 'abc123',
|
|
'is_bad_bot': 'true',
|
|
'exp': '2099-01-01T00:00:00Z',
|
|
});
|
|
|
|
expect(TwitchIntegrity.isBadBot(token), isTrue);
|
|
expect(TwitchIntegrity.deviceId(token), 'abc123');
|
|
expect(TwitchIntegrity.expirationMs(token), isNotNull);
|
|
});
|
|
|
|
test('detects is_bad_bot bool flag', () {
|
|
final token = _tokenFor({
|
|
'is_bad_bot': true,
|
|
'device_id': 'dev',
|
|
});
|
|
expect(TwitchIntegrity.isBadBot(token), isTrue);
|
|
});
|
|
|
|
test('returns false when not flagged', () {
|
|
final token = _tokenFor({
|
|
'is_bad_bot': 'false',
|
|
'device_id': 'dev',
|
|
});
|
|
expect(TwitchIntegrity.isBadBot(token), isFalse);
|
|
});
|
|
});
|
|
}
|