diff --git a/Fixtures/Collections/JSON/good.json b/Fixtures/Collections/JSON/good.json index a424b14cc08..49c74bf82d3 100644 --- a/Fixtures/Collections/JSON/good.json +++ b/Fixtures/Collections/JSON/good.json @@ -66,6 +66,15 @@ "name": "Apache-2.0", "url": "https://www.example.com/repos/RepoOne/LICENSE" }, + "author": { + "name": "J. Appleseed" + }, + "signer": { + "type": "ADP", + "commonName": "J. Appleseed", + "organizationalUnitName": "A1", + "organizationName": "Appleseed Inc." + }, "createdAt": "2020-10-21T09:25:36Z" } ] diff --git a/Fixtures/Collections/JSON/good_signed.json b/Fixtures/Collections/JSON/good_signed.json index cd48d6f3265..b8b10b26225 100644 --- a/Fixtures/Collections/JSON/good_signed.json +++ b/Fixtures/Collections/JSON/good_signed.json @@ -66,6 +66,15 @@ "name": "Apache-2.0", "url": "https://www.example.com/repos/RepoOne/LICENSE" }, + "author": { + "name": "J. Appleseed" + }, + "signer": { + "type": "ADP", + "commonName": "J. Appleseed", + "organizationalUnitName": "A1", + "organizationName": "Appleseed Inc." + }, "createdAt": "2020-10-21T09:25:36Z" } ] diff --git a/Package.swift b/Package.swift index f65e2a712cc..80021358f67 100644 --- a/Package.swift +++ b/Package.swift @@ -370,6 +370,7 @@ let package = Package( "PackageCollections", "PackageModel", "PackageRegistry", + "PackageSigning", ] ), diff --git a/Sources/PackageCollections/Model/PackageTypes.swift b/Sources/PackageCollections/Model/PackageTypes.swift index dc41fcaa5cd..e915ad58f58 100644 --- a/Sources/PackageCollections/Model/PackageTypes.swift +++ b/Sources/PackageCollections/Model/PackageTypes.swift @@ -143,6 +143,9 @@ extension PackageCollectionsModel.Package { /// The package version's author public let author: PackageCollectionsModel.Package.Author? + + /// The package version's signer + public let signer: PackageCollectionsModel.Signer? /// When the package version was created public let createdAt: Date? @@ -224,6 +227,38 @@ extension PackageCollectionsModel.Package { } } +extension PackageCollectionsModel { + public struct Signer: Equatable, Codable { + /// The signer type. + public let type: SignerType + + /// The common name of the signing certificate's subject. + public let commonName: String + + /// The organizational unit name of the signing certificate's subject. + public let organizationalUnitName: String + + /// The organization name of the signing certificate's subject. + public let organizationName: String + + public init( + type: SignerType, + commonName: String, + organizationalUnitName: String, + organizationName: String + ) { + self.type = type + self.commonName = commonName + self.organizationalUnitName = organizationalUnitName + self.organizationName = organizationName + } + } + + public enum SignerType: String, Codable { + case adp // Apple Developer Program + } +} + extension PackageCollectionsModel { public typealias PackageMetadata = (package: PackageCollectionsModel.Package, collections: [PackageCollectionsModel.CollectionIdentifier], provider: PackageMetadataProviderContext?) } diff --git a/Sources/PackageCollections/PackageCollections.swift b/Sources/PackageCollections/PackageCollections.swift index 6fe93f12696..edc91f7f774 100644 --- a/Sources/PackageCollections/PackageCollections.swift +++ b/Sources/PackageCollections/PackageCollections.swift @@ -657,7 +657,8 @@ public struct PackageCollections: PackageCollectionsProtocol, Closable { defaultToolsVersion: packageVersion.defaultToolsVersion, verifiedCompatibility: packageVersion.verifiedCompatibility, license: packageVersion.license, - author: versionMetadata?.author, + author: versionMetadata?.author ?? packageVersion.author, + signer: packageVersion.signer, createdAt: versionMetadata?.createdAt ?? packageVersion.createdAt) } versions.sort(by: >) diff --git a/Sources/PackageCollections/Providers/JSONPackageCollectionProvider.swift b/Sources/PackageCollections/Providers/JSONPackageCollectionProvider.swift index dce526c7b6d..67cb55c60f7 100644 --- a/Sources/PackageCollections/Providers/JSONPackageCollectionProvider.swift +++ b/Sources/PackageCollections/Providers/JSONPackageCollectionProvider.swift @@ -251,6 +251,18 @@ struct JSONPackageCollectionProvider: PackageCollectionProvider { } let license = version.license.flatMap { Model.License(from: $0) } + let signer: Model.Signer? + if let versionSigner = version.signer, let signerType = Model.SignerType(rawValue: versionSigner.type.lowercased()) { + signer = .init( + type: signerType, + commonName: versionSigner.commonName, + organizationalUnitName: versionSigner.organizationalUnitName, + organizationName: versionSigner.organizationName + ) + } else { + signer = nil + } + return .init(version: parsedVersion, title: nil, summary: version.summary, @@ -258,7 +270,8 @@ struct JSONPackageCollectionProvider: PackageCollectionProvider { defaultToolsVersion: defaultToolsVersion, verifiedCompatibility: verifiedCompatibility, license: license, - author: nil, + author: version.author.map { .init(username: $0.name, url: nil, service: nil) }, + signer: signer, createdAt: version.createdAt) } if versions.count != package.versions.count { diff --git a/Sources/PackageCollectionsModel/Formats/v1.md b/Sources/PackageCollectionsModel/Formats/v1.md index 048c09615c3..be21118c943 100644 --- a/Sources/PackageCollectionsModel/Formats/v1.md +++ b/Sources/PackageCollectionsModel/Formats/v1.md @@ -100,6 +100,13 @@ A version object has metadata extracted from `Package.swift` and optionally addi * `license`: The package version's license. **Optional.** * `url`: The URL of the license file. * `name`: License name. [SPDX identifier](https://spdx.org/licenses/) (e.g., `Apache-2.0`, `MIT`, etc.) preferred. Omit if unknown. **Optional.** +* `author`: The package version's author. **Optional.** + * `name`: The author of the package version. +* `signer`: The signer of the package version. **Optional.** Refer to [documentation](https://github.com/apple/swift-package-manager/blob/main/Documentation/PackageRegistryUsage.md#package-signing) on package signing for details. + * `type`: The signer type. Currently the only valid value is `ADP` (Apple Developer Program). + * `commonName`: The common name of the signing certificate's subject. + * `organizationalUnitName`: The organizational unit name of the signing certificate's subject. + * `organizationName`: The organization name of the signing certificate's subject. * `createdAt`: The ISO 8601-formatted datetime string when the package version was created. **Optional.** ##### Version-specific manifests diff --git a/Sources/PackageCollectionsModel/PackageCollectionModel+v1.swift b/Sources/PackageCollectionsModel/PackageCollectionModel+v1.swift index 78dc3a08e9c..8fd2dbfd3f1 100644 --- a/Sources/PackageCollectionsModel/PackageCollectionModel+v1.swift +++ b/Sources/PackageCollectionsModel/PackageCollectionModel+v1.swift @@ -141,6 +141,12 @@ extension PackageCollectionModel.V1.Collection.Package { /// The package version's license. public let license: PackageCollectionModel.V1.License? + /// The author of the package version. + public let author: Author? + + /// The signer of the package version. + public let signer: PackageCollectionModel.V1.Signer? + /// When the package version was created. public let createdAt: Date? @@ -152,6 +158,8 @@ extension PackageCollectionModel.V1.Collection.Package { defaultToolsVersion: String, verifiedCompatibility: [PackageCollectionModel.V1.Compatibility]?, license: PackageCollectionModel.V1.License?, + author: Author?, + signer: PackageCollectionModel.V1.Signer?, createdAt: Date? ) { self.version = version @@ -160,6 +168,8 @@ extension PackageCollectionModel.V1.Collection.Package { self.defaultToolsVersion = defaultToolsVersion self.verifiedCompatibility = verifiedCompatibility self.license = license + self.author = author + self.signer = signer self.createdAt = createdAt } @@ -194,6 +204,16 @@ extension PackageCollectionModel.V1.Collection.Package { self.minimumPlatformVersions = minimumPlatformVersions } } + + public struct Author: Equatable, Codable { + /// The author name. + public let name: String + + /// Creates an `Author` + public init(name: String) { + self.name = name + } + } } } @@ -286,6 +306,32 @@ extension PackageCollectionModel.V1 { self.url = url } } + + public struct Signer: Equatable, Codable { + /// The signer type. (e.g., ADP) + public let type: String + + /// The common name of the signing certificate's subject. + public let commonName: String + + /// The organizational unit name of the signing certificate's subject. + public let organizationalUnitName: String + + /// The organization name of the signing certificate's subject. + public let organizationName: String + + public init( + type: String, + commonName: String, + organizationalUnitName: String, + organizationName: String + ) { + self.type = type + self.commonName = commonName + self.organizationalUnitName = organizationalUnitName + self.organizationName = organizationName + } + } } extension PackageCollectionModel.V1.Platform: Hashable { diff --git a/Sources/PackageMetadata/PackageMetadata.swift b/Sources/PackageMetadata/PackageMetadata.swift index 975c815c5b1..c225e94ab38 100644 --- a/Sources/PackageMetadata/PackageMetadata.swift +++ b/Sources/PackageMetadata/PackageMetadata.swift @@ -15,6 +15,7 @@ import Dispatch import PackageCollections import PackageModel import PackageRegistry +import PackageSigning import SourceControl import struct Foundation.Date @@ -72,6 +73,7 @@ public struct Package { public let author: Author? public let description: String? public let publishedAt: Date? + public let signingEntity: SigningEntity? public let latestVersion: Version? fileprivate init( @@ -86,6 +88,7 @@ public struct Package { author: Author?, description: String?, publishedAt: Date?, + signingEntity: SigningEntity?, latestVersion: Version? = nil, source: Source ) { @@ -100,6 +103,7 @@ public struct Package { self.author = author self.description = description self.publishedAt = publishedAt + self.signingEntity = signingEntity self.latestVersion = latestVersion self.source = source } @@ -150,6 +154,7 @@ public struct PackageSearchClient { public let author: Package.Author? public let description: String? public let publishedAt: Date? + public let signingEntity: SigningEntity? } private func getVersionMetadata( @@ -172,7 +177,8 @@ public struct PackageSearchClient { resources: metadata.resources.map { .init($0) }, author: metadata.author.map { .init($0) }, description: metadata.description, - publishedAt: metadata.publishedAt + publishedAt: metadata.publishedAt, + signingEntity: metadata.sourceArchive?.signingEntity ) }) } @@ -189,18 +195,22 @@ public struct PackageSearchClient { self.indexAndCollections.findPackages(query) { result in do { let packages = try result.get().items.map { - Package( + let versions = $0.package.versions.sorted(by: >) + let latestVersion = versions.first + + return Package( identity: $0.package.identity, location: $0.package.location, versions: $0.package.versions.map(\.version), - licenseURL: nil, + licenseURL: $0.package.license?.url, readmeURL: $0.package.readmeURL, repositoryURLs: nil, resources: [], - author: nil, - description: nil, - publishedAt: nil, - latestVersion: nil, + author: latestVersion?.author.map { .init($0) }, + description: latestVersion?.summary, + publishedAt: latestVersion?.createdAt, + signingEntity: latestVersion?.signer.map { SigningEntity(signer: $0) }, + latestVersion: latestVersion?.version, // this only makes sense in connection with providing versioned metadata source: .indexAndCollections(collections: $0.collections, indexes: $0.indexes) ) @@ -259,6 +269,7 @@ public struct PackageSearchClient { author: nil, description: nil, publishedAt: nil, + signingEntity: nil, latestVersion: nil, // this only makes sense in connection with providing versioned metadata source: .sourceControl(url: url) @@ -298,6 +309,7 @@ public struct PackageSearchClient { let author: Package.Author? let description: String? let publishedAt: Date? + let signingEntity: SigningEntity? if case .success(let metadata) = result { licenseURL = metadata.licenseURL readmeURL = metadata.readmeURL @@ -306,6 +318,7 @@ public struct PackageSearchClient { author = metadata.author description = metadata.description publishedAt = metadata.publishedAt + signingEntity = metadata.signingEntity } else { licenseURL = nil readmeURL = self.guessReadMeURL(alternateLocations: metadata.alternateLocations) @@ -314,6 +327,7 @@ public struct PackageSearchClient { author = nil description = nil publishedAt = nil + signingEntity = nil } return callback(.success([Package( @@ -326,6 +340,7 @@ public struct PackageSearchClient { author: author, description: description, publishedAt: publishedAt, + signingEntity: signingEntity, latestVersion: version, source: .registry(url: metadata.registry.url) )])) @@ -342,6 +357,7 @@ public struct PackageSearchClient { author: nil, description: nil, publishedAt: nil, + signingEntity: nil, latestVersion: nil, // this only makes sense in connection with providing versioned metadata source: .registry(url: metadata.registry.url) @@ -426,6 +442,16 @@ extension Package.Author { url: author.url ) } + + fileprivate init(_ author: PackageCollectionsModel.Package.Author) { + self.init( + name: author.username, + email: nil, + description: nil, + organization: nil, + url: author.url + ) + } } extension Package.Organization { @@ -438,3 +464,24 @@ extension Package.Organization { ) } } + +extension SigningEntity { + fileprivate init(signer: PackageCollectionsModel.Signer) { + // All package collection signers are "recognized" + self = .recognized( + type: .init(signer.type), + name: signer.commonName, + organizationalUnit: signer.organizationalUnitName, + organization: signer.organizationName + ) + } +} + +extension SigningEntityType { + fileprivate init(_ type: PackageCollectionsModel.SignerType) { + switch type { + case .adp: + self = .adp + } + } +} diff --git a/Tests/PackageCollectionsModelTests/PackageCollectionModelTests.swift b/Tests/PackageCollectionsModelTests/PackageCollectionModelTests.swift index 274e50216c0..1fd5973b732 100644 --- a/Tests/PackageCollectionsModelTests/PackageCollectionModelTests.swift +++ b/Tests/PackageCollectionsModelTests/PackageCollectionModelTests.swift @@ -42,6 +42,13 @@ class PackageCollectionModelTests: XCTestCase { defaultToolsVersion: "5.2", verifiedCompatibility: [Model.Compatibility(platform: Model.Platform(name: "macOS"), swiftVersion: "5.2")], license: .init(name: "Apache-2.0", url: "https://package-collection-tests.com/repos/foobar/LICENSE"), + author: .init(name: "J. Appleseed"), + signer: .init( + type: "ADP", + commonName: "J. Appleseed", + organizationalUnitName: "A1", + organizationName: "Appleseed Inc." + ), createdAt: Date() ), ], @@ -88,6 +95,13 @@ class PackageCollectionModelTests: XCTestCase { defaultToolsVersion: "5.2", verifiedCompatibility: [Model.Compatibility(platform: Model.Platform(name: "macOS"), swiftVersion: "5.2")], license: .init(name: "Apache-2.0", url: "https://package-collection-tests.com/repos/foobar/LICENSE"), + author: .init(name: "J. Appleseed"), + signer: .init( + type: "ADP", + commonName: "J. Appleseed", + organizationalUnitName: "A1", + organizationName: "Appleseed Inc." + ), createdAt: Date() ), ], diff --git a/Tests/PackageCollectionsTests/JSONPackageCollectionProviderTests.swift b/Tests/PackageCollectionsTests/JSONPackageCollectionProviderTests.swift index 63b3809cd21..aeb6501608c 100644 --- a/Tests/PackageCollectionsTests/JSONPackageCollectionProviderTests.swift +++ b/Tests/PackageCollectionsTests/JSONPackageCollectionProviderTests.swift @@ -76,6 +76,8 @@ class JSONPackageCollectionProviderTests: XCTestCase { XCTAssertEqual(version.verifiedCompatibility!.first!.platform, .macOS) XCTAssertEqual(version.verifiedCompatibility!.first!.swiftVersion, SwiftLanguageVersion(string: "5.1")!) XCTAssertEqual(version.license, .init(type: .Apache2_0, url: "https://www.example.com/repos/RepoOne/LICENSE")) + XCTAssertEqual(version.author?.username, "J. Appleseed") + XCTAssertEqual(version.signer?.commonName, "J. Appleseed") XCTAssertNotNil(version.createdAt) XCTAssertFalse(collection.isSigned) @@ -122,6 +124,9 @@ class JSONPackageCollectionProviderTests: XCTestCase { XCTAssertEqual(version.verifiedCompatibility!.first!.platform, .macOS) XCTAssertEqual(version.verifiedCompatibility!.first!.swiftVersion, SwiftLanguageVersion(string: "5.1")!) XCTAssertEqual(version.license, .init(type: .Apache2_0, url: "https://www.example.com/repos/RepoOne/LICENSE")) + XCTAssertEqual(version.author?.username, "J. Appleseed") + XCTAssertEqual(version.signer?.commonName, "J. Appleseed") + XCTAssertNotNil(version.createdAt) XCTAssertFalse(collection.isSigned) XCTAssertEqual(collection.packages[1].identity, .init(urlString: "https://www.example.com/repos/RepoTwo.git")) @@ -426,6 +431,8 @@ class JSONPackageCollectionProviderTests: XCTestCase { XCTAssertEqual(version.verifiedCompatibility!.first!.platform, .macOS) XCTAssertEqual(version.verifiedCompatibility!.first!.swiftVersion, SwiftLanguageVersion(string: "5.1")!) XCTAssertEqual(version.license, .init(type: .Apache2_0, url: "https://www.example.com/repos/RepoOne/LICENSE")) + XCTAssertEqual(version.author?.username, "J. Appleseed") + XCTAssertEqual(version.signer?.commonName, "J. Appleseed") XCTAssertNotNil(version.createdAt) XCTAssertTrue(collection.isSigned) let signature = collection.signature! @@ -496,6 +503,8 @@ class JSONPackageCollectionProviderTests: XCTestCase { XCTAssertEqual(version.verifiedCompatibility!.first!.platform, .macOS) XCTAssertEqual(version.verifiedCompatibility!.first!.swiftVersion, SwiftLanguageVersion(string: "5.1")!) XCTAssertEqual(version.license, .init(type: .Apache2_0, url: "https://www.example.com/repos/RepoOne/LICENSE")) + XCTAssertEqual(version.author?.username, "J. Appleseed") + XCTAssertEqual(version.signer?.commonName, "J. Appleseed") XCTAssertNotNil(version.createdAt) XCTAssertTrue(collection.isSigned) let signature = collection.signature! @@ -633,6 +642,9 @@ class JSONPackageCollectionProviderTests: XCTestCase { XCTAssertEqual(version.verifiedCompatibility!.first!.platform, .macOS) XCTAssertEqual(version.verifiedCompatibility!.first!.swiftVersion, SwiftLanguageVersion(string: "5.1")!) XCTAssertEqual(version.license, .init(type: .Apache2_0, url: "https://www.example.com/repos/RepoOne/LICENSE")) + XCTAssertEqual(version.author?.username, "J. Appleseed") + XCTAssertEqual(version.signer?.commonName, "J. Appleseed") + XCTAssertNotNil(version.createdAt) XCTAssertTrue(collection.isSigned) let signature = collection.signature! XCTAssertTrue(signature.isVerified) @@ -704,6 +716,8 @@ class JSONPackageCollectionProviderTests: XCTestCase { XCTAssertEqual(version.verifiedCompatibility!.first!.platform, .macOS) XCTAssertEqual(version.verifiedCompatibility!.first!.swiftVersion, SwiftLanguageVersion(string: "5.1")!) XCTAssertEqual(version.license, .init(type: .Apache2_0, url: "https://www.example.com/repos/RepoOne/LICENSE")) + XCTAssertEqual(version.author?.username, "J. Appleseed") + XCTAssertEqual(version.signer?.commonName, "J. Appleseed") XCTAssertNotNil(version.createdAt) XCTAssertTrue(collection.isSigned) let signature = collection.signature! @@ -781,6 +795,8 @@ class JSONPackageCollectionProviderTests: XCTestCase { XCTAssertEqual(version.verifiedCompatibility!.first!.platform, .macOS) XCTAssertEqual(version.verifiedCompatibility!.first!.swiftVersion, SwiftLanguageVersion(string: "5.1")!) XCTAssertEqual(version.license, .init(type: .Apache2_0, url: "https://www.example.com/repos/RepoOne/LICENSE")) + XCTAssertEqual(version.author?.username, "J. Appleseed") + XCTAssertEqual(version.signer?.commonName, "J. Appleseed") XCTAssertNotNil(version.createdAt) XCTAssertTrue(collection.isSigned) let signature = collection.signature! diff --git a/Tests/PackageCollectionsTests/PackageCollectionValidationTests.swift b/Tests/PackageCollectionsTests/PackageCollectionValidationTests.swift index 19da2f9123a..51b929e0fcf 100644 --- a/Tests/PackageCollectionsTests/PackageCollectionValidationTests.swift +++ b/Tests/PackageCollectionsTests/PackageCollectionValidationTests.swift @@ -2,7 +2,7 @@ // // This source file is part of the Swift open source project // -// Copyright (c) 2020-2021 Apple Inc. and the Swift project authors +// Copyright (c) 2020-2023 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See http://swift.org/LICENSE.txt for license information @@ -42,6 +42,8 @@ class PackageCollectionValidationTests: XCTestCase { defaultToolsVersion: "5.2", verifiedCompatibility: nil, license: nil, + author: nil, + signer: nil, createdAt: nil ), Model.Collection.Package.Version( @@ -59,6 +61,8 @@ class PackageCollectionValidationTests: XCTestCase { defaultToolsVersion: "5.2", verifiedCompatibility: nil, license: nil, + author: nil, + signer: nil, createdAt: nil ), ], @@ -125,6 +129,8 @@ class PackageCollectionValidationTests: XCTestCase { defaultToolsVersion: "5.2", verifiedCompatibility: nil, license: nil, + author: nil, + signer: nil, createdAt: nil ), ], @@ -151,6 +157,8 @@ class PackageCollectionValidationTests: XCTestCase { defaultToolsVersion: "5.2", verifiedCompatibility: nil, license: nil, + author: nil, + signer: nil, createdAt: nil ), ], @@ -233,6 +241,8 @@ class PackageCollectionValidationTests: XCTestCase { defaultToolsVersion: "5.2", verifiedCompatibility: nil, license: nil, + author: nil, + signer: nil, createdAt: nil ), Model.Collection.Package.Version( @@ -250,6 +260,8 @@ class PackageCollectionValidationTests: XCTestCase { defaultToolsVersion: "5.2", verifiedCompatibility: nil, license: nil, + author: nil, + signer: nil, createdAt: nil ), ], @@ -310,6 +322,8 @@ class PackageCollectionValidationTests: XCTestCase { defaultToolsVersion: "5.2", verifiedCompatibility: nil, license: nil, + author: nil, + signer: nil, createdAt: nil ), ], @@ -360,6 +374,8 @@ class PackageCollectionValidationTests: XCTestCase { defaultToolsVersion: "5.2", verifiedCompatibility: nil, license: nil, + author: nil, + signer: nil, createdAt: nil ), Model.Collection.Package.Version( @@ -377,6 +393,8 @@ class PackageCollectionValidationTests: XCTestCase { defaultToolsVersion: "5.2", verifiedCompatibility: nil, license: nil, + author: nil, + signer: nil, createdAt: nil ), ], @@ -403,6 +421,8 @@ class PackageCollectionValidationTests: XCTestCase { defaultToolsVersion: "5.2", verifiedCompatibility: nil, license: nil, + author: nil, + signer: nil, createdAt: nil ), Model.Collection.Package.Version( @@ -420,6 +440,8 @@ class PackageCollectionValidationTests: XCTestCase { defaultToolsVersion: "5.2", verifiedCompatibility: nil, license: nil, + author: nil, + signer: nil, createdAt: nil ), ], @@ -467,6 +489,8 @@ class PackageCollectionValidationTests: XCTestCase { defaultToolsVersion: "5.2", verifiedCompatibility: nil, license: nil, + author: nil, + signer: nil, createdAt: nil ), ], @@ -517,6 +541,8 @@ class PackageCollectionValidationTests: XCTestCase { defaultToolsVersion: "5.2", verifiedCompatibility: nil, license: nil, + author: nil, + signer: nil, createdAt: nil ), ], @@ -567,6 +593,8 @@ class PackageCollectionValidationTests: XCTestCase { defaultToolsVersion: "5.1", verifiedCompatibility: nil, license: nil, + author: nil, + signer: nil, createdAt: nil ), ], @@ -617,6 +645,8 @@ class PackageCollectionValidationTests: XCTestCase { defaultToolsVersion: "5.1", verifiedCompatibility: nil, license: nil, + author: nil, + signer: nil, createdAt: nil ), ], diff --git a/Tests/PackageCollectionsTests/PackageCollectionsModelTests.swift b/Tests/PackageCollectionsTests/PackageCollectionsModelTests.swift index c43b3511adf..afa641cc73f 100644 --- a/Tests/PackageCollectionsTests/PackageCollectionsModelTests.swift +++ b/Tests/PackageCollectionsTests/PackageCollectionsModelTests.swift @@ -26,11 +26,11 @@ final class PackageCollectionsModelTests: XCTestCase { toolsVersion: toolsVersion, packageName: "FooBar", targets: targets, products: products, minimumPlatformVersions: nil )] let versions: [PackageCollectionsModel.Package.Version] = [ - .init(version: .init(stringLiteral: "1.2.0"), title: nil, summary: nil, manifests: manifests, defaultToolsVersion: toolsVersion, verifiedCompatibility: nil, license: nil, author: nil, createdAt: nil), - .init(version: .init(stringLiteral: "2.0.1"), title: nil, summary: nil, manifests: manifests, defaultToolsVersion: toolsVersion, verifiedCompatibility: nil, license: nil, author: nil, createdAt: nil), - .init(version: .init(stringLiteral: "2.1.0-beta.3"), title: nil, summary: nil, manifests: manifests, defaultToolsVersion: toolsVersion, verifiedCompatibility: nil, license: nil, author: nil, createdAt: nil), - .init(version: .init(stringLiteral: "2.1.0"), title: nil, summary: nil, manifests: manifests, defaultToolsVersion: toolsVersion, verifiedCompatibility: nil, license: nil, author: nil, createdAt: nil), - .init(version: .init(stringLiteral: "3.0.0-beta.1"), title: nil, summary: nil, manifests: manifests, defaultToolsVersion: toolsVersion, verifiedCompatibility: nil, license: nil, author: nil, createdAt: nil), + .init(version: .init(stringLiteral: "1.2.0"), title: nil, summary: nil, manifests: manifests, defaultToolsVersion: toolsVersion, verifiedCompatibility: nil, license: nil, author: nil, signer: nil, createdAt: nil), + .init(version: .init(stringLiteral: "2.0.1"), title: nil, summary: nil, manifests: manifests, defaultToolsVersion: toolsVersion, verifiedCompatibility: nil, license: nil, author: nil, signer: nil, createdAt: nil), + .init(version: .init(stringLiteral: "2.1.0-beta.3"), title: nil, summary: nil, manifests: manifests, defaultToolsVersion: toolsVersion, verifiedCompatibility: nil, license: nil, author: nil, signer: nil, createdAt: nil), + .init(version: .init(stringLiteral: "2.1.0"), title: nil, summary: nil, manifests: manifests, defaultToolsVersion: toolsVersion, verifiedCompatibility: nil, license: nil, author: nil, signer: nil, createdAt: nil), + .init(version: .init(stringLiteral: "3.0.0-beta.1"), title: nil, summary: nil, manifests: manifests, defaultToolsVersion: toolsVersion, verifiedCompatibility: nil, license: nil, author: nil, signer: nil, createdAt: nil), ] XCTAssertEqual("2.1.0", versions.latestRelease?.version.description) @@ -45,8 +45,8 @@ final class PackageCollectionsModelTests: XCTestCase { toolsVersion: toolsVersion, packageName: "FooBar", targets: targets, products: products, minimumPlatformVersions: nil )] let versions: [PackageCollectionsModel.Package.Version] = [ - .init(version: .init(stringLiteral: "2.1.0-beta.3"), title: nil, summary: nil, manifests: manifests, defaultToolsVersion: toolsVersion, verifiedCompatibility: nil, license: nil, author: nil, createdAt: nil), - .init(version: .init(stringLiteral: "3.0.0-beta.1"), title: nil, summary: nil, manifests: manifests, defaultToolsVersion: toolsVersion, verifiedCompatibility: nil, license: nil, author: nil, createdAt: nil), + .init(version: .init(stringLiteral: "2.1.0-beta.3"), title: nil, summary: nil, manifests: manifests, defaultToolsVersion: toolsVersion, verifiedCompatibility: nil, license: nil, author: nil, signer: nil, createdAt: nil), + .init(version: .init(stringLiteral: "3.0.0-beta.1"), title: nil, summary: nil, manifests: manifests, defaultToolsVersion: toolsVersion, verifiedCompatibility: nil, license: nil, author: nil, signer: nil, createdAt: nil), ] XCTAssertNil(versions.latestRelease) @@ -61,9 +61,9 @@ final class PackageCollectionsModelTests: XCTestCase { toolsVersion: toolsVersion, packageName: "FooBar", targets: targets, products: products, minimumPlatformVersions: nil )] let versions: [PackageCollectionsModel.Package.Version] = [ - .init(version: .init(stringLiteral: "1.2.0"), title: nil, summary: nil, manifests: manifests, defaultToolsVersion: toolsVersion, verifiedCompatibility: nil, license: nil, author: nil, createdAt: nil), - .init(version: .init(stringLiteral: "2.0.1"), title: nil, summary: nil, manifests: manifests, defaultToolsVersion: toolsVersion, verifiedCompatibility: nil, license: nil, author: nil, createdAt: nil), - .init(version: .init(stringLiteral: "2.1.0"), title: nil, summary: nil, manifests: manifests, defaultToolsVersion: toolsVersion, verifiedCompatibility: nil, license: nil, author: nil, createdAt: nil), + .init(version: .init(stringLiteral: "1.2.0"), title: nil, summary: nil, manifests: manifests, defaultToolsVersion: toolsVersion, verifiedCompatibility: nil, license: nil, author: nil, signer: nil, createdAt: nil), + .init(version: .init(stringLiteral: "2.0.1"), title: nil, summary: nil, manifests: manifests, defaultToolsVersion: toolsVersion, verifiedCompatibility: nil, license: nil, author: nil, signer: nil, createdAt: nil), + .init(version: .init(stringLiteral: "2.1.0"), title: nil, summary: nil, manifests: manifests, defaultToolsVersion: toolsVersion, verifiedCompatibility: nil, license: nil, author: nil, signer: nil, createdAt: nil), ] XCTAssertEqual("2.1.0", versions.latestRelease?.version.description) diff --git a/Tests/PackageCollectionsTests/PackageCollectionsTests.swift b/Tests/PackageCollectionsTests/PackageCollectionsTests.swift index ab521b57f2c..02362970553 100644 --- a/Tests/PackageCollectionsTests/PackageCollectionsTests.swift +++ b/Tests/PackageCollectionsTests/PackageCollectionsTests.swift @@ -691,6 +691,7 @@ final class PackageCollectionsTests: XCTestCase { verifiedCompatibility: nil, license: nil, author: nil, + signer: nil, createdAt: nil) let url = "https://packages.mock/\(UUID().uuidString)" @@ -859,6 +860,7 @@ final class PackageCollectionsTests: XCTestCase { verifiedCompatibility: nil, license: nil, author: nil, + signer: nil, createdAt: nil) let mockPackageURL = "https://packages.mock/\(UUID().uuidString)" @@ -1301,6 +1303,7 @@ final class PackageCollectionsTests: XCTestCase { ], license: PackageCollectionsModel.License(type: .Apache2_0, url: "http://apache.license"), author: .init(username: "\($0)", url: nil, service: nil), + signer: .init(type: .adp, commonName: "\($0)", organizationalUnitName: "\($0) org unit", organizationName: "\($0) org"), createdAt: Date()) } @@ -1349,6 +1352,7 @@ final class PackageCollectionsTests: XCTestCase { XCTAssertEqual(version.license, metadataVersion?.license, "license should match") XCTAssertEqual(mockMetadataVersion?.summary, metadataVersion?.summary, "summary should match") XCTAssertEqual(mockMetadataVersion?.author, metadataVersion?.author, "author should match") + XCTAssertEqual(version.signer, metadataVersion?.signer, "signer should match") XCTAssertEqual(mockMetadataVersion?.createdAt, metadataVersion?.createdAt, "createdAt should match") } XCTAssertEqual(metadata.latestVersion, metadata.versions.first, "versions should be sorted") @@ -1537,6 +1541,7 @@ final class PackageCollectionsTests: XCTestCase { verifiedCompatibility: nil, license: nil, author: nil, + signer: nil, createdAt: nil) let mockPackageURL = "https://packages.mock/\(UUID().uuidString)" diff --git a/Tests/PackageCollectionsTests/PackageIndexAndCollectionsTests.swift b/Tests/PackageCollectionsTests/PackageIndexAndCollectionsTests.swift index b533eed1371..16d018b0cb4 100644 --- a/Tests/PackageCollectionsTests/PackageIndexAndCollectionsTests.swift +++ b/Tests/PackageCollectionsTests/PackageIndexAndCollectionsTests.swift @@ -133,6 +133,7 @@ class PackageIndexAndCollectionsTests: XCTestCase { verifiedCompatibility: nil, license: nil, author: nil, + signer: nil, createdAt: nil) let mockPackageURL = "https://packages.mock/\(UUID().uuidString)" @@ -271,6 +272,7 @@ class PackageIndexAndCollectionsTests: XCTestCase { verifiedCompatibility: nil, license: nil, author: nil, + signer: nil, createdAt: nil) let mockPackageURL = "https://packages.mock/\(UUID().uuidString)" @@ -488,6 +490,7 @@ class PackageIndexAndCollectionsTests: XCTestCase { verifiedCompatibility: nil, license: nil, author: nil, + signer: nil, createdAt: nil) let url = "https://packages.mock/\(UUID().uuidString)" @@ -590,6 +593,7 @@ class PackageIndexAndCollectionsTests: XCTestCase { verifiedCompatibility: nil, license: nil, author: nil, + signer: nil, createdAt: nil) let url = "https://packages.mock/\(UUID().uuidString)" diff --git a/Tests/PackageCollectionsTests/Utility.swift b/Tests/PackageCollectionsTests/Utility.swift index 995e4345ea1..7067522d3ca 100644 --- a/Tests/PackageCollectionsTests/Utility.swift +++ b/Tests/PackageCollectionsTests/Utility.swift @@ -103,6 +103,7 @@ func makeMockPackage(id: String) -> PackageCollectionsModel.Package { verifiedCompatibility: verifiedCompatibility, license: license, author: nil, + signer: nil, createdAt: Date()) }