Skip to content

Commit 1c55d3e

Browse files
committed
code updates
1 parent 814de99 commit 1c55d3e

File tree

5 files changed

+28
-13
lines changed

5 files changed

+28
-13
lines changed

docs/modules/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ await moduleNameContainer.StartAsync();
4646
| Keycloak | `quay.io/keycloak/keycloak:21.1` | [NuGet](https://www.nuget.org/packages/Testcontainers.Keycloak) | [Source](https://github.com/testcontainers/testcontainers-dotnet/tree/develop/src/Testcontainers.Keycloak) |
4747
| Kusto emulator | `mcr.microsoft.com/azuredataexplorer/kustainer-linux:latest` | [NuGet](https://www.nuget.org/packages/Testcontainers.Kusto) | [Source](https://github.com/testcontainers/testcontainers-dotnet/tree/develop/src/Testcontainers.Kusto) |
4848
| LocalStack | `localstack/localstack:2.0` | [NuGet](https://www.nuget.org/packages/Testcontainers.LocalStack) | [Source](https://github.com/testcontainers/testcontainers-dotnet/tree/develop/src/Testcontainers.LocalStack) |
49-
| Lowkey Vault | `nagyesta/lowkey-vault:2.7.0-ubi9-minimal` | [NuGet](https://www.nuget.org/packages/Testcontainers.LowkeyVault) | [Source](https://github.com/testcontainers/testcontainers-dotnet/tree/develop/src/Testcontainers.LowkeyVault) |
49+
| Lowkey Vault | `nagyesta/lowkey-vault:2.7.1-ubi9-minimal` | [NuGet](https://www.nuget.org/packages/Testcontainers.LowkeyVault) | [Source](https://github.com/testcontainers/testcontainers-dotnet/tree/develop/src/Testcontainers.LowkeyVault) |
5050
| MariaDB | `mariadb:10.10` | [NuGet](https://www.nuget.org/packages/Testcontainers.MariaDb) | [Source](https://github.com/testcontainers/testcontainers-dotnet/tree/develop/src/Testcontainers.MariaDb) |
5151
| Milvus | `milvusdb/milvus:v2.3.10` | [NuGet](https://www.nuget.org/packages/Testcontainers.Milvus) | [Source](https://github.com/testcontainers/testcontainers-dotnet/tree/develop/src/Testcontainers.Milvus) |
5252
| MinIO | `minio/minio:RELEASE.2023-01-31T02-24-19Z` | [NuGet](https://www.nuget.org/packages/Testcontainers.Minio) | [Source](https://github.com/testcontainers/testcontainers-dotnet/tree/develop/src/Testcontainers.Minio) |

src/Testcontainers.LowkeyVault/LowkeyVaultBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ namespace Testcontainers.LowkeyVault;
44
[PublicAPI]
55
public sealed class LowkeyVaultBuilder : ContainerBuilder<LowkeyVaultBuilder, LowkeyVaultContainer, LowkeyVaultConfiguration>
66
{
7-
public const string LowkeyVaultImage = "nagyesta/lowkey-vault:2.7.0-ubi9-minimal";
7+
public const string LowkeyVaultImage = "nagyesta/lowkey-vault:2.7.1-ubi9-minimal";
88

99
public const ushort LowkeyVaultPort = 8443;
1010

src/Testcontainers.LowkeyVault/LowkeyVaultContainer.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ namespace Testcontainers.LowkeyVault;
44
[PublicAPI]
55
public sealed class LowkeyVaultContainer : DockerContainer
66
{
7+
private const string LocalHost = "localhost";
8+
79
/// <summary>
810
/// Gets a configured HTTP client
911
/// </summary>
10-
private HttpClient HttpClient => new();
12+
private static HttpClient HttpClient => new();
1113

1214
/// <summary>
1315
/// Initializes a new instance of the <see cref="LowkeyVaultContainer" /> class.
@@ -43,7 +45,11 @@ public string GetTokenEndpointUrl()
4345
/// <returns>The vault base URL.</returns>
4446
public string GetVaultBaseUrl(string vaultName)
4547
{
46-
return new UriBuilder(Uri.UriSchemeHttps, $"{vaultName}.{Hostname}", GetMappedPublicPort(LowkeyVaultBuilder.LowkeyVaultPort)).ToString();
48+
// Using `LocalHost` here instead of `Hostname` (which resolves to `127.0.0.1` in this environment)
49+
// to address a compatibility issue with the Java URI parser utilized by the Lowkey Vault client.
50+
// The parser fails to properly handle URIs containing a mix of DNS names and IP addresses, leading to errors.
51+
// For more details, refer to: https://github.com/nagyesta/lowkey-vault/issues/1319#issuecomment-2600214768
52+
return new UriBuilder(Uri.UriSchemeHttps, $"{vaultName}.{LocalHost}", GetMappedPublicPort(LowkeyVaultBuilder.LowkeyVaultPort)).ToString();
4753
}
4854

4955
/// <summary>

tests/Testcontainers.LowkeyVault.Tests/LowkeyVaultContainerTest.cs

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,22 @@ public Task DisposeAsync()
1818
[Trait(nameof(DockerCli.DockerPlatform), nameof(DockerCli.DockerPlatform.Linux))]
1919
public async Task TestContainerDefaults()
2020
{
21-
// Assert
22-
var tokenEndpoint = _fakeLowkeyVaultContainer.GetTokenEndpointUrl();
21+
// Given
22+
const string Alias = "lowkey-vault.local";
2323

24-
await VerifyTokenEndpointIsWorking(tokenEndpoint, CreateHttpClientHandlerWithDisabledSslValidation());
24+
// When
25+
var tokenEndpoint = _fakeLowkeyVaultContainer.GetTokenEndpointUrl();
2526

2627
var keyStore = await _fakeLowkeyVaultContainer.GetDefaultKeyStore();
2728

29+
var password = await _fakeLowkeyVaultContainer.GetDefaultKeyStorePassword();
30+
31+
// Then
32+
await VerifyTokenEndpointIsWorking(tokenEndpoint, CreateHttpClientHandlerWithDisabledSslValidation());
33+
2834
Assert.NotNull(keyStore);
35+
Assert.NotNull(password);
36+
Assert.Contains(keyStore, cert => cert.Subject.Split('=')?.LastOrDefault() == Alias);
2937
}
3038

3139

@@ -130,7 +138,7 @@ private static DefaultAzureCredential CreateDefaultAzureCredential()
130138
return new DefaultAzureCredential();
131139
}
132140

133-
private SecretClientOptions CreateSecretClientOption()
141+
private static SecretClientOptions CreateSecretClientOption()
134142
{
135143
return GetClientOptions(new SecretClientOptions(SecretClientOptions.ServiceVersion.V7_4)
136144
{
@@ -139,7 +147,7 @@ private SecretClientOptions CreateSecretClientOption()
139147
});
140148
}
141149

142-
private CertificateClientOptions CreateCertificateClientOption()
150+
private static CertificateClientOptions CreateCertificateClientOption()
143151
{
144152
return GetClientOptions(new CertificateClientOptions(CertificateClientOptions.ServiceVersion.V7_4)
145153
{
@@ -148,7 +156,7 @@ private CertificateClientOptions CreateCertificateClientOption()
148156
});
149157
}
150158

151-
private T GetClientOptions<T>(T options) where T : ClientOptions
159+
private static T GetClientOptions<T>(T options) where T : ClientOptions
152160
{
153161
DisableSslValidationOnClientOptions(options);
154162
return options;
@@ -160,17 +168,17 @@ private T GetClientOptions<T>(T options) where T : ClientOptions
160168
/// <b>WARNING: Do not use in production environments.</b>
161169
/// </summary>
162170
/// <param name="options"></param>
163-
private void DisableSslValidationOnClientOptions(ClientOptions options)
171+
private static void DisableSslValidationOnClientOptions(ClientOptions options)
164172
{
165173
options.Transport = new HttpClientTransport(CreateHttpClientHandlerWithDisabledSslValidation());
166174
}
167175

168-
private HttpClientHandler CreateHttpClientHandlerWithDisabledSslValidation()
176+
private static HttpClientHandler CreateHttpClientHandlerWithDisabledSslValidation()
169177
{
170178
return new HttpClientHandler { ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator };
171179
}
172180

173-
private async Task VerifyTokenEndpointIsWorking(string endpointUrl, HttpClientHandler httpClientHandler)
181+
private static async Task VerifyTokenEndpointIsWorking(string endpointUrl, HttpClientHandler httpClientHandler)
174182
{
175183
using var httpClient = new HttpClient(httpClientHandler);
176184

tests/Testcontainers.LowkeyVault.Tests/Usings.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
global using Azure.Security.KeyVault.Secrets;
66
global using DotNet.Testcontainers.Commons;
77
global using System;
8+
global using System.Linq;
89
global using System.Net.Http;
910
global using System.Security.Cryptography.X509Certificates;
1011
global using System.Threading;

0 commit comments

Comments
 (0)