fix: keep bridge token usable after sync block
This commit is contained in:
parent
20257f392e
commit
0358a4aaac
@ -1207,10 +1207,7 @@ extension AppControllerDesktopRuntimeHelpers on AppController {
|
||||
}
|
||||
|
||||
Future<String?> _resolveManagedBridgeAuthTokenInternal() async {
|
||||
final accountSyncState = settingsControllerInternal.accountSyncState;
|
||||
if (settingsControllerInternal.accountSignedIn &&
|
||||
accountSyncState?.syncState.trim().toLowerCase() == 'ready' &&
|
||||
accountSyncState?.tokenConfigured.bridge == true) {
|
||||
if (settingsControllerInternal.accountSignedIn) {
|
||||
final bridgeToken = (await storeInternal.loadAccountManagedSecret(
|
||||
target: kAccountManagedSecretTargetBridgeAuthToken,
|
||||
))?.trim();
|
||||
|
||||
@ -82,6 +82,71 @@ void main() {
|
||||
},
|
||||
);
|
||||
|
||||
test(
|
||||
'keeps using managed bridge token after the account sync state is blocked',
|
||||
() async {
|
||||
final storeRoot = await Directory.systemTemp.createTemp(
|
||||
'xworkmate-account-sync-blocked-token-',
|
||||
);
|
||||
addTearDown(() async {
|
||||
if (await storeRoot.exists()) {
|
||||
await storeRoot.delete(recursive: true);
|
||||
}
|
||||
});
|
||||
|
||||
final store = SecureConfigStore(
|
||||
secretRootPathResolver: () async => '${storeRoot.path}/secrets',
|
||||
appDataRootPathResolver: () async => '${storeRoot.path}/app-data',
|
||||
supportRootPathResolver: () async => '${storeRoot.path}/support',
|
||||
enableSecureStorage: false,
|
||||
);
|
||||
await store.initialize();
|
||||
await store.saveSettingsSnapshot(
|
||||
SettingsSnapshot.defaults().copyWith(
|
||||
accountBaseUrl: 'https://accounts.svc.plus',
|
||||
),
|
||||
);
|
||||
await store.saveAccountSessionToken('session-token');
|
||||
await store.saveAccountSessionSummary(
|
||||
const AccountSessionSummary(
|
||||
userId: 'user-1',
|
||||
email: 'review@svc.plus',
|
||||
name: 'Review User',
|
||||
role: 'reviewer',
|
||||
mfaEnabled: true,
|
||||
),
|
||||
);
|
||||
await store.saveAccountManagedSecret(
|
||||
target: kAccountManagedSecretTargetBridgeAuthToken,
|
||||
value: 'managed-token',
|
||||
);
|
||||
await store.saveAccountSyncState(
|
||||
AccountSyncState.defaults().copyWith(
|
||||
syncState: 'blocked',
|
||||
syncMessage: 'Bridge token expired or rejected.',
|
||||
tokenConfigured: const AccountTokenConfigured(
|
||||
bridge: true,
|
||||
vault: false,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
final controller = AppController(
|
||||
store: store,
|
||||
environmentOverride: const <String, String>{},
|
||||
);
|
||||
addTearDown(controller.dispose);
|
||||
await controller.settingsControllerInternal.initialize();
|
||||
|
||||
final token = await controller.settingsControllerInternal
|
||||
.loadEffectiveGatewayToken(
|
||||
profileIndex: kGatewayRemoteProfileIndex,
|
||||
);
|
||||
|
||||
expect(token, 'managed-token');
|
||||
},
|
||||
);
|
||||
|
||||
test(
|
||||
'updates in-memory blocked state when bridge authorization is unavailable',
|
||||
() async {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user