Restore tests with recent changes

This commit is contained in:
Davide De Rosa 2019-05-19 15:50:30 +02:00
parent d057e9645b
commit 821cf66d79
8 changed files with 147 additions and 39 deletions

View File

@ -158,6 +158,42 @@
0EE2FA0922918DA100F56F49 /* TunnelKitProvider+Interaction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EE2F9EC22918DA100F56F49 /* TunnelKitProvider+Interaction.swift */; };
0EE2FA0A22918DA100F56F49 /* InterfaceObserver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EE2F9ED22918DA100F56F49 /* InterfaceObserver.swift */; };
0EE2FA0B22918DA100F56F49 /* InterfaceObserver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EE2F9ED22918DA100F56F49 /* InterfaceObserver.swift */; };
0EE2FA422291954300F56F49 /* AppExtensionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EE2FA0E2291953300F56F49 /* AppExtensionTests.swift */; };
0EE2FA432291954300F56F49 /* CompressionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EE2FA1C2291953300F56F49 /* CompressionTests.swift */; };
0EE2FA442291954300F56F49 /* ConfigurationParserTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EE2FA162291953300F56F49 /* ConfigurationParserTests.swift */; };
0EE2FA452291954300F56F49 /* ControlChannelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EE2FA1A2291953300F56F49 /* ControlChannelTests.swift */; };
0EE2FA462291954300F56F49 /* DataManipulationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EE2FA192291953300F56F49 /* DataManipulationTests.swift */; };
0EE2FA472291954300F56F49 /* DataPathEncryptionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EE2FA1D2291953300F56F49 /* DataPathEncryptionTests.swift */; };
0EE2FA482291954300F56F49 /* DataPathPerformanceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EE2FA0D2291953300F56F49 /* DataPathPerformanceTests.swift */; };
0EE2FA492291954300F56F49 /* DNSTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EE2FA112291953300F56F49 /* DNSTests.swift */; };
0EE2FA4A2291954300F56F49 /* EncryptionPerformanceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EE2FA172291953300F56F49 /* EncryptionPerformanceTests.swift */; };
0EE2FA4B2291954300F56F49 /* EncryptionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EE2FA102291953300F56F49 /* EncryptionTests.swift */; };
0EE2FA4C2291954300F56F49 /* LinkTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EE2FA122291953300F56F49 /* LinkTests.swift */; };
0EE2FA4D2291954300F56F49 /* PacketTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EE2FA182291953300F56F49 /* PacketTests.swift */; };
0EE2FA4E2291954300F56F49 /* PushTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EE2FA1B2291953300F56F49 /* PushTests.swift */; };
0EE2FA4F2291954300F56F49 /* RandomTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EE2FA0F2291953300F56F49 /* RandomTests.swift */; };
0EE2FA502291954300F56F49 /* RawPerformanceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EE2FA0C2291953300F56F49 /* RawPerformanceTests.swift */; };
0EE2FA512291954300F56F49 /* RoutingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EE2FA132291953300F56F49 /* RoutingTests.swift */; };
0EE2FA522291954300F56F49 /* StaticKeyTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EE2FA142291953300F56F49 /* StaticKeyTests.swift */; };
0EE2FA532291954300F56F49 /* TestUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EE2FA152291953300F56F49 /* TestUtils.swift */; };
0EE2FA542291954400F56F49 /* AppExtensionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EE2FA0E2291953300F56F49 /* AppExtensionTests.swift */; };
0EE2FA552291954400F56F49 /* CompressionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EE2FA1C2291953300F56F49 /* CompressionTests.swift */; };
0EE2FA562291954400F56F49 /* ConfigurationParserTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EE2FA162291953300F56F49 /* ConfigurationParserTests.swift */; };
0EE2FA572291954400F56F49 /* ControlChannelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EE2FA1A2291953300F56F49 /* ControlChannelTests.swift */; };
0EE2FA582291954400F56F49 /* DataManipulationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EE2FA192291953300F56F49 /* DataManipulationTests.swift */; };
0EE2FA592291954400F56F49 /* DataPathEncryptionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EE2FA1D2291953300F56F49 /* DataPathEncryptionTests.swift */; };
0EE2FA5A2291954400F56F49 /* DataPathPerformanceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EE2FA0D2291953300F56F49 /* DataPathPerformanceTests.swift */; };
0EE2FA5B2291954400F56F49 /* DNSTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EE2FA112291953300F56F49 /* DNSTests.swift */; };
0EE2FA5C2291954400F56F49 /* EncryptionPerformanceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EE2FA172291953300F56F49 /* EncryptionPerformanceTests.swift */; };
0EE2FA5D2291954400F56F49 /* EncryptionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EE2FA102291953300F56F49 /* EncryptionTests.swift */; };
0EE2FA5E2291954400F56F49 /* LinkTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EE2FA122291953300F56F49 /* LinkTests.swift */; };
0EE2FA5F2291954400F56F49 /* PacketTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EE2FA182291953300F56F49 /* PacketTests.swift */; };
0EE2FA602291954400F56F49 /* PushTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EE2FA1B2291953300F56F49 /* PushTests.swift */; };
0EE2FA612291954400F56F49 /* RandomTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EE2FA0F2291953300F56F49 /* RandomTests.swift */; };
0EE2FA622291954400F56F49 /* RawPerformanceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EE2FA0C2291953300F56F49 /* RawPerformanceTests.swift */; };
0EE2FA632291954400F56F49 /* RoutingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EE2FA132291953300F56F49 /* RoutingTests.swift */; };
0EE2FA642291954400F56F49 /* StaticKeyTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EE2FA142291953300F56F49 /* StaticKeyTests.swift */; };
0EE2FA652291954400F56F49 /* TestUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EE2FA152291953300F56F49 /* TestUtils.swift */; };
0EE3B3E421471C3A0027AB17 /* StaticKey.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EE3B3E321471C3A0027AB17 /* StaticKey.swift */; };
0EE3B3E521471C3A0027AB17 /* StaticKey.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EE3B3E321471C3A0027AB17 /* StaticKey.swift */; };
0EE7A79820F6296F00B42E6A /* PacketMacros.m in Sources */ = {isa = PBXBuildFile; fileRef = 0EE7A79720F6296F00B42E6A /* PacketMacros.m */; };
@ -356,6 +392,24 @@
0EE2F9EB22918DA100F56F49 /* Utils.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Utils.swift; sourceTree = "<group>"; };
0EE2F9EC22918DA100F56F49 /* TunnelKitProvider+Interaction.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "TunnelKitProvider+Interaction.swift"; sourceTree = "<group>"; };
0EE2F9ED22918DA100F56F49 /* InterfaceObserver.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InterfaceObserver.swift; sourceTree = "<group>"; };
0EE2FA0C2291953300F56F49 /* RawPerformanceTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RawPerformanceTests.swift; sourceTree = "<group>"; };
0EE2FA0D2291953300F56F49 /* DataPathPerformanceTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DataPathPerformanceTests.swift; sourceTree = "<group>"; };
0EE2FA0E2291953300F56F49 /* AppExtensionTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppExtensionTests.swift; sourceTree = "<group>"; };
0EE2FA0F2291953300F56F49 /* RandomTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RandomTests.swift; sourceTree = "<group>"; };
0EE2FA102291953300F56F49 /* EncryptionTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EncryptionTests.swift; sourceTree = "<group>"; };
0EE2FA112291953300F56F49 /* DNSTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DNSTests.swift; sourceTree = "<group>"; };
0EE2FA122291953300F56F49 /* LinkTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LinkTests.swift; sourceTree = "<group>"; };
0EE2FA132291953300F56F49 /* RoutingTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RoutingTests.swift; sourceTree = "<group>"; };
0EE2FA142291953300F56F49 /* StaticKeyTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StaticKeyTests.swift; sourceTree = "<group>"; };
0EE2FA152291953300F56F49 /* TestUtils.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestUtils.swift; sourceTree = "<group>"; };
0EE2FA162291953300F56F49 /* ConfigurationParserTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConfigurationParserTests.swift; sourceTree = "<group>"; };
0EE2FA172291953300F56F49 /* EncryptionPerformanceTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EncryptionPerformanceTests.swift; sourceTree = "<group>"; };
0EE2FA182291953300F56F49 /* PacketTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PacketTests.swift; sourceTree = "<group>"; };
0EE2FA192291953300F56F49 /* DataManipulationTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DataManipulationTests.swift; sourceTree = "<group>"; };
0EE2FA1A2291953300F56F49 /* ControlChannelTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ControlChannelTests.swift; sourceTree = "<group>"; };
0EE2FA1B2291953300F56F49 /* PushTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PushTests.swift; sourceTree = "<group>"; };
0EE2FA1C2291953300F56F49 /* CompressionTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CompressionTests.swift; sourceTree = "<group>"; };
0EE2FA1D2291953300F56F49 /* DataPathEncryptionTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DataPathEncryptionTests.swift; sourceTree = "<group>"; };
0EE3B3E321471C3A0027AB17 /* StaticKey.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StaticKey.swift; sourceTree = "<group>"; };
0EE7A79420F61EDC00B42E6A /* PacketMacros.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PacketMacros.h; sourceTree = "<group>"; };
0EE7A79720F6296F00B42E6A /* PacketMacros.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PacketMacros.m; sourceTree = "<group>"; };
@ -457,6 +511,24 @@
0E11089B1F77B9E800A92462 /* TunnelKitTests */ = {
isa = PBXGroup;
children = (
0EE2FA0E2291953300F56F49 /* AppExtensionTests.swift */,
0EE2FA1C2291953300F56F49 /* CompressionTests.swift */,
0EE2FA162291953300F56F49 /* ConfigurationParserTests.swift */,
0EE2FA1A2291953300F56F49 /* ControlChannelTests.swift */,
0EE2FA192291953300F56F49 /* DataManipulationTests.swift */,
0EE2FA1D2291953300F56F49 /* DataPathEncryptionTests.swift */,
0EE2FA0D2291953300F56F49 /* DataPathPerformanceTests.swift */,
0EE2FA112291953300F56F49 /* DNSTests.swift */,
0EE2FA172291953300F56F49 /* EncryptionPerformanceTests.swift */,
0EE2FA102291953300F56F49 /* EncryptionTests.swift */,
0EE2FA122291953300F56F49 /* LinkTests.swift */,
0EE2FA182291953300F56F49 /* PacketTests.swift */,
0EE2FA1B2291953300F56F49 /* PushTests.swift */,
0EE2FA0F2291953300F56F49 /* RandomTests.swift */,
0EE2FA0C2291953300F56F49 /* RawPerformanceTests.swift */,
0EE2FA132291953300F56F49 /* RoutingTests.swift */,
0EE2FA142291953300F56F49 /* StaticKeyTests.swift */,
0EE2FA152291953300F56F49 /* TestUtils.swift */,
0E749F612178911C00BB2701 /* pia-2048.pem */,
0E011F832196E25400BA59EE /* pia-hungary.ovpn */,
0ECEB11A2252CDAD00E9E551 /* tunnelbear.crt */,
@ -1163,6 +1235,24 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
0EE2FA522291954300F56F49 /* StaticKeyTests.swift in Sources */,
0EE2FA432291954300F56F49 /* CompressionTests.swift in Sources */,
0EE2FA492291954300F56F49 /* DNSTests.swift in Sources */,
0EE2FA472291954300F56F49 /* DataPathEncryptionTests.swift in Sources */,
0EE2FA502291954300F56F49 /* RawPerformanceTests.swift in Sources */,
0EE2FA4D2291954300F56F49 /* PacketTests.swift in Sources */,
0EE2FA452291954300F56F49 /* ControlChannelTests.swift in Sources */,
0EE2FA4E2291954300F56F49 /* PushTests.swift in Sources */,
0EE2FA422291954300F56F49 /* AppExtensionTests.swift in Sources */,
0EE2FA512291954300F56F49 /* RoutingTests.swift in Sources */,
0EE2FA4A2291954300F56F49 /* EncryptionPerformanceTests.swift in Sources */,
0EE2FA4F2291954300F56F49 /* RandomTests.swift in Sources */,
0EE2FA4B2291954300F56F49 /* EncryptionTests.swift in Sources */,
0EE2FA532291954300F56F49 /* TestUtils.swift in Sources */,
0EE2FA462291954300F56F49 /* DataManipulationTests.swift in Sources */,
0EE2FA4C2291954300F56F49 /* LinkTests.swift in Sources */,
0EE2FA442291954300F56F49 /* ConfigurationParserTests.swift in Sources */,
0EE2FA482291954300F56F49 /* DataPathPerformanceTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -1337,6 +1427,24 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
0EE2FA642291954400F56F49 /* StaticKeyTests.swift in Sources */,
0EE2FA552291954400F56F49 /* CompressionTests.swift in Sources */,
0EE2FA5B2291954400F56F49 /* DNSTests.swift in Sources */,
0EE2FA592291954400F56F49 /* DataPathEncryptionTests.swift in Sources */,
0EE2FA622291954400F56F49 /* RawPerformanceTests.swift in Sources */,
0EE2FA5F2291954400F56F49 /* PacketTests.swift in Sources */,
0EE2FA572291954400F56F49 /* ControlChannelTests.swift in Sources */,
0EE2FA602291954400F56F49 /* PushTests.swift in Sources */,
0EE2FA542291954400F56F49 /* AppExtensionTests.swift in Sources */,
0EE2FA632291954400F56F49 /* RoutingTests.swift in Sources */,
0EE2FA5C2291954400F56F49 /* EncryptionPerformanceTests.swift in Sources */,
0EE2FA612291954400F56F49 /* RandomTests.swift in Sources */,
0EE2FA5D2291954400F56F49 /* EncryptionTests.swift in Sources */,
0EE2FA652291954400F56F49 /* TestUtils.swift in Sources */,
0EE2FA582291954400F56F49 /* DataManipulationTests.swift in Sources */,
0EE2FA5E2291954400F56F49 /* LinkTests.swift in Sources */,
0EE2FA562291954400F56F49 /* ConfigurationParserTests.swift in Sources */,
0EE2FA5A2291954400F56F49 /* DataPathPerformanceTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};

View File

@ -57,10 +57,10 @@ class AppExtensionTests: XCTestCase {
let identifier = "com.example.Provider"
let appGroup = "group.com.algoritmico.TunnelKit"
let hostname = "example.com"
let credentials = Credentials("foo", "bar")
let credentials = OpenVPN.Credentials("foo", "bar")
var sessionBuilder = ConfigurationBuilder()
sessionBuilder.ca = CryptoContainer(pem: "abcdef")
var sessionBuilder = OpenVPN.ConfigurationBuilder()
sessionBuilder.ca = OpenVPN.CryptoContainer(pem: "abcdef")
sessionBuilder.cipher = .aes128cbc
sessionBuilder.digest = .sha256
sessionBuilder.hostname = hostname

View File

@ -58,9 +58,9 @@ class ConfigurationParserTests: XCTestCase {
"dhcp-option PROXY_HTTPS 7.8.9.10 8082",
"dhcp-option PROXY_BYPASS foo.com bar.org net.chat"
]
XCTAssertNoThrow(try ConfigurationParser.parsed(fromLines: lines))
XCTAssertNoThrow(try OpenVPN.ConfigurationParser.parsed(fromLines: lines))
let parsed = try! ConfigurationParser.parsed(fromLines: lines).configuration
let parsed = try! OpenVPN.ConfigurationParser.parsed(fromLines: lines).configuration
XCTAssertEqual(parsed.dnsServers, ["8.8.8.8", "ffff::1"])
XCTAssertEqual(parsed.searchDomain, "example.com")
XCTAssertEqual(parsed.httpProxy?.address, "1.2.3.4")
@ -71,24 +71,24 @@ class ConfigurationParserTests: XCTestCase {
}
func testRedirectGateway() throws {
var parsed: Configuration
var parsed: OpenVPN.Configuration
parsed = try! ConfigurationParser.parsed(fromLines: []).configuration
parsed = try! OpenVPN.ConfigurationParser.parsed(fromLines: []).configuration
XCTAssertEqual(parsed.routingPolicies, nil)
XCTAssertNotEqual(parsed.routingPolicies, [])
parsed = try! ConfigurationParser.parsed(fromLines: ["redirect-gateway ipv4 block-local"]).configuration
parsed = try! OpenVPN.ConfigurationParser.parsed(fromLines: ["redirect-gateway ipv4 block-local"]).configuration
XCTAssertEqual(Set(parsed.routingPolicies!), Set([.IPv4, .blockLocal]))
}
func testConnectionBlock() throws {
let lines = ["<connection>", "</connection>"]
XCTAssertThrowsError(try ConfigurationParser.parsed(fromLines: lines))
XCTAssertThrowsError(try OpenVPN.ConfigurationParser.parsed(fromLines: lines))
}
// from file
func testPIA() throws {
let file = try ConfigurationParser.parsed(fromURL: url(withName: "pia-hungary"))
let file = try OpenVPN.ConfigurationParser.parsed(fromURL: url(withName: "pia-hungary"))
XCTAssertEqual(file.configuration.hostname, "hungary.privateinternetaccess.com")
XCTAssertEqual(file.configuration.cipher, .aes128cbc)
XCTAssertEqual(file.configuration.digest, .sha1)
@ -99,7 +99,7 @@ class ConfigurationParserTests: XCTestCase {
}
func testStripped() throws {
let lines = try ConfigurationParser.parsed(fromURL: url(withName: "pia-hungary"), returnsStripped: true).strippedLines!
let lines = try OpenVPN.ConfigurationParser.parsed(fromURL: url(withName: "pia-hungary"), returnsStripped: true).strippedLines!
let stripped = lines.joined(separator: "\n")
print(stripped)
}
@ -111,8 +111,8 @@ class ConfigurationParserTests: XCTestCase {
private func privateTestEncryptedCertificateKey(pkcs: String) throws {
let cfgURL = url(withName: "tunnelbear.enc.\(pkcs)")
XCTAssertThrowsError(try ConfigurationParser.parsed(fromURL: cfgURL))
XCTAssertNoThrow(try ConfigurationParser.parsed(fromURL: cfgURL, passphrase: "foobar"))
XCTAssertThrowsError(try OpenVPN.ConfigurationParser.parsed(fromURL: cfgURL))
XCTAssertNoThrow(try OpenVPN.ConfigurationParser.parsed(fromURL: cfgURL, passphrase: "foobar"))
}
private func url(withName name: String) -> URL {

View File

@ -49,8 +49,8 @@ class ControlChannelTests: XCTestCase {
// 00 // ack_size
// 00000000 // message packet_id (HARD_RESET -> UInt32(0))
func testHMAC() {
let key = StaticKey(biData: Data(hex: hex))
let server = CryptoBox(cipherAlgorithm: nil, digestAlgorithm: Digest.sha1.rawValue)
let key = OpenVPN.StaticKey(biData: Data(hex: hex))
let server = CryptoBox(cipherAlgorithm: nil, digestAlgorithm: OpenVPN.Digest.sha1.rawValue)
XCTAssertNoThrow(try server.configure(withCipherEncKey: nil, cipherDecKey: nil, hmacEncKey: key.hmacReceiveKey, hmacDecKey: key.hmacSendKey))
// let original = Data(hex: "38858fe14742fdae40e67c9137933a412a711c0d0514aca6db6476d17d000000015b96c9470000000000")
@ -69,8 +69,8 @@ class ControlChannelTests: XCTestCase {
// 00 // ack_size
// 00000000 // message packet_id
func testAuth() {
let client = try! ControlChannel.AuthSerializer(withKey: StaticKey(data: Data(hex: hex), direction: .client), digest: .sha512)
let server = try! ControlChannel.AuthSerializer(withKey: StaticKey(data: Data(hex: hex), direction: .server), digest: .sha512)
let client = try! OpenVPN.ControlChannel.AuthSerializer(withKey: OpenVPN.StaticKey(data: Data(hex: hex), direction: .client), digest: .sha512)
let server = try! OpenVPN.ControlChannel.AuthSerializer(withKey: OpenVPN.StaticKey(data: Data(hex: hex), direction: .server), digest: .sha512)
// let original = Data(hex: "38bccfd1")
let original = Data(hex: "38bccfd171ce22e085e01a3454c354f3c3093b00fc8d6228a8b69ef503d56f6a572ebd26a800711b4cd4df2b9daf06cb90f82379e7815e39fb73be4ac5461752db4f35120474af82b2000000015b93b65d0000000000")
@ -101,8 +101,8 @@ class ControlChannelTests: XCTestCase {
}
func testCrypt() {
let client = try! ControlChannel.CryptSerializer(withKey: StaticKey(data: Data(hex: hex), direction: .client))
let server = try! ControlChannel.CryptSerializer(withKey: StaticKey(data: Data(hex: hex), direction: .server))
let client = try! OpenVPN.ControlChannel.CryptSerializer(withKey: OpenVPN.StaticKey(data: Data(hex: hex), direction: .client))
let server = try! OpenVPN.ControlChannel.CryptSerializer(withKey: OpenVPN.StaticKey(data: Data(hex: hex), direction: .server))
let original = Data(hex: "407bf3d6a260e6476d000000015ba4155887940856ddb70e01693980c5c955cb5506ecf9fd3e0bcee0c802ec269427d43bf1cda1837ffbf30c83cacff852cd0b7f4c")
let timestamp = UInt32(0x5ba41558)

View File

@ -49,7 +49,7 @@ class DataPathPerformanceTests: XCTestCase {
let ck = try! SecureRandom.safeData(length: 32)
let hk = try! SecureRandom.safeData(length: 32)
let crypto = try! EncryptionBridge(.aes128cbc, .sha1, ck, ck, hk, hk)
let crypto = try! OpenVPN.EncryptionBridge(.aes128cbc, .sha1, ck, ck, hk, hk)
encrypter = crypto.encrypter()
decrypter = crypto.decrypter()

View File

@ -137,7 +137,7 @@ class EncryptionTests: XCTestCase {
func testCertificatePreamble() {
let url = Bundle(for: EncryptionTests.self).url(forResource: "tunnelbear", withExtension: "crt")!
let cert = CryptoContainer(pem: try! String(contentsOf: url))
let cert = OpenVPN.CryptoContainer(pem: try! String(contentsOf: url))
XCTAssert(cert.pem.hasPrefix("-----BEGIN"))
}

View File

@ -26,7 +26,7 @@
import XCTest
@testable import TunnelKit
private extension SessionReply {
private extension OpenVPN.PushReply {
func debug() {
print("Compression framing: \(options.compressionFraming?.description ?? "disabled")")
print("Compression algorithm: \(options.compressionAlgorithm?.description ?? "disabled")")
@ -48,7 +48,7 @@ class PushTests: XCTestCase {
func testNet30() {
let msg = "PUSH_REPLY,redirect-gateway def1,dhcp-option DNS 209.222.18.222,dhcp-option DNS 209.222.18.218,ping 10,comp-lzo no,route 10.5.10.1,topology net30,ifconfig 10.5.10.6 10.5.10.5,auth-token AUkQf/b3nj3L+CH4RJPP0Vuq8/gpntr7uPqzjQhncig="
let reply = try! PushReply(message: msg)!
let reply = try! OpenVPN.PushReply(message: msg)!
reply.debug()
XCTAssertEqual(reply.options.ipv4?.address, "10.5.10.6")
@ -59,7 +59,7 @@ class PushTests: XCTestCase {
func testSubnet() {
let msg = "PUSH_REPLY,dhcp-option DNS 8.8.8.8,dhcp-option DNS 4.4.4.4,route-gateway 10.8.0.1,topology subnet,ping 10,ping-restart 120,ifconfig 10.8.0.2 255.255.255.0,peer-id 0"
let reply = try! PushReply(message: msg)!
let reply = try! OpenVPN.PushReply(message: msg)!
reply.debug()
XCTAssertEqual(reply.options.ipv4?.address, "10.8.0.2")
@ -70,7 +70,7 @@ class PushTests: XCTestCase {
func testRoute() {
let msg = "PUSH_REPLY,dhcp-option DNS 8.8.8.8,dhcp-option DNS 4.4.4.4,route-gateway 10.8.0.1,route 192.168.0.0 255.255.255.0 10.8.0.12,topology subnet,ping 10,ping-restart 120,ifconfig 10.8.0.2 255.255.255.0,peer-id 0"
let reply = try! PushReply(message: msg)!
let reply = try! OpenVPN.PushReply(message: msg)!
reply.debug()
let route = reply.options.ipv4!.routes.first!
@ -82,7 +82,7 @@ class PushTests: XCTestCase {
func testIPv6() {
let msg = "PUSH_REPLY,dhcp-option DNS6 2001:4860:4860::8888,dhcp-option DNS6 2001:4860:4860::8844,tun-ipv6,route-gateway 10.8.0.1,topology subnet,ping 10,ping-restart 120,ifconfig-ipv6 fe80::601:30ff:feb7:ec01/64 fe80::601:30ff:feb7:dc02,ifconfig 10.8.0.2 255.255.255.0,peer-id 0"
let reply = try! PushReply(message: msg)!
let reply = try! OpenVPN.PushReply(message: msg)!
reply.debug()
XCTAssertEqual(reply.options.ipv4?.address, "10.8.0.2")
@ -96,7 +96,7 @@ class PushTests: XCTestCase {
func testCompressionFraming() {
let msg = "PUSH_REPLY,dhcp-option DNS 8.8.8.8,dhcp-option DNS 4.4.4.4,comp-lzo no,route 10.8.0.1,topology net30,ping 10,ping-restart 120,ifconfig 10.8.0.6 10.8.0.5,peer-id 0,cipher AES-256-CBC"
let reply = try! PushReply(message: msg)!
let reply = try! OpenVPN.PushReply(message: msg)!
reply.debug()
XCTAssertEqual(reply.options.compressionFraming, .compLZO)
@ -104,29 +104,29 @@ class PushTests: XCTestCase {
func testCompression() {
let msg = "PUSH_REPLY,dhcp-option DNS 8.8.8.8,dhcp-option DNS 4.4.4.4,route 10.8.0.1,topology net30,ping 10,ping-restart 120,ifconfig 10.8.0.6 10.8.0.5,peer-id 0,cipher AES-256-CBC"
var reply: SessionReply
var reply: OpenVPN.PushReply
reply = try! PushReply(message: msg.appending(",comp-lzo no"))!
reply = try! OpenVPN.PushReply(message: msg.appending(",comp-lzo no"))!
reply.debug()
XCTAssertEqual(reply.options.compressionFraming, .compLZO)
XCTAssertEqual(reply.options.compressionAlgorithm, .disabled)
reply = try! PushReply(message: msg.appending(",comp-lzo"))!
reply = try! OpenVPN.PushReply(message: msg.appending(",comp-lzo"))!
reply.debug()
XCTAssertEqual(reply.options.compressionFraming, .compLZO)
XCTAssertEqual(reply.options.compressionAlgorithm, .LZO)
reply = try! PushReply(message: msg.appending(",comp-lzo yes"))!
reply = try! OpenVPN.PushReply(message: msg.appending(",comp-lzo yes"))!
reply.debug()
XCTAssertEqual(reply.options.compressionFraming, .compLZO)
XCTAssertEqual(reply.options.compressionAlgorithm, .LZO)
reply = try! PushReply(message: msg.appending(",compress"))!
reply = try! OpenVPN.PushReply(message: msg.appending(",compress"))!
reply.debug()
XCTAssertEqual(reply.options.compressionFraming, .compress)
XCTAssertEqual(reply.options.compressionAlgorithm, .disabled)
reply = try! PushReply(message: msg.appending(",compress lz4"))!
reply = try! OpenVPN.PushReply(message: msg.appending(",compress lz4"))!
reply.debug()
XCTAssertEqual(reply.options.compressionFraming, .compress)
XCTAssertEqual(reply.options.compressionAlgorithm, .other)
@ -134,7 +134,7 @@ class PushTests: XCTestCase {
func testNCP() {
let msg = "PUSH_REPLY,dhcp-option DNS 8.8.8.8,dhcp-option DNS 4.4.4.4,comp-lzo no,route 10.8.0.1,topology net30,ping 10,ping-restart 120,ifconfig 10.8.0.6 10.8.0.5,peer-id 0,cipher AES-256-GCM"
let reply = try! PushReply(message: msg)!
let reply = try! OpenVPN.PushReply(message: msg)!
reply.debug()
XCTAssertEqual(reply.options.cipher, .aes256gcm)
@ -142,7 +142,7 @@ class PushTests: XCTestCase {
func testNCPTrailing() {
let msg = "PUSH_REPLY,dhcp-option DNS 8.8.8.8,dhcp-option DNS 4.4.4.4,comp-lzo no,route 10.8.0.1,topology net30,ping 10,ping-restart 120,ifconfig 10.8.0.18 10.8.0.17,peer-id 3,cipher AES-256-GCM,auth-token"
let reply = try! PushReply(message: msg)!
let reply = try! OpenVPN.PushReply(message: msg)!
reply.debug()
XCTAssertEqual(reply.options.cipher, .aes256gcm)
@ -150,7 +150,7 @@ class PushTests: XCTestCase {
func testPing() {
let msg = "PUSH_REPLY,route 192.168.1.0 255.255.255.0,route 10.0.2.0 255.255.255.0,dhcp-option DNS 192.168.1.99,dhcp-option DNS 176.103.130.130,route 10.0.2.1,topology net30,ping 10,ping-restart 60,ifconfig 10.0.2.14 10.0.2.13"
let reply = try! PushReply(message: msg)!
let reply = try! OpenVPN.PushReply(message: msg)!
reply.debug()
XCTAssertEqual(reply.options.keepAliveInterval, 10)
@ -158,7 +158,7 @@ class PushTests: XCTestCase {
func testProvost() {
let msg = "PUSH_REPLY,route 87.233.192.218,route 87.233.192.219,route 87.233.192.220,route 87.248.186.252,route 92.241.171.245,route 103.246.200.0 255.255.252.0,route 109.239.140.0 255.255.255.0,route 128.199.0.0 255.255.0.0,route 13.125.0.0 255.255.0.0,route 13.230.0.0 255.254.0.0,route 13.56.0.0 255.252.0.0,route 149.154.160.0 255.255.252.0,route 149.154.164.0 255.255.252.0,route 149.154.168.0 255.255.252.0,route 149.154.172.0 255.255.252.0,route 159.122.128.0 255.255.192.0,route 159.203.0.0 255.255.0.0,route 159.65.0.0 255.255.0.0,route 159.89.0.0 255.255.0.0,route 165.227.0.0 255.255.0.0,route 167.99.0.0 255.255.0.0,route 174.138.0.0 255.255.128.0,route 176.67.169.0 255.255.255.0,route 178.239.88.0 255.255.248.0,route 178.63.0.0 255.255.0.0,route 18.130.0.0 255.255.0.0,route 18.144.0.0 255.255.0.0,route 18.184.0.0 255.254.0.0,route 18.194.0.0 255.254.0.0,route 18.196.0.0 255.254.0.0,route 18.204.0.0 255.252.0.0,push-continuation 2"
let reply = try? PushReply(message: msg)!
let reply = try? OpenVPN.PushReply(message: msg)!
reply?.debug()
}
}

View File

@ -63,7 +63,7 @@ dccdb953cdf32bea03f365760b0ed800
func testFileBidirectional() {
let expected = Data(hex: "cf55d863fcbe314df5f0b45dbe974d9bde33ef5b4803c3985531c6c23ca6906d6cd028efc8585d1b9e71003566bd7891b9cc9212bcba510109922eed87f5c8e6")
let key = StaticKey(file: content, direction: nil)
let key = OpenVPN.StaticKey(file: content, direction: nil)
XCTAssertNotNil(key)
XCTAssertEqual(key?.hmacSendKey.toData(), expected)
@ -73,7 +73,7 @@ dccdb953cdf32bea03f365760b0ed800
func testFileDirection() {
let send = Data(hex: "778a6b35a124e700920879f1d003ba93dccdb953cdf32bea03f365760b0ed8002098d4ce20d045b45a83a8432cc737677aed27125592a7148d25c87fdbe0a3f6")
let receive = Data(hex: "cf55d863fcbe314df5f0b45dbe974d9bde33ef5b4803c3985531c6c23ca6906d6cd028efc8585d1b9e71003566bd7891b9cc9212bcba510109922eed87f5c8e6")
let key = StaticKey(file: content, direction: .client)
let key = OpenVPN.StaticKey(file: content, direction: .client)
XCTAssertNotNil(key)
XCTAssertEqual(key?.hmacSendKey.toData(), send)