2020-06-28 06:44:14 +01:00
|
|
|
using System.Collections.Generic;
|
2021-12-13 07:31:59 -08:00
|
|
|
using System.Text.Json;
|
2020-06-28 06:44:14 +01:00
|
|
|
using k8s.KubeConfigModels;
|
|
|
|
|
using Xunit;
|
|
|
|
|
|
|
|
|
|
namespace k8s.Tests
|
|
|
|
|
{
|
|
|
|
|
public class ExternalExecutionTests
|
|
|
|
|
{
|
|
|
|
|
[Fact]
|
|
|
|
|
public void CreateRunnableExternalProcess()
|
|
|
|
|
{
|
|
|
|
|
var actual = KubernetesClientConfiguration.CreateRunnableExternalProcess(new ExternalExecution
|
|
|
|
|
{
|
|
|
|
|
ApiVersion = "testingversion",
|
|
|
|
|
Command = "command",
|
|
|
|
|
Arguments = new List<string> { "arg1", "arg2" },
|
|
|
|
|
EnvironmentVariables = new List<Dictionary<string, string>>
|
2020-10-23 08:31:57 -07:00
|
|
|
{ new Dictionary<string, string> { { "name", "testkey" }, { "value", "testvalue" } } },
|
2020-06-28 06:44:14 +01:00
|
|
|
});
|
|
|
|
|
|
2021-12-13 07:31:59 -08:00
|
|
|
var actualExecInfo = JsonSerializer.Deserialize<IDictionary<string, dynamic>>(actual.StartInfo.EnvironmentVariables["KUBERNETES_EXEC_INFO"]);
|
|
|
|
|
Assert.Equal("testingversion", actualExecInfo["apiVersion"].ToString());
|
|
|
|
|
Assert.Equal("ExecCredentials", actualExecInfo["kind"].ToString());
|
2020-06-28 06:44:14 +01:00
|
|
|
|
|
|
|
|
Assert.Equal("command", actual.StartInfo.FileName);
|
|
|
|
|
Assert.Equal("arg1 arg2", actual.StartInfo.Arguments);
|
|
|
|
|
Assert.Equal("testvalue", actual.StartInfo.EnvironmentVariables["testkey"]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|