forked from baron/baron-sso
36 lines
1.1 KiB
Dart
36 lines
1.1 KiB
Dart
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:userfront/features/dashboard/domain/session_time_resolver.dart';
|
|
import 'package:userfront/features/profile/data/models/user_profile_model.dart';
|
|
|
|
void main() {
|
|
test('JWT에 iat가 있으면 세션 시각으로 사용한다', () {
|
|
const token = 'eyJhbGciOiJub25lIn0.eyJpYXQiOjE3MTEyMDc4MDB9.signature';
|
|
|
|
final issuedAt = resolveDashboardSessionIssuedAt(token: token);
|
|
|
|
expect(issuedAt, isNotNull);
|
|
expect(issuedAt!.toUtc().toIso8601String(), '2024-03-23T15:30:00.000Z');
|
|
});
|
|
|
|
test('cookie mode에서는 profile의 sessionAuthenticatedAt으로 복원한다', () {
|
|
final profile = UserProfile(
|
|
id: 'user-1',
|
|
email: 'qa@example.com',
|
|
name: 'QA User',
|
|
phone: '01012345678',
|
|
department: 'Platform',
|
|
affiliationType: 'GENERAL',
|
|
companyCode: '',
|
|
sessionAuthenticatedAt: '2026-03-23T15:30:00Z',
|
|
);
|
|
|
|
final issuedAt = resolveDashboardSessionIssuedAt(
|
|
token: null,
|
|
profile: profile,
|
|
);
|
|
|
|
expect(issuedAt, isNotNull);
|
|
expect(issuedAt!.toUtc().toIso8601String(), '2026-03-23T15:30:00.000Z');
|
|
});
|
|
}
|