Skip to content

Commit 4eb60f2

Browse files
committed
testing and fix validation
1 parent 2ab22d2 commit 4eb60f2

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

src/Digdir.Domain.Dialogporten.Infrastructure/InfrastructureExtensions.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
using Digdir.Domain.Dialogporten.Infrastructure.Altinn.Events;
2727
using Digdir.Domain.Dialogporten.Infrastructure.Altinn.OrganizationRegistry;
2828
using Digdir.Domain.Dialogporten.Infrastructure.Altinn.ResourceRegistry;
29+
using StackExchange.Redis;
2930

3031
namespace Digdir.Domain.Dialogporten.Infrastructure;
3132

@@ -59,7 +60,7 @@ public static IServiceCollection AddInfrastructure(this IServiceCollection servi
5960
var infrastructureSettings = infrastructureConfigurationSection.Get<InfrastructureSettings>()
6061
?? throw new InvalidOperationException("Failed to get Redis settings. Infrastructure settings must not be null.");
6162

62-
if (infrastructureSettings.Redis.Enabled)
63+
if (infrastructureSettings.Redis.Enabled == true)
6364
{
6465
services.AddStackExchangeRedisCache(options =>
6566
{

src/Digdir.Domain.Dialogporten.Infrastructure/InfrastructureSettings.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public sealed class AltinnCdnPlatformSettings
2929

3030
public sealed class RedisSettings
3131
{
32-
public required bool Enabled { get; init; }
32+
public required bool? Enabled { get; init; }
3333
public required string ConnectionString { get; init; }
3434
}
3535

@@ -93,7 +93,7 @@ internal sealed class RedisSettingsValidator : AbstractValidator<RedisSettings>
9393
{
9494
public RedisSettingsValidator()
9595
{
96-
RuleFor(x => x.Enabled).NotEmpty();
96+
RuleFor(x => x.Enabled).Must(x => x is false or true);
9797
RuleFor(x => x.ConnectionString).NotEmpty();
9898
}
9999
}

src/Digdir.Domain.Dialogporten.WebApi/appsettings.Development.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
}
77
},
88
"Infrastructure": {
9-
"Redis":{
10-
"Enabled": false,
11-
"ConnectionString": "redis://localhost:6379"
9+
"Redis": {
10+
"Enabled": true,
11+
"ConnectionString": "localhost:6379"
1212
},
1313
"DialogDbConnectionString": "TODO: Add to local secrets",
1414
// Settings from appsettings.json, environment variables or other configuration providers.

0 commit comments

Comments
 (0)