Dispose certificates in Kubernetes.Dispose() (#1191)
* Dispose certs created by Kuberentes * Update tests
This commit is contained in:
@@ -28,7 +28,7 @@ namespace k8s.E2E
|
||||
var namespaceParameter = "default";
|
||||
var podName = "k8scsharp-e2e-pod";
|
||||
|
||||
var client = CreateClient();
|
||||
using var client = CreateClient();
|
||||
|
||||
void Cleanup()
|
||||
{
|
||||
@@ -79,7 +79,7 @@ namespace k8s.E2E
|
||||
var namespaceParameter = "default";
|
||||
var podName = "k8scsharp-e2e-patch-pod";
|
||||
|
||||
var client = CreateClient();
|
||||
using var client = CreateClient();
|
||||
|
||||
void Cleanup()
|
||||
{
|
||||
@@ -183,7 +183,7 @@ namespace k8s.E2E
|
||||
[MinikubeFact]
|
||||
public async Task WatcherIntegrationTest()
|
||||
{
|
||||
var kubernetes = CreateClient();
|
||||
using var kubernetes = CreateClient();
|
||||
|
||||
var job = await kubernetes.BatchV1.CreateNamespacedJobAsync(
|
||||
new V1Job()
|
||||
@@ -251,7 +251,7 @@ namespace k8s.E2E
|
||||
[MinikubeFact]
|
||||
public void LeaderIntegrationTest()
|
||||
{
|
||||
var client = CreateClient();
|
||||
using var client = CreateClient();
|
||||
var namespaceParameter = "default";
|
||||
|
||||
void Cleanup()
|
||||
@@ -350,7 +350,7 @@ namespace k8s.E2E
|
||||
var namespaceParameter = "default";
|
||||
var podName = "k8scsharp-e2e-logstream-pod";
|
||||
|
||||
var client = CreateClient();
|
||||
using var client = CreateClient();
|
||||
|
||||
void Cleanup()
|
||||
{
|
||||
@@ -446,7 +446,7 @@ namespace k8s.E2E
|
||||
[MinikubeFact]
|
||||
public async Task DatetimeFieldTest()
|
||||
{
|
||||
var kubernetes = CreateClient();
|
||||
using var kubernetes = CreateClient();
|
||||
|
||||
await kubernetes.CoreV1.CreateNamespacedEventAsync(
|
||||
new Corev1Event(
|
||||
@@ -478,7 +478,7 @@ namespace k8s.E2E
|
||||
var namespaceParameter = "default";
|
||||
var podName = "k8scsharp-e2e-generic-pod";
|
||||
|
||||
var client = CreateClient();
|
||||
using var client = CreateClient();
|
||||
var genericPods = new GenericClient(client, "", "v1", "pods");
|
||||
|
||||
void Cleanup()
|
||||
@@ -590,7 +590,7 @@ namespace k8s.E2E
|
||||
var namespaceParameter = "default";
|
||||
var podName = "k8scsharp-e2e-cp-pod";
|
||||
|
||||
var client = CreateClient();
|
||||
using var client = CreateClient();
|
||||
|
||||
async Task<int> CopyFileToPodAsync(string name, string @namespace, string container, Stream inputFileStream, string destinationFilePath, CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using k8s.E2E;
|
||||
using k8s.kubectl.beta;
|
||||
using System.Text.Json;
|
||||
using Xunit;
|
||||
|
||||
@@ -9,7 +10,8 @@ public partial class KubectlTests
|
||||
[MinikubeFact]
|
||||
public void Version()
|
||||
{
|
||||
var client = CreateClient();
|
||||
using var kubernetes = MinikubeTests.CreateClient();
|
||||
var client = new Kubectl(kubernetes);
|
||||
var version = client.Version();
|
||||
var serverobj = version.ServerVersion;
|
||||
|
||||
|
||||
@@ -1,16 +1,9 @@
|
||||
using k8s.E2E;
|
||||
using k8s.kubectl.beta;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace k8s.kubectl.Tests;
|
||||
|
||||
public partial class KubectlTests
|
||||
{
|
||||
private Kubectl CreateClient()
|
||||
{
|
||||
return new Kubectl(MinikubeTests.CreateClient());
|
||||
}
|
||||
|
||||
private string RunKubectl(string args)
|
||||
{
|
||||
var p = new Process
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user