-
Notifications
You must be signed in to change notification settings - Fork 392
/
Copy pathMockTunnel.swift
61 lines (45 loc) · 1.47 KB
/
MockTunnel.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
//
// MockTunnel.swift
// MullvadVPNTests
//
// Created by Andrew Bulhak on 2024-02-05.
// Copyright © 2024 Mullvad VPN AB. All rights reserved.
//
import Foundation
@testable import MullvadVPN
import NetworkExtension
class MockTunnel: TunnelProtocol {
typealias TunnelManagerProtocol = SimulatorTunnelProviderManager
var status: NEVPNStatus
var isOnDemandEnabled: Bool
var startDate: Date?
required init(tunnelProvider: TunnelManagerProtocol) {
status = .disconnected
isOnDemandEnabled = false
startDate = nil
}
// Observers are currently unimplemented
func addObserver(_ observer: TunnelStatusObserver) {}
func removeObserver(_ observer: TunnelStatusObserver) {}
func addBlockObserver(
queue: DispatchQueue?,
handler: @escaping (any TunnelProtocol, NEVPNStatus) -> Void
) -> TunnelStatusBlockObserver {
fatalError("MockTunnel.addBlockObserver Not implemented")
}
func logFormat() -> String {
""
}
func saveToPreferences(_ completion: @escaping (Error?) -> Void) {
completion(nil)
}
func removeFromPreferences(completion: @escaping (Error?) -> Void) {
completion(nil)
}
func setConfiguration(_ configuration: TunnelConfiguration) {}
func start(options: [String: NSObject]?) throws {
startDate = Date()
}
func stop() {}
func sendProviderMessage(_ messageData: Data, responseHandler: ((Data?) -> Void)?) throws {}
}