9
9
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10
10
//
11
11
//===----------------------------------------------------------------------===//
12
-
12
+ import Foundation
13
+ import Testing
13
14
import XCTest
14
15
15
16
import Basics
16
17
@testable import PackageSigning
17
18
import _InternalTestSupport
18
19
import X509
19
20
20
- final class SigningEntityTests : XCTestCase {
21
- func testTwoADPSigningEntitiesAreEqualIfTeamIDEqual( ) {
21
+ struct SigningEntityTests {
22
+ @Test
23
+ func twoADPSigningEntitiesAreEqualIfTeamIDEqual( ) {
22
24
let adp1 = SigningEntity . recognized (
23
25
type: . adp,
24
26
name: " A. Appleseed " ,
@@ -37,48 +39,39 @@ final class SigningEntityTests: XCTestCase {
37
39
organizationalUnit: " SwiftPM Test Unit Y " ,
38
40
organization: " C "
39
41
)
40
- XCTAssertEqual ( adp1, adp2) // Only team ID (org unit) needs to match
41
- XCTAssertNotEqual ( adp1, adp3)
42
+ #expect ( adp1 == adp2) // Only team ID (org unit) needs to match
43
+ #expect ( adp1 != adp3)
42
44
}
43
45
44
- func testFromECKeyCertificate( ) throws {
46
+ @Test (
47
+ " From certificate key " ,
48
+ arguments: [
49
+ ( certificateFilename: " Test_ec.cer " , id: " EC Key " ) ,
50
+ ( certificateFilename: " Test_rsa.cer " , id: " RSA Key " )
51
+ ]
52
+ )
53
+ func fromCertificate( certificateFilename: String , id: String ) throws {
45
54
try fixture ( name: " Signing " , createGitRepo: false ) { fixturePath in
46
55
let certificateBytes = try readFileContents (
47
56
in: fixturePath,
48
57
pathComponents: " Certificates " ,
49
- " Test_ec.cer "
58
+ certificateFilename
50
59
)
51
60
let certificate = try Certificate ( certificateBytes)
52
61
53
62
let signingEntity = SigningEntity . from ( certificate: certificate)
54
63
guard case . unrecognized( let name, let organizationalUnit, let organization) = signingEntity else {
55
- return XCTFail ( " Expected SigningEntity.unrecognized but got \( signingEntity) " )
64
+ Issue . record ( " Expected SigningEntity.unrecognized but got \( signingEntity) " )
65
+ return
56
66
}
57
- XCTAssertEqual ( name, certificate. subject. commonName)
58
- XCTAssertEqual ( organizationalUnit, certificate. subject. organizationalUnitName)
59
- XCTAssertEqual ( organization, certificate. subject. organizationName)
60
- }
61
- }
62
-
63
- func testFromRSAKeyCertificate( ) throws {
64
- try fixture ( name: " Signing " , createGitRepo: false ) { fixturePath in
65
- let certificateBytes = try readFileContents (
66
- in: fixturePath,
67
- pathComponents: " Certificates " ,
68
- " Test_rsa.cer "
69
- )
70
- let certificate = try Certificate ( certificateBytes)
71
-
72
- let signingEntity = SigningEntity . from ( certificate: certificate)
73
- guard case . unrecognized( let name, let organizationalUnit, let organization) = signingEntity else {
74
- return XCTFail ( " Expected SigningEntity.unrecognized but got \( signingEntity) " )
75
- }
76
- XCTAssertEqual ( name, certificate. subject. commonName)
77
- XCTAssertEqual ( organizationalUnit, certificate. subject. organizationalUnitName)
78
- XCTAssertEqual ( organization, certificate. subject. organizationName)
67
+ #expect( name == certificate. subject. commonName)
68
+ #expect( organizationalUnit == certificate. subject. organizationalUnitName)
69
+ #expect( organization == certificate. subject. organizationName)
79
70
}
80
71
}
72
+ }
81
73
74
+ final class SigningEntityXCTests : XCTestCase {
82
75
#if os(macOS)
83
76
func testFromKeychainCertificate( ) async throws {
84
77
#if ENABLE_REAL_SIGNING_IDENTITY_TEST
0 commit comments