SPM-related refactoring

This commit is contained in:
kabiroberai
2021-08-01 11:02:05 +05:30
committed by Kabir Oberai
Unverified
parent a501ccb3c5
commit efed4185e2
10 changed files with 53 additions and 6 deletions
+2
View File
@@ -0,0 +1,2 @@
/Tests/SupersignTests/config/*
!/Tests/SupersignTests/config/config-template.json
+14
View File
@@ -58,6 +58,20 @@ let package = Package(
],
cSettings: cSettings
),
.testTarget(
name: "SupersignTests",
dependencies: [
"Supersign",
.product(name: "SuperutilsTestSupport", package: "SuperchargeCore")
],
exclude: [
"config/config-template.json",
],
resources: [
.copy("config/config.json"),
.copy("config/test.app"),
]
),
.target(
name: "SupersignCLI",
dependencies: [
@@ -7,6 +7,7 @@
//
import XCTest
import SuperutilsTestSupport
import Supersign
class SupersignDeveloperServicesTests: XCTestCase {
@@ -15,6 +16,7 @@ class SupersignDeveloperServicesTests: XCTestCase {
override func setUp() {
super.setUp()
_ = addMockSigner
client = .test()
}
@@ -29,11 +31,11 @@ class SupersignDeveloperServicesTests: XCTestCase {
let teams = try XCTTry(client.sendTest(listTeams))
let team = teams.first { $0.status == "active" && $0.memberships.contains { $0.platform == .iOS } }!
let bundle = Bundle(for: Self.self)
let source = try XCTUnwrap(bundle.url(forResource: "test", withExtension: "app"))
let source = try XCTUnwrap(Bundle.module.url(forResource: "test", withExtension: "app"))
let context = try XCTTry(SigningContext(
udid: Config.current.udid,
deviceName: SigningContext.hostName,
teamID: team.id,
client: client,
signingInfoManager: MemoryBackedSigningInfoManager()
@@ -7,6 +7,7 @@
//
import XCTest
import SuperutilsTestSupport
@testable import Supersign
class TwoFactorAuthenticator: TwoFactorAuthDelegate {
@@ -23,6 +24,7 @@ class SupersignGrandSlamTests: XCTestCase {
override func setUp() {
super.setUp()
_ = addMockSigner
client = .test()
authenticator = TwoFactorAuthenticator()
}
@@ -6,7 +6,12 @@
// Copyright © 2019 Kabir Oberai. All rights reserved.
//
// TODO: Test using mock signer
#if false
import XCTest
import SuperutilsTestSupport
import Supersign
class SupersignSigningTests: XCTestCase {
@@ -18,11 +23,11 @@ class SupersignSigningTests: XCTestCase {
// swiftlint:disable force_try
override func setUp() {
super.setUp()
_ = addMockSigner
client = .test()
signerImpl = try! SignerImpl.first()
let bundle = Bundle(for: Self.self)
let source = try! XCTUnwrap(bundle.url(forResource: "test", withExtension: "app"))
let source = try! XCTUnwrap(Bundle.module.url(forResource: "test", withExtension: "app"))
let tmp = FileManager.default.temporaryDirectory
app = tmp.appendingPathComponent(source.lastPathComponent)
if FileManager.default.fileExists(atPath: app.path) {
@@ -48,6 +53,7 @@ class SupersignSigningTests: XCTestCase {
let context = try XCTTry(SigningContext(
udid: Config.current.udid,
deviceName: SigningContext.hostName,
teamID: team.id,
client: client,
signingInfoManager: MemoryBackedSigningInfoManager(),
@@ -82,3 +88,5 @@ class SupersignSigningTests: XCTestCase {
}
}
#endif
@@ -23,8 +23,7 @@ struct Config: Decodable {
let udid: String
static let current: Config = {
class ConfigDummy {}
let url = Bundle(for: ConfigDummy.self).url(forResource: "config", withExtension: "json")!
let url = Bundle.module.url(forResource: "config", withExtension: "json")!
// swiftlint:disable:next force_try
let data = try! Data(contentsOf: url)
// swiftlint:disable:next force_try
@@ -10,6 +10,8 @@ import Foundation
import XCTest
@testable import Supersign
#if false
extension TCPAnisetteDataProvider {
static func test() -> TCPAnisetteDataProvider {
@@ -26,6 +28,8 @@ extension NetcatAnisetteDataProvider {
}
#endif
extension SupersetteDataProvider {
static func test() -> SupersetteDataProvider {
@@ -0,0 +1,16 @@
import Foundation
import SignerSupport
let addMockSigner: () = {
add_signer(
"MockSigner",
{ appDir, certData, certLen, privKeyData, privKeyLen, entitlements, numEntitlements, progress, exception in
exception.initialize(to: strdup("Mock signer not implemented"))
return 1
},
{ path, outLen, exception in
exception.initialize(to: strdup("Mock analyzer not implemented"))
return nil
}
)
}()