|
15 | 15 | @testable import App |
16 | 16 |
|
17 | 17 | import Dependencies |
18 | | -import PackageCollectionsSigning |
19 | 18 | import SnapshotTesting |
20 | 19 | import Testing |
21 | 20 | import XCTVapor |
@@ -845,76 +844,76 @@ extension AllTests.ApiTests { |
845 | 844 | } |
846 | 845 | } |
847 | 846 |
|
848 | | - @Test(.disabled(if: !isRunningInCI() && EnvironmentClient.liveValue.collectionSigningPrivateKey() == nil, |
849 | | - "Skip test for local user due to unset COLLECTION_SIGNING_PRIVATE_KEY env variable")) |
850 | | - func package_collections_owner() async throws { |
851 | | - let event = App.ActorIsolated<TestEvent?>(nil) |
852 | | - try await withDependencies { |
853 | | - $0.date.now = .t0 |
854 | | - $0.environment.apiSigningKey = { "secret" } |
855 | | - $0.environment.collectionSigningCertificateChain = EnvironmentClient.liveValue.collectionSigningCertificateChain |
856 | | - $0.environment.collectionSigningPrivateKey = EnvironmentClient.liveValue.collectionSigningPrivateKey |
857 | | - $0.httpClient.postPlausibleEvent = { @Sendable kind, path, _ in |
858 | | - await event.setValue(.init(kind: kind, path: path)) |
859 | | - } |
860 | | - } operation: { |
861 | | - try await withApp { app in |
862 | | - // setup |
863 | | - let p1 = Package(id: .id1, url: "1") |
864 | | - try await p1.save(on: app.db) |
865 | | - try await Repository(package: p1, |
866 | | - defaultBranch: "main", |
867 | | - name: "name 1", |
868 | | - owner: "foo", |
869 | | - summary: "foo bar package").save(on: app.db) |
870 | | - let v = try Version(package: p1, |
871 | | - latest: .release, |
872 | | - packageName: "Foo", |
873 | | - reference: .tag(1, 2, 3), |
874 | | - toolsVersion: "5.0") |
875 | | - try await v.save(on: app.db) |
876 | | - try await Product(version: v, type: .library(.automatic), name: "lib") |
877 | | - .save(on: app.db) |
878 | | - |
879 | | - do { // MUT |
880 | | - let body: ByteBuffer = .init(string: """ |
881 | | - { |
882 | | - "revision": 3, |
883 | | - "authorName": "author", |
884 | | - "keywords": [ |
885 | | - "a", |
886 | | - "b" |
887 | | - ], |
888 | | - "selection": { |
889 | | - "author": { |
890 | | - "_0": "foo" |
891 | | - } |
892 | | - }, |
893 | | - "collectionName": "my collection", |
894 | | - "overview": "my overview" |
895 | | - } |
896 | | - """) |
897 | | - |
898 | | - try await app.test(.POST, "api/package-collections", |
899 | | - headers: .bearerApplicationJSON(try .apiToken(secretKey: "secret", tier: .tier3)), |
900 | | - body: body, |
901 | | - afterResponse: { res async throws in |
902 | | - // validation |
903 | | - #expect(res.status == .ok) |
904 | | - let container = try res.content.decode(SignedCollection.self) |
905 | | - #expect(!container.signature.signature.isEmpty) |
906 | | - // more details are tested in PackageCollectionTests |
907 | | - #expect(container.collection.name == "my collection") |
908 | | - }) |
909 | | - } |
910 | | - |
911 | | - // ensure API event has been reported |
912 | | - await event.withValue { |
913 | | - #expect($0 == .some(.init(kind: .pageview, path: .packageCollections))) |
914 | | - } |
915 | | - } |
916 | | - } |
917 | | - } |
| 847 | +// @Test(.disabled(if: !isRunningInCI() && EnvironmentClient.liveValue.collectionSigningPrivateKey() == nil, |
| 848 | +// "Skip test for local user due to unset COLLECTION_SIGNING_PRIVATE_KEY env variable")) |
| 849 | +// func package_collections_owner() async throws { |
| 850 | +// let event = App.ActorIsolated<TestEvent?>(nil) |
| 851 | +// try await withDependencies { |
| 852 | +// $0.date.now = .t0 |
| 853 | +// $0.environment.apiSigningKey = { "secret" } |
| 854 | +// $0.environment.collectionSigningCertificateChain = EnvironmentClient.liveValue.collectionSigningCertificateChain |
| 855 | +// $0.environment.collectionSigningPrivateKey = EnvironmentClient.liveValue.collectionSigningPrivateKey |
| 856 | +// $0.httpClient.postPlausibleEvent = { @Sendable kind, path, _ in |
| 857 | +// await event.setValue(.init(kind: kind, path: path)) |
| 858 | +// } |
| 859 | +// } operation: { |
| 860 | +// try await withApp { app in |
| 861 | +// // setup |
| 862 | +// let p1 = Package(id: .id1, url: "1") |
| 863 | +// try await p1.save(on: app.db) |
| 864 | +// try await Repository(package: p1, |
| 865 | +// defaultBranch: "main", |
| 866 | +// name: "name 1", |
| 867 | +// owner: "foo", |
| 868 | +// summary: "foo bar package").save(on: app.db) |
| 869 | +// let v = try Version(package: p1, |
| 870 | +// latest: .release, |
| 871 | +// packageName: "Foo", |
| 872 | +// reference: .tag(1, 2, 3), |
| 873 | +// toolsVersion: "5.0") |
| 874 | +// try await v.save(on: app.db) |
| 875 | +// try await Product(version: v, type: .library(.automatic), name: "lib") |
| 876 | +// .save(on: app.db) |
| 877 | +// |
| 878 | +// do { // MUT |
| 879 | +// let body: ByteBuffer = .init(string: """ |
| 880 | +// { |
| 881 | +// "revision": 3, |
| 882 | +// "authorName": "author", |
| 883 | +// "keywords": [ |
| 884 | +// "a", |
| 885 | +// "b" |
| 886 | +// ], |
| 887 | +// "selection": { |
| 888 | +// "author": { |
| 889 | +// "_0": "foo" |
| 890 | +// } |
| 891 | +// }, |
| 892 | +// "collectionName": "my collection", |
| 893 | +// "overview": "my overview" |
| 894 | +// } |
| 895 | +// """) |
| 896 | +// |
| 897 | +// try await app.test(.POST, "api/package-collections", |
| 898 | +// headers: .bearerApplicationJSON(try .apiToken(secretKey: "secret", tier: .tier3)), |
| 899 | +// body: body, |
| 900 | +// afterResponse: { res async throws in |
| 901 | +// // validation |
| 902 | +// #expect(res.status == .ok) |
| 903 | +// let container = try res.content.decode(SignedCollection.self) |
| 904 | +// #expect(!container.signature.signature.isEmpty) |
| 905 | +// // more details are tested in PackageCollectionTests |
| 906 | +// #expect(container.collection.name == "my collection") |
| 907 | +// }) |
| 908 | +// } |
| 909 | +// |
| 910 | +// // ensure API event has been reported |
| 911 | +// await event.withValue { |
| 912 | +// #expect($0 == .some(.init(kind: .pageview, path: .packageCollections))) |
| 913 | +// } |
| 914 | +// } |
| 915 | +// } |
| 916 | +// } |
918 | 917 |
|
919 | 918 | @Test(.disabled(if: !isRunningInCI() && EnvironmentClient.liveValue.collectionSigningPrivateKey() == nil, |
920 | 919 | "Skip test for local user due to unset COLLECTION_SIGNING_PRIVATE_KEY env variable")) |
|
0 commit comments