Import profiles with on-demand disabled (#641)

Make it friendly to Shortcuts automation by default.
This commit is contained in:
Davide 2024-09-30 17:40:24 +02:00 committed by GitHub
parent aead866275
commit 0e4dd086ef
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 11 additions and 6 deletions

View File

@ -32,7 +32,7 @@
"kind" : "remoteSourceControl",
"location" : "git@github.com:passepartoutvpn/passepartoutkit",
"state" : {
"revision" : "3d1a60be9722861f9de45e355d520bae33ac87a9"
"revision" : "fd4fe153c17a33d43a2e75d58512194ac3588eba"
}
},
{

View File

@ -31,7 +31,7 @@ let package = Package(
],
dependencies: [
// .package(url: "git@github.com:passepartoutvpn/passepartoutkit", from: "0.7.0"),
.package(url: "git@github.com:passepartoutvpn/passepartoutkit", revision: "3d1a60be9722861f9de45e355d520bae33ac87a9"),
.package(url: "git@github.com:passepartoutvpn/passepartoutkit", revision: "fd4fe153c17a33d43a2e75d58512194ac3588eba"),
// .package(path: "../../../passepartoutkit"),
.package(url: "git@github.com:passepartoutvpn/passepartoutkit-openvpn-openssl", from: "0.6.0"),
// .package(path: "../../../passepartoutkit-openvpn-openssl"),

View File

@ -125,11 +125,14 @@ private extension ProfileImporter {
}
let module = try registry.module(fromURL: url, object: passphrase)
var onDemandModuleBuilder = OnDemandModule.Builder()
onDemandModuleBuilder.isEnabled = false
let onDemandModule = onDemandModuleBuilder.tryBuild()
var builder = Profile.Builder()
builder.name = url.lastPathComponent
builder.modules = [module]
builder.activeModulesIds = [module.id]
builder.modules = [module, onDemandModule]
builder.activeModulesIds = Set(builder.modules.map(\.id))
let profile = try builder.tryBuild()
try await profileManager.save(profile)

View File

@ -61,8 +61,9 @@ extension ProfileImporterTests {
.sink {
switch $0 {
case .save(let profile):
XCTAssertEqual(profile.modules.count, 1)
XCTAssertEqual(profile.modules.count, 2)
XCTAssertTrue(profile.modules.first is SomeModule)
XCTAssertTrue(profile.modules.last is OnDemandModule)
exp.fulfill()
default:
@ -92,8 +93,9 @@ extension ProfileImporterTests {
.sink {
switch $0 {
case .save(let profile):
XCTAssertEqual(profile.modules.count, 1)
XCTAssertEqual(profile.modules.count, 2)
XCTAssertTrue(profile.modules.first is SomeModule)
XCTAssertTrue(profile.modules.last is OnDemandModule)
exp.fulfill()
default: