From 8f22710c878370211e5ca6d7f16f36bff17f85b5 Mon Sep 17 00:00:00 2001 From: Tony Eichelberger Date: Thu, 29 Jan 2026 16:32:23 -0600 Subject: [PATCH 1/5] AI generated removal of the big sur compatibility logic. Needs vetted and tested --- PPPC UtilityTests/ModelTests/ModelTests.swift | 197 +----------------- Resources/Base.lproj/Main.storyboard | 21 +- Source/Model/Model.swift | 52 +---- .../TCCProfileViewController.swift | 59 ------ 4 files changed, 12 insertions(+), 317 deletions(-) diff --git a/PPPC UtilityTests/ModelTests/ModelTests.swift b/PPPC UtilityTests/ModelTests/ModelTests.swift index a07cb54..85ea06e 100644 --- a/PPPC UtilityTests/ModelTests/ModelTests.swift +++ b/PPPC UtilityTests/ModelTests/ModelTests.swift @@ -130,7 +130,6 @@ class ModelTests: XCTestCase { func testExportProfileWithAppleEventsAndAuthorization() { // given - model.usingLegacyAllowKey = false let exe1 = Executable(identifier: "one", codeRequirement: "oneReq") let exe2 = Executable(identifier: "two", codeRequirement: "twoReq") @@ -185,65 +184,6 @@ class ModelTests: XCTestCase { } } - func testExportProfileWithAppleEventsAndLegacyAllowed() { - // given - let exe1 = Executable(identifier: "one", codeRequirement: "oneReq") - let exe2 = Executable(identifier: "two", codeRequirement: "twoReq") - - exe1.appleEvents = [AppleEventRule(source: exe1, destination: exe2, value: true)] - exe2.policy.SystemPolicyAllFiles = "Allow" - - model.selectedExecutables = [exe1, exe2] - model.usingLegacyAllowKey = true - - // when - let profile = model.exportProfile(organization: "Org", identifier: "ID", displayName: "Name", payloadDescription: "Desc") - - // then check top level settings - XCTAssertEqual("Org", profile.organization) - XCTAssertEqual("ID", profile.identifier) - XCTAssertEqual("Name", profile.displayName) - XCTAssertEqual("Desc", profile.payloadDescription) - XCTAssertEqual("System", profile.scope) - XCTAssertEqual("Configuration", profile.type) - XCTAssertNotNil(profile.uuid) - XCTAssertEqual(1, profile.version) - - // then check policy settings - // then verify the payload content top level - XCTAssertEqual(1, profile.content.count) - profile.content.forEach { content in - XCTAssertNotNil(content.uuid) - XCTAssertEqual(1, content.version) - - // then verify the services - XCTAssertEqual(2, content.services.count) - let appleEvents = content.services["AppleEvents"] - XCTAssertNotNil(appleEvents) - let appleEventsPolicy = appleEvents?.first - XCTAssertEqual("one", appleEventsPolicy?.identifier) - XCTAssertEqual("oneReq", appleEventsPolicy?.codeRequirement) - XCTAssertEqual("bundleID", appleEventsPolicy?.identifierType) - XCTAssertEqual("two", appleEventsPolicy?.receiverIdentifier) - XCTAssertEqual("twoReq", appleEventsPolicy?.receiverCodeRequirement) - XCTAssertEqual("bundleID", appleEventsPolicy?.receiverIdentifierType) - XCTAssertTrue(appleEventsPolicy?.allowed == true) - XCTAssertNil(appleEventsPolicy?.authorization) - - let allFiles = content.services["SystemPolicyAllFiles"] - XCTAssertNotNil(allFiles) - let allFilesPolicy = allFiles?.first - XCTAssertEqual("two", allFilesPolicy?.identifier) - XCTAssertEqual("twoReq", allFilesPolicy?.codeRequirement) - XCTAssertEqual("bundleID", allFilesPolicy?.identifierType) - XCTAssertNil(allFilesPolicy?.receiverIdentifier) - XCTAssertNil(allFilesPolicy?.receiverCodeRequirement) - XCTAssertNil(allFilesPolicy?.receiverIdentifierType) - XCTAssertTrue(allFilesPolicy?.allowed == true) - XCTAssertNil(allFilesPolicy?.authorization) - } - } - // MARK: - tests for importProfile func testImportProfileUsingAuthorizationKeyAllow() { @@ -330,11 +270,10 @@ class ModelTests: XCTestCase { XCTAssertEqual("Deny", model.selectedExecutables.first?.policy.SystemPolicyAllFiles) } - // MARK: - tests for profileToString + // MARK: - tests for policyFromString - func testPolicyWhenUsingAllowAndAuthorizationKey() { + func testPolicyWhenUsingAllow() { // given - model.usingLegacyAllowKey = false let app = Executable(identifier: "id", codeRequirement: "req") // when @@ -347,7 +286,6 @@ class ModelTests: XCTestCase { func testPolicyWhenUsingDeny() { // given - model.usingLegacyAllowKey = false let app = Executable(identifier: "id", codeRequirement: "req") // when @@ -360,7 +298,6 @@ class ModelTests: XCTestCase { func testPolicyWhenUsingAllowForStandardUsers() { // given - model.usingLegacyAllowKey = false let app = Executable(identifier: "id", codeRequirement: "req") // when @@ -382,134 +319,4 @@ class ModelTests: XCTestCase { XCTAssertNil(policy, "should have not created the policy with an unknown value") } - func testPolicyWhenUsingLegacyDeny() { - // given - let app = Executable(identifier: "id", codeRequirement: "req") - model.usingLegacyAllowKey = true - - // when - let policy = model.policyFromString(executable: app, value: "Deny") - - // then - XCTAssertNil(policy?.authorization, "should not set authorization when in legacy mode") - XCTAssertEqual(policy?.allowed, false) - } - - func testPolicyWhenUsingLegacyAllow() { - // given - let app = Executable(identifier: "id", codeRequirement: "req") - model.usingLegacyAllowKey = true - - // when - let policy = model.policyFromString(executable: app, value: "Allow") - - // then - XCTAssertNil(policy?.authorization, "should not set authorization when in legacy mode") - XCTAssertEqual(policy?.allowed, true) - } - - // test for the unrecognized strings for both legacy and normal - func testPolicyWhenUsingLegacyAllowButNonLegacyValueUsed() { - // given - let app = Executable(identifier: "id", codeRequirement: "req") - model.usingLegacyAllowKey = true - - // when - let policy = model.policyFromString(executable: app, value: "Let Standard Users Approve") - - // then - XCTAssertNil(policy, "should have errored out because of an invalid value") - } - - // MARK: - tests for requiresAuthorizationKey - - func testWhenServiceIsUsingAllowStandarUsersToApprove() { - // given - let profile = TCCProfileBuilder().buildProfile(authorization: .allowStandardUserToSetSystemService) - - // when - model.importProfile(tccProfile: profile) - - // then - XCTAssertTrue(model.requiresAuthorizationKey()) - } - - func testWhenServiceIsUsingOnlyAllowKey() { - // given - let profile = TCCProfileBuilder().buildProfile(authorization: .allow) - - // when - model.importProfile(tccProfile: profile) - - // then - XCTAssertFalse(model.requiresAuthorizationKey()) - } - - func testWhenServiceIsUsingOnlyDenyKey() { - // given - let profile = TCCProfileBuilder().buildProfile(authorization: .deny) - - // when - model.importProfile(tccProfile: profile) - - // then - XCTAssertFalse(model.requiresAuthorizationKey()) - } - - // MARK: - tests for changeToUseLegacyAllowKey - - func testChangingFromAuthorizationKeyToLegacyAllowKey() { - // given - let allowStandard = TCCProfileDisplayValue.allowStandardUsersToApprove.rawValue - let exeSettings = ["AddressBook": "Allow", "ListenEvent": allowStandard, "ScreenCapture": allowStandard] - let model = ModelBuilder().addExecutable(settings: exeSettings).build() - model.usingLegacyAllowKey = false - - // when - model.changeToUseLegacyAllowKey() - - // then - XCTAssertEqual(1, model.selectedExecutables.count, "should have only one exe") - let policy = model.selectedExecutables.first?.policy - XCTAssertEqual("Allow", policy?.AddressBook) - XCTAssertEqual("-", policy?.Camera) - XCTAssertEqual("-", policy?.ListenEvent) - XCTAssertEqual("-", policy?.ScreenCapture) - XCTAssertTrue(model.usingLegacyAllowKey) - } - - func testChangingFromAuthorizationKeyToLegacyAllowKeyWithMoreComplexVaues() { - // given - let allowStandard = TCCProfileDisplayValue.allowStandardUsersToApprove.rawValue - let p1Settings = ["SystemPolicyAllFiles": "Allow", - "ListenEvent": allowStandard, - "ScreenCapture": "Deny", - "Camera": "Deny"] - - let p2Settings = ["SystemPolicyAllFiles": "Deny", - "ScreenCapture": allowStandard, - "Calendar": "Allow"] - let builder = ModelBuilder().addExecutable(settings: p1Settings) - model = builder.addExecutable(settings: p2Settings).build() - model.usingLegacyAllowKey = false - - // when - model.changeToUseLegacyAllowKey() - - // then - XCTAssertEqual(2, model.selectedExecutables.count, "should have only one exe") - let policy1 = model.selectedExecutables[0].policy - XCTAssertEqual("Allow", policy1.SystemPolicyAllFiles) - XCTAssertEqual("-", policy1.ListenEvent) - XCTAssertEqual("Deny", policy1.ScreenCapture) - XCTAssertEqual("Deny", policy1.Camera) - - let policy2 = model.selectedExecutables[1].policy - XCTAssertEqual("Deny", policy2.SystemPolicyAllFiles) - XCTAssertEqual("-", policy2.ListenEvent) - XCTAssertEqual("-", policy2.ScreenCapture) - XCTAssertEqual("Allow", policy2.Calendar) - XCTAssertTrue(model.usingLegacyAllowKey) - } - } diff --git a/Resources/Base.lproj/Main.storyboard b/Resources/Base.lproj/Main.storyboard index 76e1e55..bd1a5b6 100644 --- a/Resources/Base.lproj/Main.storyboard +++ b/Resources/Base.lproj/Main.storyboard @@ -2397,20 +2397,6 @@ - - - - - - - - - - - - - -