-
Notifications
You must be signed in to change notification settings - Fork 384
/
Copy pathTunnelSettingsUpdateTests.swift
73 lines (60 loc) · 2.25 KB
/
TunnelSettingsUpdateTests.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
//
// TunnelSettingsUpdateTests.swift
// MullvadVPNTests
//
// Created by Andrew Bulhak on 2024-02-14.
// Copyright © 2024 Mullvad VPN AB. All rights reserved.
//
@testable import MullvadSettings
import MullvadTypes
import Network
import XCTest
final class TunnelSettingsUpdateTests: XCTestCase {
func testApplyDNSSettings() {
// Given:
var settings = LatestTunnelSettings()
// When:
var dnsSettings = DNSSettings()
dnsSettings.blockingOptions = [.blockAdvertising, .blockTracking]
dnsSettings.enableCustomDNS = true
dnsSettings.customDNSDomains = [.ipv4(IPv4Address("1.2.3.4")!)]
let update = TunnelSettingsUpdate.dnsSettings(dnsSettings)
update.apply(to: &settings)
// Then:
XCTAssertEqual(settings.dnsSettings.blockingOptions, [.blockAdvertising, .blockTracking])
XCTAssertEqual(settings.dnsSettings.enableCustomDNS, true)
XCTAssertEqual(settings.dnsSettings.customDNSDomains, [.ipv4(IPv4Address("1.2.3.4")!)])
}
func testApplyObfuscation() {
// Given:
var settings = LatestTunnelSettings()
// When:
let update = TunnelSettingsUpdate.obfuscation(.init(state: .on, port: .port5001))
update.apply(to: &settings)
// Then:
XCTAssertEqual(settings.wireGuardObfuscation, WireGuardObfuscationSettings(state: .on, port: .port5001))
}
func testApplyRelayConstraints() {
// Given:
var settings = LatestTunnelSettings()
// When:
let relayConstraints = RelayConstraints(
locations: .only(RelayLocations(locations: [.country("zz")])),
port: .only(9999),
filter: .only(.init(ownership: .rented, providers: .only(["foo", "bar"])))
)
let update = TunnelSettingsUpdate.relayConstraints(relayConstraints)
update.apply(to: &settings)
// Then:
XCTAssertEqual(settings.relayConstraints, relayConstraints)
}
func testApplyQuantumResistance() {
// Given:
var settings = LatestTunnelSettings()
// When:
let update = TunnelSettingsUpdate.quantumResistance(.on)
update.apply(to: &settings)
// Then:
XCTAssertEqual(settings.tunnelQuantumResistance, .on)
}
}