Skip to content

Commit

Permalink
Merge branch 'kubernetes-client:master' into exec-hangs
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanJosipovic committed Apr 19, 2023
2 parents 3cfbc94 + 729b10c commit 9800711
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<ItemGroup>
<PackageReference Include="Portable.BouncyCastle" Version="1.9.0" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.28.1" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.29.0" />
<PackageReference Include="IdentityModel.OidcClient" Version="5.2.1" />
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="7.0.0" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/KubernetesClient.Models/KubernetesClient.Models.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
<ItemGroup>
<PackageReference Include="System.Text.Json" Version="7.0.2" />
<PackageReference Include="Fractions" Version="7.2.1" />
<PackageReference Include="YamlDotNet" Version="13.0.2" />
<PackageReference Include="YamlDotNet" Version="13.1.0" />
</ItemGroup>
</Project>
20 changes: 9 additions & 11 deletions src/KubernetesClient/Kubernetes.ConfigInit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,21 +72,19 @@ private void InitializeFromConfig(KubernetesClientConfiguration config)
}
else
{
if (CaCerts == null)
if (CaCerts != null)
{
throw new KubeConfigException("A CA must be set when SkipTlsVerify === false");
}

#if NET5_0_OR_GREATER
HttpClientHandler.SslOptions.RemoteCertificateValidationCallback =
HttpClientHandler.SslOptions.RemoteCertificateValidationCallback =
#else
HttpClientHandler.ServerCertificateCustomValidationCallback =
HttpClientHandler.ServerCertificateCustomValidationCallback =
#endif
(sender, certificate, chain, sslPolicyErrors) =>
{
return CertificateValidationCallBack(sender, CaCerts, certificate, chain,
sslPolicyErrors);
};
(sender, certificate, chain, sslPolicyErrors) =>
{
return CertificateValidationCallBack(sender, CaCerts, certificate, chain,
sslPolicyErrors);
};
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/KubernetesClient/KubernetesClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<ItemGroup>
<PackageReference Include="prometheus-net" Version="8.0.0" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.28.1" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.29.0" />
<PackageReference Include="IdentityModel.OidcClient" Version="5.2.1" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion src/LibKubernetesGenerator/LibKubernetesGenerator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Autofac" Version="7.0.0" GeneratePathProperty="true" PrivateAssets="all" />
<PackageReference Include="Autofac" Version="7.0.1" GeneratePathProperty="true" PrivateAssets="all" />
<PackageReference Include="CaseExtensions" Version="1.1.0" GeneratePathProperty="true" PrivateAssets="all" />
<PackageReference Include="NSwag.Core" Version="13.18.2" GeneratePathProperty="true" PrivateAssets="all" />
<PackageReference Include="Nustache" Version="1.16.0.10" GeneratePathProperty="true" PrivateAssets="all" NoWarn="NU1701" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<PackageReference Include="MartinCostello.Logging.XUnit" Version="0.3.0" />
<PackageReference Include="FluentAssertions" Version="6.10.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
<PackageReference Include="System.IO.Abstractions.TestingHelpers" Version="19.2.8" />
<PackageReference Include="System.IO.Abstractions.TestingHelpers" Version="19.2.11" />
<PackageReference Include="System.Reactive" Version="5.0.0" />
<PackageReference Include="Nito.AsyncEx" Version="5.1.2" />
<PackageReference Include="Portable.BouncyCastle" Version="1.9.0" />
Expand Down
2 changes: 1 addition & 1 deletion tests/KubernetesClient.Tests/KubernetesClient.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<PackageReference Include="MartinCostello.Logging.XUnit" Version="0.3.0" />
<PackageReference Include="FluentAssertions" Version="6.10.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
<PackageReference Include="System.IO.Abstractions.TestingHelpers" Version="19.2.8" />
<PackageReference Include="System.IO.Abstractions.TestingHelpers" Version="19.2.11" />
<PackageReference Include="System.Reactive" Version="5.0.0" />
<PackageReference Include="Nito.AsyncEx" Version="5.1.2" />
<PackageReference Include="Portable.BouncyCastle" Version="1.9.0" />
Expand Down
14 changes: 14 additions & 0 deletions tests/KubernetesClient.Tests/KubernetesClientConfigurationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,20 @@ public void CheckClusterTlsSkipCorrectness()
Assert.True(cfg.SkipTlsVerify);
}

/// <summary>
/// Checks that a KubeConfigException is not thrown when no certificate-authority-data is set and user do not require tls
/// skip
/// </summary>
[Fact]
public void CheckClusterTlsNoSkipCorrectness()
{
var fi = new FileInfo("assets/kubeconfig.tls-no-skip.yml");
var cfg = KubernetesClientConfiguration.BuildConfigFromConfigFile(fi);
Assert.NotNull(cfg.Host);
Assert.Null(cfg.SslCaCerts);
Assert.False(cfg.SkipTlsVerify);
}

/// <summary>
/// Checks that a KubeConfigException is thrown when the cluster defined in clusters and contexts do not match
/// </summary>
Expand Down
22 changes: 22 additions & 0 deletions tests/KubernetesClient.Tests/assets/kubeconfig.tls-no-skip.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Sample file based on https://kubernetes.io/docs/tasks/access-application-cluster/authenticate-across-clusters-kubeconfig/
# WARNING: File includes minor fixes
---
current-context: federal-context
apiVersion: v1
clusters:
- cluster:
insecure-skip-tls-verify: false
server: https://horse.org:443
name: horse-cluster
contexts:
- context:
cluster: horse-cluster
namespace: chisel-ns
user: green-user
name: federal-context
kind: Config
users:
- name: green-user
user:
password: secret
username: admin

0 comments on commit 9800711

Please sign in to comment.