public async Task WithExpiredCertificate_InstallFromPMCForPC_WarnAsync(ProjectTemplate projectTemplate) { // Arrange EnsureVisualStudioHost(); using (var testContext = new ApexTestContext(VisualStudio, projectTemplate, XunitLogger)) using (var trustedExpiringTestCert = SigningUtility.GenerateTrustedTestCertificateThatWillExpireSoon()) { XunitLogger.LogInformation("Creating package"); var package = CommonUtility.CreatePackage("ExpiredTestPackage", "1.0.0"); XunitLogger.LogInformation("Signing package"); var expiredTestPackage = CommonUtility.RepositorySignPackage(package, trustedExpiringTestCert.Source.Cert, new Uri("https://v3serviceIndexUrl.test/api/index.json")); await SimpleTestPackageUtility.CreatePackagesAsync(testContext.PackageSource, expiredTestPackage); XunitLogger.LogInformation("Waiting for package to expire"); SigningUtility.WaitForCertificateToExpire(trustedExpiringTestCert.Source.Cert); var nugetConsole = GetConsole(testContext.Project); nugetConsole.InstallPackageFromPMC(expiredTestPackage.Id, expiredTestPackage.Version); // TODO: Fix bug where no warnings are shown when package is untrusted but still installed //nugetConsole.IsMessageFoundInPMC("expired certificate").Should().BeTrue("expired certificate warning"); CommonUtility.AssertPackageInPackagesConfig(VisualStudio, testContext.Project, expiredTestPackage.Id, expiredTestPackage.Version, XunitLogger); } }
public async Task WithExpiredAuthorCertificateAtCountersigning_InstallFromPMCForPC_WarnAsync(ProjectTemplate projectTemplate) { // Arrange EnsureVisualStudioHost(); var timestampService = await _fixture.GetDefaultTrustedTimestampServiceAsync(); using (var testContext = new ApexTestContext(VisualStudio, projectTemplate, XunitLogger)) using (var trustedCert = _fixture.TrustedRepositoryTestCertificate) using (var trustedExpiringTestCert = SigningUtility.GenerateTrustedTestCertificateThatWillExpireSoon()) { XunitLogger.LogInformation("Creating package"); var package = CommonUtility.CreatePackage("ExpiredTestPackage", "1.0.0"); XunitLogger.LogInformation("Signing package"); var expiredTestPackage = CommonUtility.AuthorSignPackage(package, trustedExpiringTestCert.Source.Cert); await SimpleTestPackageUtility.CreatePackagesAsync(testContext.PackageSource, expiredTestPackage); var packageFullName = Path.Combine(testContext.PackageSource, expiredTestPackage.PackageName); XunitLogger.LogInformation("Waiting for package to expire"); SigningUtility.WaitForCertificateToExpire(trustedExpiringTestCert.Source.Cert); XunitLogger.LogInformation("Countersigning package"); var countersignedPackage = await SignedArchiveTestUtility.RepositorySignPackageAsync( new X509Certificate2(trustedCert.Source.Cert), packageFullName, testContext.PackageSource, new Uri("https://v3serviceIndexUrl.test/api/index.json"), timestampService.Url); File.Copy(countersignedPackage, packageFullName, overwrite: true); File.Delete(countersignedPackage); var nugetConsole = GetConsole(testContext.Project); nugetConsole.InstallPackageFromPMC(expiredTestPackage.Id, expiredTestPackage.Version); // TODO: Fix bug where no warnings are shown when package is untrusted but still installed //nugetConsole.IsMessageFoundInPMC("expired certificate").Should().BeTrue("expired certificate warning"); CommonUtility.AssertPackageInPackagesConfig(VisualStudio, testContext.Project, expiredTestPackage.Id, expiredTestPackage.Version, XunitLogger); } }