Test and fix behavior with compression options
Changes in #20 were insufficient.
This commit is contained in:
parent
c1065751b6
commit
f2b5c05d58
|
@ -236,8 +236,12 @@ extension TunnelKitProvider.Configuration {
|
|||
isHandled = true
|
||||
compressionFraming = .compLZO
|
||||
|
||||
guard let arg = $0.first, arg == "no" else {
|
||||
warning = warning ?? .unsupportedConfiguration(option: "compression")
|
||||
guard let arg = $0.first else {
|
||||
warning = warning ?? .unsupportedConfiguration(option: line)
|
||||
return
|
||||
}
|
||||
guard arg == "no" else {
|
||||
unsupportedError = .unsupportedConfiguration(option: line)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
@ -246,7 +250,7 @@ extension TunnelKitProvider.Configuration {
|
|||
compressionFraming = .compress
|
||||
|
||||
guard $0.isEmpty else {
|
||||
warning = warning ?? .unsupportedConfiguration(option: "compression")
|
||||
unsupportedError = .unsupportedConfiguration(option: line)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,6 +55,17 @@ class FileConfigurationTests: XCTestCase {
|
|||
print(stripped)
|
||||
}
|
||||
|
||||
func testCompression() throws {
|
||||
let base: [String] = ["<ca>", "</ca>", "remote 1.2.3.4"]
|
||||
|
||||
XCTAssertNotNil(try TunnelKitProvider.Configuration.parsed(fromLines: base + ["comp-lzo"]).warning)
|
||||
XCTAssertNoThrow(try TunnelKitProvider.Configuration.parsed(fromLines: base + ["comp-lzo no"]))
|
||||
XCTAssertThrowsError(try TunnelKitProvider.Configuration.parsed(fromLines: base + ["comp-lzo yes"]))
|
||||
|
||||
XCTAssertNoThrow(try TunnelKitProvider.Configuration.parsed(fromLines: base + ["compress"]))
|
||||
XCTAssertThrowsError(try TunnelKitProvider.Configuration.parsed(fromLines: base + ["compress lzo"]))
|
||||
}
|
||||
|
||||
private func url(withName name: String) -> URL {
|
||||
return Bundle(for: FileConfigurationTests.self).url(forResource: name, withExtension: "ovpn")!
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue