diff --git a/.github/workflows/swiftlint.yml b/.github/workflows/swiftlint.yml index 4ca6626..b35dc26 100644 --- a/.github/workflows/swiftlint.yml +++ b/.github/workflows/swiftlint.yml @@ -7,6 +7,9 @@ on: - '.swiftlint.yml' - '**/*.swift' +permissions: + contents: read + jobs: SwiftLint: runs-on: ubuntu-latest diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..d5d148e --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,25 @@ +name: Unit Tests + +on: + pull_request: + paths: + - '.github/workflows/tests.yml' + - '**/*.swift' + +permissions: + contents: read + +jobs: + test: + runs-on: macos-latest + steps: + - uses: actions/checkout@v4 + + - name: Run unit tests + run: | + xcodebuild test \ + -project "PPPC Utility.xcodeproj" \ + -scheme "PPPC Utility" \ + -destination "platform=macOS" \ + CODE_SIGN_IDENTITY="-" \ + CODE_SIGNING_REQUIRED=NO diff --git a/PPPC UtilityTests/TCCProfileImporterTests/TCCProfileImporterTests.swift b/PPPC UtilityTests/TCCProfileImporterTests/TCCProfileImporterTests.swift index c17d883..a70dc76 100644 --- a/PPPC UtilityTests/TCCProfileImporterTests/TCCProfileImporterTests.swift +++ b/PPPC UtilityTests/TCCProfileImporterTests/TCCProfileImporterTests.swift @@ -32,7 +32,7 @@ import XCTest class TCCProfileImporterTests: XCTestCase { - func testBrokenSignedTCCProfile() { + func testMalformedTCCProfile() { let tccProfileImporter = TCCProfileImporter() let resourceURL = getResourceProfile(fileName: "TestTCCProfileSigned-Broken") @@ -40,9 +40,11 @@ class TCCProfileImporterTests: XCTestCase { tccProfileImporter.decodeTCCProfile(fileUrl: resourceURL) { tccProfileResult in switch tccProfileResult { case .success: - XCTFail("Broken Signed Profile, it shouldn't be success") + XCTFail("Malformed profile should not succeed") case .failure(let tccProfileError): - XCTAssertTrue(tccProfileError.localizedDescription.contains("The given data was not a valid property list.")) + if case TCCProfileImportError.invalidProfileFile = tccProfileError { } else { + XCTFail("Expected invalidProfileFile error, got \(tccProfileError)") + } } } } diff --git a/Source/View Controllers/TCCProfileViewController.swift b/Source/View Controllers/TCCProfileViewController.swift index 521108d..835439a 100644 --- a/Source/View Controllers/TCCProfileViewController.swift +++ b/Source/View Controllers/TCCProfileViewController.swift @@ -24,6 +24,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. // +// swiftlint:disable file_length import Cocoa import OSLog