diff --git a/Library/Package.resolved b/Library/Package.resolved index 63295a757..9ec767f9e 100644 --- a/Library/Package.resolved +++ b/Library/Package.resolved @@ -41,8 +41,7 @@ "kind" : "remoteSourceControl", "location" : "git@github.com:passepartoutvpn/passepartoutkit-source", "state" : { - "revision" : "e8833c9416503026ba933adcb6c5850a9db2f13b", - "version" : "0.12.0" + "revision" : "aa85d745f8419def59ef630501d71a491a32829e" } }, { diff --git a/Library/Package.swift b/Library/Package.swift index b45eeb690..f0b884007 100644 --- a/Library/Package.swift +++ b/Library/Package.swift @@ -51,8 +51,8 @@ let package = Package( ) ], dependencies: [ - .package(url: "git@github.com:passepartoutvpn/passepartoutkit-source", from: "0.12.0"), -// .package(url: "git@github.com:passepartoutvpn/passepartoutkit-source", revision: "e8833c9416503026ba933adcb6c5850a9db2f13b"), +// .package(url: "git@github.com:passepartoutvpn/passepartoutkit-source", from: "0.12.0"), + .package(url: "git@github.com:passepartoutvpn/passepartoutkit-source", revision: "aa85d745f8419def59ef630501d71a491a32829e"), // .package(path: "../../passepartoutkit-source"), .package(url: "git@github.com:passepartoutvpn/passepartoutkit-source-openvpn-openssl", from: "0.9.1"), // .package(url: "git@github.com:passepartoutvpn/passepartoutkit-source-openvpn-openssl", revision: "031863a1cd683962a7dfe68e20b91fa820a1ecce"), diff --git a/Library/Tests/AppUIMainTests/ProfileImporterTests.swift b/Library/Tests/AppUIMainTests/ProfileImporterTests.swift index dd6d75afb..67e714b0f 100644 --- a/Library/Tests/AppUIMainTests/ProfileImporterTests.swift +++ b/Library/Tests/AppUIMainTests/ProfileImporterTests.swift @@ -31,10 +31,7 @@ import PassepartoutKit import XCTest final class ProfileImporterTests: XCTestCase { - private let registry = Registry( - allHandlers: [SomeModule.moduleHandler], - allImplementations: [SomeModule.Implementation()] - ) + private let moduleImporter = SomeModule.Implementation() private var subscriptions: Set = [] } @@ -45,7 +42,7 @@ extension ProfileImporterTests { let sut = ProfileImporter() let profileManager = ProfileManager(profiles: []) - try await sut.tryImport(urls: [], profileManager: profileManager, registry: registry) + try await sut.tryImport(urls: [], profileManager: profileManager, importer: moduleImporter) XCTAssertEqual(sut.nextURL, nil) XCTAssertTrue(profileManager.previews.isEmpty) } @@ -75,7 +72,7 @@ extension ProfileImporterTests { try await sut.tryImport( urls: [url], profileManager: profileManager, - registry: registry + importer: moduleImporter ) XCTAssertEqual(sut.nextURL, nil) @@ -107,12 +104,12 @@ extension ProfileImporterTests { try await sut.tryImport( urls: [url], profileManager: profileManager, - registry: registry + importer: moduleImporter ) XCTAssertEqual(sut.nextURL, url) sut.currentPassphrase = "passphrase" - try await sut.reImport(url: url, profileManager: profileManager, registry: registry) + try await sut.reImport(url: url, profileManager: profileManager, importer: moduleImporter) XCTAssertEqual(sut.nextURL, nil) await fulfillment(of: [exp]) @@ -126,29 +123,37 @@ extension ProfileImporterTests { try await sut.tryImport( urls: [url, url, url], profileManager: profileManager, - registry: registry + importer: moduleImporter ) XCTAssertEqual(sut.nextURL, url) XCTAssertEqual(sut.urlsRequiringPassphrase.count, 3) } } +// MARK: - + private struct SomeModule: Module { - struct Implementation: ModuleImplementation, ModuleImporter { + struct Implementation: ModuleImplementation { var moduleHandlerId: ModuleHandler.ID { moduleHandler.id } + } +} - func module(fromURL url: URL, object: Any?) throws -> Module { - if url.absoluteString.hasSuffix(".encrypted") { - guard let passphrase = object as? String else { - throw PassepartoutError(.OpenVPN.passphraseRequired) - } - guard passphrase == "passphrase" else { - throw PassepartoutError(.crypto) - } +extension SomeModule.Implementation: ModuleImporter { + func module(fromContents contents: String, object: Any?) throws -> Module { + fatalError() + } + + func module(fromURL url: URL, object: Any?) throws -> Module { + if url.absoluteString.hasSuffix(".encrypted") { + guard let passphrase = object as? String else { + throw PassepartoutError(.OpenVPN.passphraseRequired) + } + guard passphrase == "passphrase" else { + throw PassepartoutError(.crypto) } - return SomeModule() } + return SomeModule() } }