|
306 | 306 | Run("SIGTRAN commercial evidence file verification command plan orders execution", SigtranCommercialEvidenceFileVerificationCommandPlanOrdersExecution); |
307 | 307 | Run("SIGTRAN commercial evidence file verification status summarizes readiness", SigtranCommercialEvidenceFileVerificationStatusSummarizesReadiness); |
308 | 308 | Run("SIGTRAN commercial evidence filesystem observer computes retained file digest", SigtranCommercialEvidenceFileSystemObserverComputesRetainedFileDigest); |
| 309 | +Run("SIGTRAN commercial evidence filesystem manifest builder observes handoff files", SigtranCommercialEvidenceFileSystemManifestBuilderObservesHandoffFiles); |
309 | 310 | Run("SIGTRAN status capabilities use domain documentation labels", SigtranStatusCapabilitiesUseDomainDocumentationLabels); |
310 | 311 | Run("Native SCTP platform probe reports socket creation capability", NativeSctpPlatformProbeReportsSocketCreationCapability); |
311 | 312 | Run("Native SCTP socket factory creates or reports unsupported platform", NativeSctpSocketFactoryCreatesOrReportsUnsupportedPlatform); |
@@ -5196,10 +5197,92 @@ static void SigtranCommercialEvidenceFileSystemObserverComputesRetainedFileDiges |
5196 | 5197 | } |
5197 | 5198 | finally |
5198 | 5199 | { |
5199 | | - if (tempRoot.StartsWith(Path.GetTempPath(), StringComparison.OrdinalIgnoreCase) && Directory.Exists(tempRoot)) |
5200 | | - { |
5201 | | - Directory.Delete(tempRoot, recursive: true); |
5202 | | - } |
| 5200 | + DeleteTempEvidenceRoot(tempRoot); |
| 5201 | + } |
| 5202 | +} |
| 5203 | + |
| 5204 | +static void SigtranCommercialEvidenceFileSystemManifestBuilderObservesHandoffFiles() |
| 5205 | +{ |
| 5206 | + string tempRoot = Path.Combine(Path.GetTempPath(), "sigtran-commercial-evidence-" + Guid.NewGuid().ToString("N")); |
| 5207 | + Directory.CreateDirectory(tempRoot); |
| 5208 | + |
| 5209 | + try |
| 5210 | + { |
| 5211 | + byte[] artifactContent = "verified commercial artifact"u8.ToArray(); |
| 5212 | + byte[] reportContent = "verified commercial readiness report"u8.ToArray(); |
| 5213 | + SigtranCommercialEvidencePromotionHandoff handoff = CreateCommercialEvidencePromotionHandoffWithDigests( |
| 5214 | + ComputeSha256Hex(artifactContent), |
| 5215 | + ComputeSha256Hex(reportContent)); |
| 5216 | + IReadOnlyDictionary<string, string> pathOverrides = MaterializeHandoffFiles(tempRoot, handoff, artifactContent, reportContent); |
| 5217 | + |
| 5218 | + SigtranCommercialEvidenceFileSystemManifestExecution execution = SigtranCommercialEvidenceFileSystemManifestBuilder.Build( |
| 5219 | + handoff, |
| 5220 | + pathOverrides, |
| 5221 | + DateTimeOffset.UtcNow); |
| 5222 | + |
| 5223 | + Assert(execution.IsReady, execution.Describe()); |
| 5224 | + AssertEqual(handoff.Items.Count, execution.Observations.Count, "filesystem manifest observation count"); |
| 5225 | + Assert(execution.CoversHandoffItems, "filesystem manifest should cover handoff items"); |
| 5226 | + Assert(execution.AllObservedFilesExist, "filesystem manifest should observe existing files"); |
| 5227 | + Assert(execution.AllObservedDigestsMatch, "filesystem manifest should match handoff digests"); |
| 5228 | + Assert(execution.Manifest.IsReady, "filesystem retained manifest should be ready"); |
| 5229 | + } |
| 5230 | + finally |
| 5231 | + { |
| 5232 | + DeleteTempEvidenceRoot(tempRoot); |
| 5233 | + } |
| 5234 | +} |
| 5235 | + |
| 5236 | +static IReadOnlyDictionary<string, string> MaterializeHandoffFiles( |
| 5237 | + string tempRoot, |
| 5238 | + SigtranCommercialEvidencePromotionHandoff handoff, |
| 5239 | + byte[] artifactContent, |
| 5240 | + byte[] reportContent) |
| 5241 | +{ |
| 5242 | + Dictionary<string, string> paths = new(StringComparer.OrdinalIgnoreCase); |
| 5243 | + |
| 5244 | + for (int i = 0; i < handoff.Items.Count; i++) |
| 5245 | + { |
| 5246 | + SigtranCommercialEvidencePromotionHandoffItem item = handoff.Items[i]; |
| 5247 | + string path = Path.Combine(tempRoot, $"retained-{i:D2}.bin"); |
| 5248 | + File.WriteAllBytes(path, item.RetainedPath == handoff.Report.ReportPath ? reportContent : artifactContent); |
| 5249 | + paths[item.RetainedPath] = path; |
| 5250 | + } |
| 5251 | + |
| 5252 | + return paths; |
| 5253 | +} |
| 5254 | + |
| 5255 | +static SigtranCommercialEvidencePromotionHandoff CreateCommercialEvidencePromotionHandoffWithDigests( |
| 5256 | + string artifactSha256, |
| 5257 | + string reportSha256) |
| 5258 | +{ |
| 5259 | + SigtranCommercialEvidenceArtifactDigestManifest digests = SigtranCommercialEvidenceArtifactDigests.CreateCovered( |
| 5260 | + CreateDefaultCommercialEvidenceArtifactSourceManifest(), |
| 5261 | + artifactSha256); |
| 5262 | + SigtranCommercialEvidenceRedactionReviewManifest reviews = SigtranCommercialEvidenceRedactionReviews.CreateApproved( |
| 5263 | + digests, |
| 5264 | + "release-review", |
| 5265 | + DateTimeOffset.UtcNow); |
| 5266 | + SigtranCommercialEvidenceArtifactCompletenessResult completeness = SigtranCommercialEvidenceArtifactCompleteness.Evaluate(reviews); |
| 5267 | + SigtranCommercialEvidenceDossierIntakeReport report = SigtranCommercialEvidenceDossierIntakeReports.CreateDefault(completeness); |
| 5268 | + |
| 5269 | + return SigtranCommercialEvidencePromotionHandoffs.CreateDefault( |
| 5270 | + report, |
| 5271 | + reportSha256, |
| 5272 | + "release-review", |
| 5273 | + DateTimeOffset.UtcNow); |
| 5274 | +} |
| 5275 | + |
| 5276 | +static string ComputeSha256Hex(byte[] content) |
| 5277 | +{ |
| 5278 | + return Convert.ToHexString(System.Security.Cryptography.SHA256.HashData(content)).ToLowerInvariant(); |
| 5279 | +} |
| 5280 | + |
| 5281 | +static void DeleteTempEvidenceRoot(string tempRoot) |
| 5282 | +{ |
| 5283 | + if (tempRoot.StartsWith(Path.GetTempPath(), StringComparison.OrdinalIgnoreCase) && Directory.Exists(tempRoot)) |
| 5284 | + { |
| 5285 | + Directory.Delete(tempRoot, recursive: true); |
5203 | 5286 | } |
5204 | 5287 | } |
5205 | 5288 |
|
|
0 commit comments