Dispose certificates in Kubernetes.Dispose() (#1191)

* Dispose certs created by Kuberentes

* Update tests
This commit is contained in:
Shenglong Li
2023-02-01 15:47:29 -08:00
committed by GitHub
parent f0b93e056d
commit e1508370f5
7 changed files with 39 additions and 34 deletions

View File

@@ -29,7 +29,7 @@ namespace k8s.Tests
useRelativePaths: false);
// Just validate that this doesn't throw and private key is non-null
var cert = CertUtils.GeneratePfx(cfg);
using var cert = CertUtils.GeneratePfx(cfg);
Assert.NotNull(cert.GetRSAPrivateKey());
}
@@ -44,7 +44,7 @@ namespace k8s.Tests
"federal-context");
// Just validate that this doesn't throw and private key is non-null
var cert = CertUtils.GeneratePfx(cfg);
using var cert = CertUtils.GeneratePfx(cfg);
Assert.NotNull(cert.GetRSAPrivateKey());
}
@@ -58,7 +58,7 @@ namespace k8s.Tests
useRelativePaths: false);
// Just validate that this doesn't throw and private key is non-null
var cert = CertUtils.GeneratePfx(cfg);
using var cert = CertUtils.GeneratePfx(cfg);
Assert.NotNull(cert.GetRSAPrivateKey());
}
@@ -73,7 +73,7 @@ namespace k8s.Tests
"victorian-context");
// Just validate that this doesn't throw and private key is non-null
var cert = CertUtils.GeneratePfx(cfg);
using var cert = CertUtils.GeneratePfx(cfg);
Assert.NotNull(cert.GetRSAPrivateKey());
}
@@ -85,8 +85,8 @@ namespace k8s.Tests
{
var certCollection = CertUtils.LoadPemFileCert("assets/ca-bundle.crt");
var intermediateCert = new X509Certificate2("assets/ca-bundle-intermediate.crt");
var rootCert = new X509Certificate2("assets/ca-bundle-root.crt");
using var intermediateCert = new X509Certificate2("assets/ca-bundle-intermediate.crt");
using var rootCert = new X509Certificate2("assets/ca-bundle-root.crt");
Assert.Equal(2, certCollection.Count);