Batch 5: remove silent desktop gateway fallback
This commit is contained in:
parent
9542dc3768
commit
f16a07cc6c
@ -301,7 +301,6 @@ extension AppControllerDesktopSettingsRuntime on AppController {
|
||||
final runtime = GatewayRuntime(
|
||||
store: temporaryStore,
|
||||
identityStore: DeviceIdentityStore(temporaryStore),
|
||||
sessionClient: GoGatewayRuntimeDesktopClient(),
|
||||
);
|
||||
await runtime.initialize();
|
||||
try {
|
||||
|
||||
@ -26,10 +26,13 @@ class GatewayRuntime extends ChangeNotifier with GatewayRuntimeHelpersInternal {
|
||||
required SecureConfigStore store,
|
||||
required DeviceIdentityStore identityStore,
|
||||
GatewayRuntimeSessionClient? sessionClient,
|
||||
bool allowDirectSocketFallbackOnSessionClientFailure = false,
|
||||
String runtimeId = '',
|
||||
}) : storeInternal = store,
|
||||
identityStoreInternal = identityStore,
|
||||
sessionClientInternal = sessionClient,
|
||||
allowDirectSocketFallbackOnSessionClientFailureInternal =
|
||||
allowDirectSocketFallbackOnSessionClientFailure,
|
||||
runtimeIdInternal = runtimeId.trim().isNotEmpty
|
||||
? runtimeId.trim()
|
||||
: randomIdInternal();
|
||||
@ -37,6 +40,7 @@ class GatewayRuntime extends ChangeNotifier with GatewayRuntimeHelpersInternal {
|
||||
final SecureConfigStore storeInternal;
|
||||
final DeviceIdentityStore identityStoreInternal;
|
||||
final GatewayRuntimeSessionClient? sessionClientInternal;
|
||||
final bool allowDirectSocketFallbackOnSessionClientFailureInternal;
|
||||
final String runtimeIdInternal;
|
||||
final StreamController<GatewayPushEvent> eventsInternal =
|
||||
StreamController<GatewayPushEvent>.broadcast();
|
||||
@ -292,7 +296,8 @@ class GatewayRuntime extends ChangeNotifier with GatewayRuntimeHelpersInternal {
|
||||
notifyListeners();
|
||||
return;
|
||||
} on GatewayRuntimeException catch (error) {
|
||||
if (_shouldFallbackToDirectRuntimeInternal(error)) {
|
||||
if (allowDirectSocketFallbackOnSessionClientFailureInternal &&
|
||||
_shouldFallbackToDirectRuntimeInternal(error)) {
|
||||
appendLogInternal(
|
||||
this,
|
||||
'warn',
|
||||
|
||||
@ -225,7 +225,7 @@ void main() {
|
||||
);
|
||||
|
||||
test(
|
||||
'GatewayRuntime falls back to direct websocket when go-core bridge is unavailable',
|
||||
'GatewayRuntime does not silently fall back to direct websocket when go-core bridge is unavailable',
|
||||
() async {
|
||||
SharedPreferences.setMockInitialValues(<String, Object>{});
|
||||
final store = createIsolatedTestStore();
|
||||
@ -243,6 +243,47 @@ void main() {
|
||||
addTearDown(runtime.dispose);
|
||||
addTearDown(server.close);
|
||||
|
||||
await runtime.initialize();
|
||||
await expectLater(
|
||||
() => runtime.connectProfile(
|
||||
GatewayConnectionProfile.defaults().copyWith(
|
||||
mode: RuntimeConnectionMode.local,
|
||||
host: '127.0.0.1',
|
||||
port: server.port,
|
||||
tls: false,
|
||||
useSetupCode: false,
|
||||
),
|
||||
authTokenOverride: 'shared-token-from-form',
|
||||
),
|
||||
throwsA(isA<GatewayRuntimeException>()),
|
||||
);
|
||||
|
||||
expect(server.connectAuth, isNull);
|
||||
expect(runtime.snapshot.status, RuntimeConnectionStatus.error);
|
||||
expect(runtime.snapshot.lastErrorCode, 'GO_GATEWAY_RUNTIME_ENDPOINT_MISSING');
|
||||
},
|
||||
);
|
||||
|
||||
test(
|
||||
'GatewayRuntime can explicitly fall back to direct websocket when enabled',
|
||||
() async {
|
||||
SharedPreferences.setMockInitialValues(<String, Object>{});
|
||||
final store = createIsolatedTestStore();
|
||||
final runtime = GatewayRuntime(
|
||||
store: store,
|
||||
identityStore: DeviceIdentityStore(store),
|
||||
sessionClient: _FakeGatewayRuntimeSessionClient(
|
||||
connectError: GatewayRuntimeException(
|
||||
'go bridge unavailable',
|
||||
code: 'GO_GATEWAY_RUNTIME_ENDPOINT_MISSING',
|
||||
),
|
||||
),
|
||||
allowDirectSocketFallbackOnSessionClientFailure: true,
|
||||
);
|
||||
final server = await FakeGatewayRuntimeServerInternal.start();
|
||||
addTearDown(runtime.dispose);
|
||||
addTearDown(server.close);
|
||||
|
||||
await runtime.initialize();
|
||||
await runtime.connectProfile(
|
||||
GatewayConnectionProfile.defaults().copyWith(
|
||||
|
||||
Loading…
Reference in New Issue
Block a user