Skip to content

Commit

Permalink
sort alphabetically
Browse files Browse the repository at this point in the history
  • Loading branch information
TimHess committed Nov 3, 2023
1 parent 55211fe commit b48a048
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,6 @@

namespace Steeltoe.Extensions.Configuration.Kubernetes.ServiceBinding;

internal sealed class RabbitMQLegacyConnectorPostProcessor : IConfigurationPostProcessor
{
internal const string BindingTypeKey = "rabbitmq";

public void PostProcessConfiguration(PostProcessorConfigurationProvider provider, IDictionary<string, string> configData)
{
if (!provider.IsBindingTypeEnabled(BindingTypeKey))
{
return;
}

configData.Filter(ServiceBindingConfigurationProvider.KubernetesBindingsPrefix, ServiceBindingConfigurationProvider.TypeKey, BindingTypeKey).ForEach(
bindingNameKey =>
{
// Spring -> spring.rabbitmq....
// Steeltoe -> rabbitmq:client:....
var mapper = new ServiceBindingMapper(configData, bindingNameKey, "rabbitmq", "client");
mapper.MapFromTo("addresses", "uri");
mapper.MapFromTo("host", "server");
mapper.MapFromTo("password", "password");
mapper.MapFromTo("port", "port");
mapper.MapFromTo("username", "username");
mapper.MapFromTo("virtual-host", "virtualhost");
});
}
}

internal sealed class MySqlLegacyConnectorPostProcessor : IConfigurationPostProcessor
{
internal const string BindingTypeKey = "mysql";
Expand Down Expand Up @@ -100,3 +73,30 @@ public void PostProcessConfiguration(PostProcessorConfigurationProvider provider
});
}
}

internal sealed class RabbitMQLegacyConnectorPostProcessor : IConfigurationPostProcessor
{
internal const string BindingTypeKey = "rabbitmq";

public void PostProcessConfiguration(PostProcessorConfigurationProvider provider, IDictionary<string, string> configData)
{
if (!provider.IsBindingTypeEnabled(BindingTypeKey))
{
return;
}

configData.Filter(ServiceBindingConfigurationProvider.KubernetesBindingsPrefix, ServiceBindingConfigurationProvider.TypeKey, BindingTypeKey).ForEach(
bindingNameKey =>
{
// Spring -> spring.rabbitmq....
// Steeltoe -> rabbitmq:client:....
var mapper = new ServiceBindingMapper(configData, bindingNameKey, "rabbitmq", "client");
mapper.MapFromTo("addresses", "uri");
mapper.MapFromTo("host", "server");
mapper.MapFromTo("password", "password");
mapper.MapFromTo("port", "port");
mapper.MapFromTo("username", "username");
mapper.MapFromTo("virtual-host", "virtualhost");
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,6 @@ namespace Steeltoe.Extensions.Configuration.Kubernetes.ServiceBinding.Test;

public class LegacyConnectorsPostProcessorsTest : BasePostProcessorsTest
{
[Fact]
public void RabbitMQTest_BindingTypeEnabled()
{
var postProcessor = new RabbitMQLegacyConnectorPostProcessor();

Dictionary<string, string> configData = GetConfigData(_testBindingName, RabbitMQPostProcessor.BindingTypeKey, Tuple.Create("addresses", "test-addresses"), Tuple.Create("host", "test-host"), Tuple.Create("password", "test-password"), Tuple.Create("port", "test-port"), Tuple.Create("username", "test-username"), Tuple.Create("virtual-host", "test-virtual-host"));

// BindingType enabled
postProcessor.PostProcessConfiguration(GetConfigurationProvider(postProcessor, RabbitMQPostProcessor.BindingTypeKey, true), configData);
Assert.Equal("test-addresses", configData["rabbitmq:client:uri"]);
Assert.Equal("test-host", configData["rabbitmq:client:server"]);
Assert.Equal("test-password", configData["rabbitmq:client:password"]);
Assert.Equal("test-port", configData["rabbitmq:client:port"]);
Assert.Equal("test-username", configData["rabbitmq:client:username"]);
Assert.Equal("test-virtual-host", configData["rabbitmq:client:virtualhost"]);
}

[Fact]
public void MySqlTest_BindingTypeEnabled()
{
Expand Down Expand Up @@ -63,4 +46,21 @@ public void PostgreSqlTest_BindingTypeEnabled()
Assert.Equal("root.cert", configData["postgres:client:sslrootcert"]);
Assert.Equal("--cluster=routing-id&opt=val1", configData["postgres:client:options"]);
}

[Fact]
public void RabbitMQTest_BindingTypeEnabled()
{
var postProcessor = new RabbitMQLegacyConnectorPostProcessor();

Dictionary<string, string> configData = GetConfigData(_testBindingName, RabbitMQPostProcessor.BindingTypeKey, Tuple.Create("addresses", "test-addresses"), Tuple.Create("host", "test-host"), Tuple.Create("password", "test-password"), Tuple.Create("port", "test-port"), Tuple.Create("username", "test-username"), Tuple.Create("virtual-host", "test-virtual-host"));

// BindingType enabled
postProcessor.PostProcessConfiguration(GetConfigurationProvider(postProcessor, RabbitMQPostProcessor.BindingTypeKey, true), configData);
Assert.Equal("test-addresses", configData["rabbitmq:client:uri"]);
Assert.Equal("test-host", configData["rabbitmq:client:server"]);
Assert.Equal("test-password", configData["rabbitmq:client:password"]);
Assert.Equal("test-port", configData["rabbitmq:client:port"]);
Assert.Equal("test-username", configData["rabbitmq:client:username"]);
Assert.Equal("test-virtual-host", configData["rabbitmq:client:virtualhost"]);
}
}

0 comments on commit b48a048

Please sign in to comment.