From ccc34920099363c9850a907539e11962e689a6a7 Mon Sep 17 00:00:00 2001 From: Sergey Abramchuk Date: Tue, 16 Jun 2020 13:06:35 +0300 Subject: [PATCH] Test connection without credentials --- .../OpenVPNAdapter/OpenVPNAdapterTests.swift | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/Tests/OpenVPNAdapter/OpenVPNAdapterTests.swift b/Tests/OpenVPNAdapter/OpenVPNAdapterTests.swift index e52baea..aa9d9da 100644 --- a/Tests/OpenVPNAdapter/OpenVPNAdapterTests.swift +++ b/Tests/OpenVPNAdapter/OpenVPNAdapterTests.swift @@ -112,6 +112,36 @@ class OpenVPNAdapterTests: XCTestCase { } } + // Test connection to the VPN server without credentials + func testConnectionWithoutCredentials() { + guard let vpnConfiguration = VPNProfile.withoutCredentials.configuration.data(using: .utf8) else { fatalError() } + + let adapter = OpenVPNAdapter() + + let configuration = OpenVPNConfiguration() + configuration.fileContent = vpnConfiguration + configuration.settings = VPNProfile.withoutCredentials.settings + + let result: OpenVPNProperties + do { + result = try adapter.apply(configuration: configuration) + } catch { + XCTFail("Failed to configure OpenVPN adapted due to error: \(error)") + return + } + + XCTAssertTrue(result.autologin) + + expectations[.connection] = expectation(description: "me.ss-abramchuk.openvpn-adapter.connection") + + adapter.delegate = self + adapter.connect(using: customFlow) + + waitForExpectations(timeout: 30.0) { (error) in + adapter.disconnect() + } + } + } extension OpenVPNAdapterTests: OpenVPNAdapterDelegate {