-
Notifications
You must be signed in to change notification settings - Fork 392
/
Copy pathMockTunnelInteractor.swift
80 lines (59 loc) · 2.18 KB
/
MockTunnelInteractor.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
//
// MockTunnelInteractor.swift
// MullvadVPNTests
//
// Created by Andrew Bulhak on 2024-02-02.
// Copyright © 2024 Mullvad VPN AB. All rights reserved.
//
import Foundation
import MullvadSettings
@testable import MullvadVPN
import PacketTunnelCore
// this is still very minimal, and will be fleshed out as needed.
class MockTunnelInteractor: TunnelInteractor {
var isConfigurationLoaded: Bool
var settings: MullvadSettings.LatestTunnelSettings
var deviceState: MullvadSettings.DeviceState
var onUpdateTunnelStatus: ((TunnelStatus) -> Void)?
var tunnel: (any TunnelProtocol)?
init(
isConfigurationLoaded: Bool,
settings: MullvadSettings.LatestTunnelSettings,
deviceState: MullvadSettings.DeviceState,
onUpdateTunnelStatus: ((TunnelStatus) -> Void)? = nil
) {
self.isConfigurationLoaded = isConfigurationLoaded
self.settings = settings
self.deviceState = deviceState
self.onUpdateTunnelStatus = onUpdateTunnelStatus
self.tunnel = nil
self.tunnelStatus = TunnelStatus()
}
func getPersistentTunnels() -> [any TunnelProtocol] {
return []
}
func createNewTunnel() -> any TunnelProtocol {
return MockTunnel(tunnelProvider: SimulatorTunnelProviderManager())
}
func setTunnel(_ tunnel: (any TunnelProtocol)?, shouldRefreshTunnelState: Bool) {
self.tunnel = tunnel
}
var tunnelStatus: TunnelStatus
func updateTunnelStatus(_ block: (inout TunnelStatus) -> Void) -> TunnelStatus {
var tunnelStatus = self.tunnelStatus
block(&tunnelStatus)
onUpdateTunnelStatus?(tunnelStatus)
return tunnelStatus
}
func setConfigurationLoaded() {}
func setSettings(_ settings: MullvadSettings.LatestTunnelSettings, persist: Bool) {}
func setDeviceState(_ deviceState: MullvadSettings.DeviceState, persist: Bool) {}
func removeLastUsedAccount() {}
func handleRestError(_ error: Error) {}
func startTunnel() {}
func prepareForVPNConfigurationDeletion() {}
struct NotImplementedError: Error {}
func selectRelay() throws -> PacketTunnelCore.SelectedRelay {
throw NotImplementedError()
}
}