Skip to content
This repository has been archived by the owner on Sep 29, 2024. It is now read-only.

Commit

Permalink
Drop prints
Browse files Browse the repository at this point in the history
  • Loading branch information
keeshux committed Dec 12, 2023
1 parent 29feedf commit 6435fa9
Show file tree
Hide file tree
Showing 12 changed files with 5 additions and 57 deletions.
7 changes: 0 additions & 7 deletions Tests/TunnelKitCoreTests/RandomTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,8 @@ class RandomTests: XCTestCase {
}

func testRandom1() {
print(try! SecureRandom.uint32())
print(try! SecureRandom.uint32())
print(try! SecureRandom.uint32())
print(try! SecureRandom.uint32())
print(try! SecureRandom.uint32())
}

func testRandom2() {
print("random UInt32: \(try! SecureRandom.uint32())")
print("random bytes: \(try! SecureRandom.data(length: 12).toHex())")
}
}
8 changes: 0 additions & 8 deletions Tests/TunnelKitCoreTests/RoutingTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ class RoutingTests: XCTestCase {

func testEntryMatch4() {
let entry24 = RoutingTableEntry(iPv4Network: "192.168.1.0/24", gateway: nil, networkInterface: "en0")
print(entry24.networkMask()!)
for i in 0x0...0xff {
XCTAssertTrue(entry24.matchesDestination("192.168.1.\(i)"))
}
Expand All @@ -47,7 +46,6 @@ class RoutingTests: XCTestCase {
}

let entry28 = RoutingTableEntry(iPv4Network: "192.168.1.0/28", gateway: nil, networkInterface: "en0")
print(entry28.networkMask()!)
for i in 0x0...0xf {
XCTAssertTrue(entry28.matchesDestination("192.168.1.\(i)"))
}
Expand All @@ -70,13 +68,10 @@ class RoutingTests: XCTestCase {
let table = RoutingTable()

for entry in table.ipv4() {
print(entry)
}

if let defaultGateway = table.defaultGateway4()?.gateway() {
print("Default gateway: \(defaultGateway)")
if let lan = table.broadestRoute4(matchingDestination: defaultGateway) {
print("Gateway LAN: \(lan.network())/\(lan.prefix())")
}
}
}
Expand All @@ -85,13 +80,10 @@ class RoutingTests: XCTestCase {
let table = RoutingTable()

for entry in table.ipv6() {
print(entry)
}

if let defaultGateway = table.defaultGateway6()?.gateway() {
print("Default gateway: \(defaultGateway)")
if let lan = table.broadestRoute6(matchingDestination: defaultGateway) {
print("Gateway LAN: \(lan.network())/\(lan.prefix())")
}
}
}
Expand Down
3 changes: 0 additions & 3 deletions Tests/TunnelKitLZOTests/CompressionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ class CompressionTests: XCTestCase {

override func setUp() {
// Put setup code here. This method is called before the invocation of each test method in the class.
// print("LZO version: \(LZO.versionString())")
}

override func tearDown() {
Expand All @@ -51,8 +50,6 @@ class CompressionTests: XCTestCase {
XCTFail("Unable to decompress data")
return
}
print("BEFORE: \(src)")
print("AFTER : \(dstDecompressed)")
XCTAssertEqual(src, dstDecompressed)
}
}
10 changes: 3 additions & 7 deletions Tests/TunnelKitOpenVPNTests/AppExtensionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ class AppExtensionTests: XCTestCase {
guard let pc = proto.providerConfiguration else {
return
}
print("\(pc)")

let ovpn = pc["configuration"] as? [String: Any]
XCTAssertEqual(pc["appGroup"] as? String, appGroup)
Expand All @@ -107,11 +106,11 @@ class AppExtensionTests: XCTestCase {
exp.fulfill()
}
switch $0 {
case .success(let records):
print("\(records)")
case .success:
break

case .failure:
print("Can't resolve")
break
}
}
waitForExpectations(timeout: 5.0, handler: nil)
Expand Down Expand Up @@ -159,7 +158,6 @@ class AppExtensionTests: XCTestCase {
guard let remote = strategy.currentRemote else {
break
}
print("\(i): \(remote)")
XCTAssertEqual(remote.originalEndpoint.description, expected[i])
i += 1
guard strategy.tryNextEndpoint() else {
Expand Down Expand Up @@ -190,7 +188,6 @@ class AppExtensionTests: XCTestCase {
// var i = 0
// while strategy.hasEndpoint() {
// let endpoint = strategy.currentEndpoint()
// print("\(endpoint)")
// XCTAssertEqual(endpoint.description, expected[i])
// i += 1
// strategy.tryNextEndpoint()
Expand Down Expand Up @@ -219,7 +216,6 @@ class AppExtensionTests: XCTestCase {
// var i = 0
// while strategy.hasEndpoint() {
// let endpoint = strategy.currentEndpoint()
// print("\(endpoint)")
// XCTAssertEqual(endpoint.description, expected[i])
// i += 1
// strategy.tryNextEndpoint()
Expand Down
3 changes: 1 addition & 2 deletions Tests/TunnelKitOpenVPNTests/ConfigurationParserTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,7 @@ class ConfigurationParserTests: XCTestCase {

func testStripped() throws {
let lines = try OpenVPN.ConfigurationParser.parsed(fromURL: url(withName: "pia-hungary"), returnsStripped: true).strippedLines!
let stripped = lines.joined(separator: "\n")
print(stripped)
_ = lines.joined(separator: "\n")
}

func testEncryptedCertificateKey() throws {
Expand Down
5 changes: 0 additions & 5 deletions Tests/TunnelKitOpenVPNTests/ControlChannelTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ class ControlChannelTests: XCTestCase {
let hmac = Data(hex: "e67c9137933a412a711c0d0514aca6db6476d17d")
let subject = Data(hex: "000000015b96c94738858fe14742fdae400000000000")
let data = hmac + subject
print(data.toHex())

XCTAssertNoThrow(try server.decrypter().verifyData(data, flags: nil))
}
Expand Down Expand Up @@ -98,8 +97,6 @@ class ControlChannelTests: XCTestCase {
XCTAssertNil(error)
return
}
print("raw: \(raw.toHex())")
print("org: \(original.toHex())")
XCTAssertEqual(raw, original)
}

Expand Down Expand Up @@ -130,8 +127,6 @@ class ControlChannelTests: XCTestCase {
XCTAssertNil(error)
return
}
print("raw: \(raw.toHex())")
print("org: \(original.toHex())")
XCTAssertEqual(raw, original)
}
}
2 changes: 0 additions & 2 deletions Tests/TunnelKitOpenVPNTests/DataPathEncryptionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,7 @@ class DataPathEncryptionTests: XCTestCase {
let key: UInt8 = 4

let encrypted = try! path.encryptPackets([expectedPayload], key: key)
print(encrypted.map { $0.toHex() })
let decrypted = try! path.decryptPackets(encrypted, keepAlive: nil)
print(decrypted.map { $0.toHex() })
let payload = decrypted.first!

XCTAssertEqual(payload, expectedPayload)
Expand Down
2 changes: 0 additions & 2 deletions Tests/TunnelKitOpenVPNTests/DataPathPerformanceTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ class DataPathPerformanceTests: XCTestCase {
// decryptedPackets = try! self.swiftDP.decryptPackets(encryptedPackets, keepAlive: nil)
// }
//
//// print(">>> \(packets?.count) packets")
// XCTAssertEqual(decryptedPackets, packets)
// }

Expand All @@ -97,7 +96,6 @@ class DataPathPerformanceTests: XCTestCase {
decryptedPackets = try! self.dataPath.decryptPackets(encryptedPackets, keepAlive: nil)
}

// print(">>> \(packets?.count) packets")
XCTAssertEqual(decryptedPackets, packets)
}
}
5 changes: 0 additions & 5 deletions Tests/TunnelKitOpenVPNTests/EncryptionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -112,19 +112,16 @@ class EncryptionTests: XCTestCase {

// let expEncrypted = Data(hex: "319bb8e7f8f7930cc4625079dd32a6ef9540c2fc001c53f909f712037ae9818af840b88714")
let encrypted = try! client.encrypter().encryptData(original, flags: &flags)
print(encrypted.toHex())
// XCTAssertEqual(encrypted, expEncrypted)

let decrypted = try! server.decrypter().decryptData(encrypted, flags: &flags)
print(decrypted.toHex())
XCTAssertEqual(decrypted, original)
}

func testCertificateMD5() {
let path = Bundle.module.path(forResource: "pia-2048", ofType: "pem")!
let md5 = try! TLSBox.md5(forCertificatePath: path)
let exp = "e2fccccaba712ccc68449b1c56427ac1"
print(md5)
XCTAssertEqual(md5, exp)
}

Expand All @@ -140,10 +137,8 @@ class EncryptionTests: XCTestCase {

XCTAssertThrowsError(try TLSBox.decryptedPrivateKey(fromPath: encryptedPath, passphrase: "wrongone"))
let decryptedViaPath = try! TLSBox.decryptedPrivateKey(fromPath: encryptedPath, passphrase: "foobar")
print(decryptedViaPath)
let encryptedPEM = try! String(contentsOfFile: encryptedPath, encoding: .utf8)
let decryptedViaString = try! TLSBox.decryptedPrivateKey(fromPEM: encryptedPEM, passphrase: "foobar")
print(decryptedViaString)
XCTAssertEqual(decryptedViaPath, decryptedViaString)

let expDecrypted = try! String(contentsOfFile: decryptedPath)
Expand Down
5 changes: 0 additions & 5 deletions Tests/TunnelKitOpenVPNTests/LinkTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ class LinkTests: XCTestCase {
enqueueControl(&q, &id, p) {
hdl.append($0)
}
print()
}
return hdl
}
Expand All @@ -163,10 +162,7 @@ class LinkTests: XCTestCase {
return (p1 < p2)
}

print("q = \(q)")
print("id = \(id)")
for p in q {
print("test(\(p))")
if p < id {
q.removeFirst()
continue
Expand All @@ -176,7 +172,6 @@ class LinkTests: XCTestCase {
}

h(p)
print("handle(\(p))")
id += 1
q.removeFirst()
}
Expand Down
4 changes: 0 additions & 4 deletions Tests/TunnelKitOpenVPNTests/PacketTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ class PacketTests: XCTestCase {

let serialized = ControlPacket(code: code, key: key, sessionId: sessionId, packetId: id, payload: payload).serialized()
let expected = Data(hex: "2311223344556677880000001456932748238742397591704891")
print("Serialized: \(serialized.toHex())")
print("Expected : \(expected.toHex())")

XCTAssertEqual(serialized, expected)
}
Expand All @@ -62,8 +60,6 @@ class PacketTests: XCTestCase {

let serialized = ControlPacket(key: key, sessionId: sessionId, ackIds: acks as [NSNumber], ackRemoteSessionId: remoteSessionId).serialized()
let expected = Data(hex: "2b112233445566778805000000aa000000bb000000cc000000dd000000eea639328cbf03490e")
print("Serialized: \(serialized.toHex())")
print("Expected : \(expected.toHex())")

XCTAssertEqual(serialized, expected)
}
Expand Down
8 changes: 1 addition & 7 deletions Tests/TunnelKitOpenVPNTests/PushTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@ import XCTest

private extension OpenVPN.PushReply {
func debug() {
print("Compression framing: \(options.compressionFraming?.description ?? "disabled")")
print("Compression algorithm: \(options.compressionAlgorithm?.description ?? "disabled")")
print("IPv4: \(options.ipv4?.description ?? "none")")
print("IPv6: \(options.ipv6?.description ?? "none")")
print("DNS: \(options.dnsServers?.description ?? "none")")
}
}

Expand Down Expand Up @@ -174,7 +169,6 @@ class PushTests: XCTestCase {
}

func testPeerInfo() {
let peerInfo = CoreConfiguration.OpenVPN.peerInfo()
print(peerInfo)
_ = CoreConfiguration.OpenVPN.peerInfo()
}
}

0 comments on commit 6435fa9

Please sign in to comment.