Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Help buttons list related codesigning entitlements (#105, #104) #108

Merged
merged 6 commits into from
Feb 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

## [Unreleased]
<!-- Add any information here about changes in master that have yet to be released -->
### Added
- (@macblazer) Help buttons now list related codesigning entitlements (issue #105).

### Changed
- (@macblazer) Now reads profile keys in a case-insensitive manner during import (issue #88).

Expand Down Expand Up @@ -89,7 +92,9 @@ Initial release

<!-- -->

[unreleased]: https://github.com/jamf/PPPC-Utility/compare/1.2.1...master
[unreleased]: https://github.com/jamf/PPPC-Utility/compare/1.4.0...master
[1.4.0]: https://github.com/jamf/PPPC-Utility/compare/1.3.0...1.4.0
[1.3.0]: https://github.com/jamf/PPPC-Utility/compare/1.2.1...1.3.0
[1.2.1]: https://github.com/jamf/PPPC-Utility/compare/1.2.0...1.2.1
[1.2.0]: https://github.com/jamf/PPPC-Utility/compare/1.1.2...1.2.0
[1.1.2]: https://github.com/jamf/PPPC-Utility/compare/1.1.1...1.1.2
Expand Down
30 changes: 21 additions & 9 deletions PPPC Utility.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
5F95AE302315B172002E0A22 /* TestTCCProfileSigned-Broken.mobileconfig in Resources */ = {isa = PBXBuildFile; fileRef = 5F95AE2B2315B172002E0A22 /* TestTCCProfileSigned-Broken.mobileconfig */; };
5F95AE312315B172002E0A22 /* TestTCCUnsignedProfile-Empty.mobileconfig in Resources */ = {isa = PBXBuildFile; fileRef = 5F95AE2C2315B172002E0A22 /* TestTCCUnsignedProfile-Empty.mobileconfig */; };
6E6216F9215321CE0043DF18 /* OpenViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E6216F8215321CE0043DF18 /* OpenViewController.swift */; };
6E651CC523143890001CC974 /* ProfilesDescriptions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E651CC423143890001CC974 /* ProfilesDescriptions.swift */; };
6E651CC82314397D001CC974 /* FlippedClipView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E651CC72314397D001CC974 /* FlippedClipView.swift */; };
6E651CCA231439CE001CC974 /* InfoButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E651CC9231439CE001CC974 /* InfoButton.swift */; };
6EB45830214FFCCB00BE5749 /* AppleEventRule.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6EB4582F214FFCCB00BE5749 /* AppleEventRule.swift */; };
Expand All @@ -43,6 +42,10 @@
71061E54246106C800822D35 /* LoadExecutableError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 71061E53246106C800822D35 /* LoadExecutableError.swift */; };
B5E09548250BCCFC00A40409 /* Alert.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5E09547250BCCFC00A40409 /* Alert.swift */; };
C0A85DB5279873C600086283 /* TestTCCUnsignedProfile-allLower.mobileconfig in Resources */ = {isa = PBXBuildFile; fileRef = C0A85DB4279873C600086283 /* TestTCCUnsignedProfile-allLower.mobileconfig */; };
C0E0383F27A30C7100A23FA2 /* PPPCServiceInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0E0383D27A30C7100A23FA2 /* PPPCServiceInfo.swift */; };
C0E0384027A30C7100A23FA2 /* PPPCServicesManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0E0383E27A30C7100A23FA2 /* PPPCServicesManager.swift */; };
C0E0384227A30D1D00A23FA2 /* PPPCServices.json in Resources */ = {isa = PBXBuildFile; fileRef = C0E0384127A30D1D00A23FA2 /* PPPCServices.json */; };
C0E0384427A30D6B00A23FA2 /* PPPCServicesManagerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0E0384327A30D6B00A23FA2 /* PPPCServicesManagerTests.swift */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -75,7 +78,6 @@
5F95AE2C2315B172002E0A22 /* TestTCCUnsignedProfile-Empty.mobileconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = "TestTCCUnsignedProfile-Empty.mobileconfig"; sourceTree = "<group>"; };
6E5D5A1521541B8F00B43312 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
6E6216F8215321CE0043DF18 /* OpenViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OpenViewController.swift; sourceTree = "<group>"; };
6E651CC423143890001CC974 /* ProfilesDescriptions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProfilesDescriptions.swift; sourceTree = "<group>"; };
6E651CC72314397D001CC974 /* FlippedClipView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FlippedClipView.swift; sourceTree = "<group>"; };
6E651CC9231439CE001CC974 /* InfoButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InfoButton.swift; sourceTree = "<group>"; };
6E95730721553B650002C30B /* LICENSE */ = {isa = PBXFileReference; lastKnownFileType = text; path = LICENSE; sourceTree = "<group>"; };
Expand All @@ -99,6 +101,10 @@
97227C6726248CD7000F26C1 /* CHANGELOG.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = CHANGELOG.md; sourceTree = "<group>"; };
B5E09547250BCCFC00A40409 /* Alert.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Alert.swift; sourceTree = "<group>"; };
C0A85DB4279873C600086283 /* TestTCCUnsignedProfile-allLower.mobileconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = "TestTCCUnsignedProfile-allLower.mobileconfig"; sourceTree = "<group>"; };
C0E0383D27A30C7100A23FA2 /* PPPCServiceInfo.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PPPCServiceInfo.swift; sourceTree = "<group>"; };
C0E0383E27A30C7100A23FA2 /* PPPCServicesManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PPPCServicesManager.swift; sourceTree = "<group>"; };
C0E0384127A30D1D00A23FA2 /* PPPCServices.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = PPPCServices.json; sourceTree = "<group>"; };
C0E0384327A30D6B00A23FA2 /* PPPCServicesManagerTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PPPCServicesManagerTests.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -141,6 +147,7 @@
isa = PBXGroup;
children = (
5F90EBE32319992B00738D09 /* ModelTests.swift */,
C0E0384327A30D6B00A23FA2 /* PPPCServicesManagerTests.swift */,
);
path = ModelTests;
sourceTree = "<group>";
Expand Down Expand Up @@ -243,6 +250,7 @@
6EC409E1214D65BD00BE4F17 /* Assets.xcassets */,
6EC409E3214D65BD00BE4F17 /* Main.storyboard */,
6EC409E6214D65BD00BE4F17 /* Info.plist */,
C0E0384127A30D1D00A23FA2 /* PPPCServices.json */,
6E957309215557870002C30B /* PPPC Utility.entitlements */,
);
path = Resources;
Expand All @@ -251,13 +259,14 @@
6EC40A1D214EF87E00BE4F17 /* Model */ = {
isa = PBXGroup;
children = (
6EC40A1B214EF87800BE4F17 /* SigningIdentity.swift */,
6EC40A13214DFB5800BE4F17 /* Model.swift */,
6EC40A0F214DE3B200BE4F17 /* Executable.swift */,
6EC409F4214D95D200BE4F17 /* TCCProfile.swift */,
6EB4582F214FFCCB00BE5749 /* AppleEventRule.swift */,
6E651CC423143890001CC974 /* ProfilesDescriptions.swift */,
6EC40A0F214DE3B200BE4F17 /* Executable.swift */,
71061E53246106C800822D35 /* LoadExecutableError.swift */,
6EC40A13214DFB5800BE4F17 /* Model.swift */,
C0E0383D27A30C7100A23FA2 /* PPPCServiceInfo.swift */,
C0E0383E27A30C7100A23FA2 /* PPPCServicesManager.swift */,
6EC40A1B214EF87800BE4F17 /* SigningIdentity.swift */,
6EC409F4214D95D200BE4F17 /* TCCProfile.swift */,
);
path = Model;
sourceTree = "<group>";
Expand Down Expand Up @@ -378,6 +387,7 @@
buildActionMask = 2147483647;
files = (
6EC409E2214D65BD00BE4F17 /* Assets.xcassets in Resources */,
C0E0384227A30D1D00A23FA2 /* PPPCServices.json in Resources */,
6EC409E5214D65BD00BE4F17 /* Main.storyboard in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand All @@ -401,7 +411,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if which swiftlint >/dev/null; then\n swiftlint\nelse\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi\n";
shellScript = "export PATH=\"$PATH:/opt/homebrew/bin\"\n\nif which swiftlint >/dev/null; then\n swiftlint\nelse\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi\n";
};
/* End PBXShellScriptBuildPhase section */

Expand All @@ -416,6 +426,7 @@
5901A2772534DF1400A1CD2F /* ModelBuilder.swift in Sources */,
59798B82252D16310070A204 /* TCCProfileBuilder.swift in Sources */,
5F90EBE42319992B00738D09 /* ModelTests.swift in Sources */,
C0E0384427A30D6B00A23FA2 /* PPPCServicesManagerTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -431,9 +442,10 @@
5F90EBDD2319934F00738D09 /* ArrayExtensions.swift in Sources */,
6EC40A14214DFB5800BE4F17 /* Model.swift in Sources */,
71061E54246106C800822D35 /* LoadExecutableError.swift in Sources */,
C0E0383F27A30C7100A23FA2 /* PPPCServiceInfo.swift in Sources */,
6EC40A1C214EF87800BE4F17 /* SigningIdentity.swift in Sources */,
6EC40A18214ECF2C00BE4F17 /* UploadViewController.swift in Sources */,
6E651CC523143890001CC974 /* ProfilesDescriptions.swift in Sources */,
C0E0384027A30C7100A23FA2 /* PPPCServicesManager.swift in Sources */,
6E651CCA231439CE001CC974 /* InfoButton.swift in Sources */,
6EC409F5214D95D200BE4F17 /* TCCProfile.swift in Sources */,
6EC40A12214DF8FE00BE4F17 /* SecurityWrapper.swift in Sources */,
Expand Down
90 changes: 90 additions & 0 deletions PPPC UtilityTests/ModelTests/PPPCServicesManagerTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
//
// PPPCServicesManagerTests.swift
// PPPC UtilityTests
//
// MIT License
//
// Copyright (c) 2022 Jamf Software
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//

import Foundation
import XCTest

@testable import PPPC_Utility

class PPPCServicesManagerTests: XCTestCase {

func testLoadAllServices() {
// given/when
let actual = PPPCServicesManager()

// then
XCTAssertEqual(actual.allServices.count, 21)
}

func testUserHelp_withEntitlements() throws {
// given
let services = PPPCServicesManager()
let service = try XCTUnwrap(services.allServices["Camera"])

// when
let actual = service.userHelp

// then
XCTAssertEqual(actual, "Use to deny specified apps access to the camera.\n\nMDM Key: Camera\nRelated entitlements: [\"com.apple.developer.avfoundation.multitasking-camera-access\", \"com.apple.security.device.camera\"]")
}

func testUserHelp_withoutEntitlements() throws {
// given
let services = PPPCServicesManager()
let service = try XCTUnwrap(services.allServices["ScreenCapture"])

// when
let actual = service.userHelp

// then
XCTAssertEqual(actual, "Deny specified apps access to capture (read) the contents of the system display.\n\nMDM Key: ScreenCapture")
}

func testCameraIsDenyOnly() throws {
// given
let services = PPPCServicesManager()
let service = try XCTUnwrap(services.allServices["Camera"])

// when
let actual = try XCTUnwrap(service.denyOnly)

// then
XCTAssertTrue(actual)
}

func testScreenCaptureAllowsStandardUsers() throws {
// given
let services = PPPCServicesManager()
let service = try XCTUnwrap(services.allServices["ScreenCapture"])

// when
let actual = try XCTUnwrap(service.allowStandardUsersMacOS11Plus)

// then
XCTAssertTrue(actual)
}
}
Loading