forked from baron/baron-sso
#269 진행. 리다이렉트 등 파라미터 전체 전달
This commit is contained in:
@@ -1,7 +1,16 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:userfront/core/i18n/locale_registry.dart';
|
||||
import 'package:userfront/core/i18n/locale_utils.dart';
|
||||
|
||||
void main() {
|
||||
setUp(() {
|
||||
LocaleRegistry.setSupportedLocaleCodesForTest(['en', 'ko']);
|
||||
});
|
||||
|
||||
tearDown(() {
|
||||
LocaleRegistry.resetForTest();
|
||||
});
|
||||
|
||||
group('locale_utils', () {
|
||||
test('normalizeLocaleCode handles supported locales', () {
|
||||
expect(normalizeLocaleCode('ko'), 'ko');
|
||||
@@ -50,7 +59,25 @@ void main() {
|
||||
final uri = Uri.parse('/signin?redirect_uri=https://example.com');
|
||||
expect(
|
||||
buildLocalizedPath('ko', uri),
|
||||
'/ko/signin?redirect_uri=https%3A%2F%2Fexample.com',
|
||||
'/ko/signin?redirect_uri=https://example.com',
|
||||
);
|
||||
});
|
||||
|
||||
test('buildLocalizedPath preserves raw query order and duplicates', () {
|
||||
final uri = Uri.parse(
|
||||
'/signin?a=1&a=2&redirect_uri=https%3A%2F%2Fexample.com%2Fcb%3Fx%3D1%26y%3D2',
|
||||
);
|
||||
expect(
|
||||
buildLocalizedPath('ko', uri),
|
||||
'/ko/signin?a=1&a=2&redirect_uri=https%3A%2F%2Fexample.com%2Fcb%3Fx%3D1%26y%3D2',
|
||||
);
|
||||
});
|
||||
|
||||
test('buildLocalizedPath preserves fragment', () {
|
||||
final uri = Uri.parse('/signin?notice=qr_login_required#auth');
|
||||
expect(
|
||||
buildLocalizedPath('ko', uri),
|
||||
'/ko/signin?notice=qr_login_required#auth',
|
||||
);
|
||||
});
|
||||
|
||||
@@ -59,8 +86,28 @@ void main() {
|
||||
expect(buildLocalizedPath('ko', Uri.parse('/en/profile')), '/ko/profile');
|
||||
});
|
||||
|
||||
test('buildLocalizedPath drops unknown 2-letter prefix', () {
|
||||
expect(buildLocalizedPath('ko', Uri.parse('/zz/signin')), '/ko/signin');
|
||||
test('buildLocalizedPath keeps unknown 2-letter prefix as path', () {
|
||||
expect(
|
||||
buildLocalizedPath('ko', Uri.parse('/zz/signin')),
|
||||
'/ko/zz/signin',
|
||||
);
|
||||
});
|
||||
|
||||
test('buildSigninRedirectPath keeps path without query', () {
|
||||
expect(
|
||||
buildSigninRedirectPath('ko', Uri.parse('/ko/profile')),
|
||||
'/ko/signin',
|
||||
);
|
||||
});
|
||||
|
||||
test('buildSigninRedirectPath preserves full raw query', () {
|
||||
final uri = Uri.parse(
|
||||
'/ko/profile?a=1&a=2&redirect_uri=https%3A%2F%2Fexample.com%2Fcb%3Fx%3D1%26y%3D2¬ice=qr_login_required',
|
||||
);
|
||||
expect(
|
||||
buildSigninRedirectPath('ko', uri),
|
||||
'/ko/signin?a=1&a=2&redirect_uri=https%3A%2F%2Fexample.com%2Fcb%3Fx%3D1%26y%3D2¬ice=qr_login_required',
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user