Files
SpotiFLAC-Mobile/test/extension_session_callback_test.dart
T
zarzet 51d3459426 chore(branding): drop remaining SpotiFLAC references
Remove the original SpotiFLAC creator and PC source links from About,
point docs links and podspec homepages at mornye.com, drop stale
SpotiFLAC build artifact cleanup, and rename incidental test data.
Legacy compatibility (backup magic, lyrics provider id, extension
suffix, signed session protocol) is kept so old data still loads.
2026-10-20 12:27:29 +07:00

41 lines
1.2 KiB
Dart

import 'package:flutter_test/flutter_test.dart';
import 'package:mornye/utils/extension_session_callback.dart';
void main() {
test('parses a signed-session callback without treating state as an id', () {
final callback = parseExtensionSessionGrantCallback(
'mornye://session-grant?cb_version=v2grant&state=nonce_123&grant=gr_456',
);
expect(callback, isNotNull);
expect(callback!.state, 'nonce_123');
expect(callback.grant, 'gr_456');
});
test('extracts the expected state from a nested challenge callback', () {
final callback = Uri(
scheme: 'mornye',
host: 'session-grant',
queryParameters: const {'cb_version': 'v2grant', 'state': 'nonce_123'},
);
final challenge = Uri.https('api.zarz.moe', '/v2/challenge', {
'cb': callback.toString(),
});
expect(extensionCallbackStateFromVerificationUri(challenge), 'nonce_123');
});
test('rejects callbacks without both a grant and state', () {
expect(
parseExtensionSessionGrantCallback('mornye://session-grant?grant=gr_456'),
isNull,
);
expect(
parseExtensionSessionGrantCallback(
'mornye://session-grant?state=nonce_123',
),
isNull,
);
});
}