forked from baron/baron-sso
테넌트 접근 제한 테스트 추가
This commit is contained in:
23
userfront/test/consent_error_routing_test.dart
Normal file
23
userfront/test/consent_error_routing_test.dart
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import 'package:userfront/core/services/auth_proxy_service.dart';
|
||||||
|
import 'package:userfront/features/auth/domain/consent_error_routing.dart';
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
test('tenant_not_allowed consent error routes to dedicated error screen', () {
|
||||||
|
const error = AuthProxyException(
|
||||||
|
errorCode: 'tenant_not_allowed',
|
||||||
|
message: '허용되지 않은 테넌트입니다.',
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(shouldRouteConsentErrorToErrorScreen(error), isTrue);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('generic consent error stays on consent screen', () {
|
||||||
|
const error = AuthProxyException(
|
||||||
|
errorCode: 'forbidden',
|
||||||
|
message: '동의 정보를 가져오지 못했습니다.',
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(shouldRouteConsentErrorToErrorScreen(error), isFalse);
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -10,6 +10,7 @@ Future<void> _pumpErrorScreen(
|
|||||||
String? description,
|
String? description,
|
||||||
bool? isProdOverride,
|
bool? isProdOverride,
|
||||||
Future<Map<String, dynamic>> Function()? sessionProfileLoader,
|
Future<Map<String, dynamic>> Function()? sessionProfileLoader,
|
||||||
|
Map<String, dynamic>? tenantAccessDetails,
|
||||||
}) async {
|
}) async {
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
MaterialApp(
|
MaterialApp(
|
||||||
@@ -18,6 +19,7 @@ Future<void> _pumpErrorScreen(
|
|||||||
description: description,
|
description: description,
|
||||||
isProdOverride: isProdOverride,
|
isProdOverride: isProdOverride,
|
||||||
sessionProfileLoader: sessionProfileLoader,
|
sessionProfileLoader: sessionProfileLoader,
|
||||||
|
tenantAccessDetails: tenantAccessDetails,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -213,20 +215,21 @@ void main() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
final title = tr(
|
final title = tr(
|
||||||
'msg.userfront.error.title',
|
'msg.userfront.error.tenant.page_title',
|
||||||
fallback: '인증 과정에서 오류가 발생했습니다',
|
fallback: '애플리케이션 접근이 제한되었습니다',
|
||||||
);
|
);
|
||||||
final detail = tr(
|
final detail = tr(
|
||||||
'msg.userfront.error.tenant.detail',
|
'msg.userfront.error.tenant.detail',
|
||||||
fallback: '현재 로그인된 계정은 이 애플리케이션에 접근할 수 없습니다.',
|
fallback: '현재 로그인된 계정은 이 애플리케이션에 접근할 수 없습니다.',
|
||||||
);
|
);
|
||||||
final account = tr(
|
final account = tr('msg.userfront.error.tenant.account', fallback: '계정');
|
||||||
'msg.userfront.error.tenant.account',
|
final primaryTenant = tr(
|
||||||
fallback: '계정',
|
'msg.userfront.error.tenant.primary_tenant',
|
||||||
|
fallback: '대표 소속 테넌트',
|
||||||
);
|
);
|
||||||
final tenant = tr(
|
final affiliatedTenants = tr(
|
||||||
'msg.userfront.error.tenant.tenant',
|
'msg.userfront.error.tenant.affiliated_tenants',
|
||||||
fallback: '소속 테넌트',
|
fallback: '전체 소속 테넌트',
|
||||||
);
|
);
|
||||||
final switchAccount = tr(
|
final switchAccount = tr(
|
||||||
'ui.userfront.error.switch_account',
|
'ui.userfront.error.switch_account',
|
||||||
@@ -237,8 +240,36 @@ void main() {
|
|||||||
expect(find.text(detail), findsOneWidget);
|
expect(find.text(detail), findsOneWidget);
|
||||||
expect(find.text(account), findsOneWidget);
|
expect(find.text(account), findsOneWidget);
|
||||||
expect(find.text('employee@example.com'), findsOneWidget);
|
expect(find.text('employee@example.com'), findsOneWidget);
|
||||||
expect(find.text(tenant), findsOneWidget);
|
expect(find.text(primaryTenant), findsOneWidget);
|
||||||
expect(find.text('Baron HQ'), findsOneWidget);
|
expect(find.text(affiliatedTenants), findsOneWidget);
|
||||||
|
expect(find.text('Baron HQ'), findsNWidgets(2));
|
||||||
expect(find.text(switchAccount), findsOneWidget);
|
expect(find.text(switchAccount), findsOneWidget);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
testWidgets('tenant_not_allowed는 details를 우선 사용해 계정과 테넌트 정보를 노출한다', (
|
||||||
|
WidgetTester tester,
|
||||||
|
) async {
|
||||||
|
await _pumpErrorScreen(
|
||||||
|
tester,
|
||||||
|
errorCode: 'tenant_not_allowed',
|
||||||
|
isProdOverride: true,
|
||||||
|
tenantAccessDetails: {
|
||||||
|
'account': {'email': 'dyddus1210@gmail.com'},
|
||||||
|
'current_tenant': {'name': 'test1 company', 'slug': 'test1-company'},
|
||||||
|
'affiliated_tenants': [
|
||||||
|
{'name': 'test1 company', 'slug': 'test1-company'},
|
||||||
|
{'name': 'test2 company', 'slug': 'test-company'},
|
||||||
|
],
|
||||||
|
'allowed_tenants': [
|
||||||
|
{'name': 'test4', 'slug': 'test4'},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(find.text('dyddus1210@gmail.com'), findsOneWidget);
|
||||||
|
expect(find.text('test1 company'), findsOneWidget);
|
||||||
|
expect(find.text('test1 company, test2 company'), findsOneWidget);
|
||||||
|
expect(find.text('test4'), findsOneWidget);
|
||||||
|
expect(find.text('알 수 없음'), findsNothing);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user