Skip to content

Commit 253f2c5

Browse files
committed
Validate error on export to non-existent directory
1 parent 73bd5ef commit 253f2c5

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
@@ -311,6 +311,29 @@ public void EnsureCreateHttpsCertificate_CanExportTheCertInPemFormat_WithoutPass
311311
Assert.Equal(httpsCertificate.GetCertHashString(), exportedCertificate.GetCertHashString());
312312
}
313313

314+
[ConditionalFact]
315+
[SkipOnHelix("https://github.com/dotnet/aspnetcore/issues/6720", Queues = "All.OSX")]
316+
public void EnsureCreateHttpsCertificate_CannotExportToNonExistentDirectory()
317+
{
318+
// Arrange
319+
const string CertificateName = nameof(EnsureCreateHttpsCertificate_DoesNotCreateACertificate_WhenThereIsAnExistingHttpsCertificates) + ".pem";
320+
321+
_fixture.CleanupCertificates();
322+
323+
var now = DateTimeOffset.UtcNow;
324+
now = new DateTimeOffset(now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second, 0, now.Offset);
325+
var creation = _manager.EnsureAspNetCoreHttpsDevelopmentCertificate(now, now.AddYears(1), path: null, trust: false, isInteractive: false);
326+
Output.WriteLine(creation.ToString());
327+
ListCertificates();
328+
329+
// Act
330+
var result = _manager
331+
.EnsureAspNetCoreHttpsDevelopmentCertificate(now, now.AddYears(1), Path.Combine("NoSuchDirectory", CertificateName));
332+
333+
// Assert
334+
Assert.Equal(EnsureCertificateResult.ErrorExportingTheCertificate, result);
335+
}
336+
314337
[Fact]
315338
public void EnsureCreateHttpsCertificate_ReturnsExpiredCertificateIfVersionIsIncorrect()
316339
{

0 commit comments

Comments
 (0)