Skip to content

Commit febccb6

Browse files
committed
Validate error on export to non-existent directory
1 parent 2f11442 commit febccb6

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/Tools/FirstRunCertGenerator/test/CertificateManagerTests.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,29 @@ public void EnsureCreateHttpsCertificate_CanExportTheCertInPemFormat_WithoutPass
352352
Assert.Equal(httpsCertificate.GetCertHashString(), exportedCertificate.GetCertHashString());
353353
}
354354

355+
[ConditionalFact]
356+
[SkipOnHelix("https://github.com/dotnet/aspnetcore/issues/6720", Queues = "All.OSX")]
357+
public void EnsureCreateHttpsCertificate_CannotExportToNonExistentDirectory()
358+
{
359+
// Arrange
360+
const string CertificateName = nameof(EnsureCreateHttpsCertificate_DoesNotCreateACertificate_WhenThereIsAnExistingHttpsCertificates) + ".pem";
361+
362+
_fixture.CleanupCertificates();
363+
364+
var now = DateTimeOffset.UtcNow;
365+
now = new DateTimeOffset(now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second, 0, now.Offset);
366+
var creation = _manager.EnsureAspNetCoreHttpsDevelopmentCertificate(now, now.AddYears(1), path: null, trust: false, isInteractive: false);
367+
Output.WriteLine(creation.ToString());
368+
ListCertificates();
369+
370+
// Act
371+
var result = _manager
372+
.EnsureAspNetCoreHttpsDevelopmentCertificate(now, now.AddYears(1), Path.Combine("NoSuchDirectory", CertificateName));
373+
374+
// Assert
375+
Assert.Equal(EnsureCertificateResult.ErrorExportingTheCertificate, result);
376+
}
377+
355378
[Fact]
356379
public void EnsureCreateHttpsCertificate_ReturnsExpiredCertificateIfVersionIsIncorrect()
357380
{

0 commit comments

Comments
 (0)