Skip to content

Commit 8b07d9a

Browse files
committed
Add tests
1 parent fa32ae5 commit 8b07d9a

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

tests/Aspire.Hosting.Tests/DistributedApplicationBuilderTests.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4+
using Aspire.Hosting.Dashboard;
45
using Aspire.Hosting.Dcp;
56
using Aspire.Hosting.Lifecycle;
67
using Aspire.Hosting.Publishing;
@@ -95,6 +96,28 @@ public void AppHostDirectoryAvailableViaConfig()
9596
Assert.Equal(appHostDirectory, config["AppHost:Directory"]);
9697
}
9798

99+
[Fact]
100+
public void ResourceServiceConfig_Secured()
101+
{
102+
var appBuilder = DistributedApplication.CreateBuilder();
103+
using var app = appBuilder.Build();
104+
105+
var config = app.Services.GetRequiredService<IConfiguration>();
106+
Assert.Equal(nameof(ResourceServiceAuthMode.Unsecured), config["AppHost:ResourceService:AuthMode"]);
107+
Assert.False(string.IsNullOrEmpty(config["AppHost:ResourceService:ApiKey"]));
108+
}
109+
110+
[Fact]
111+
public void ResourceServiceConfig_Unsecured()
112+
{
113+
var appBuilder = DistributedApplication.CreateBuilder(args: [$"{KnownConfigNames.DashboardUnsecuredAllowAnonymous}=true"]);
114+
using var app = appBuilder.Build();
115+
116+
var config = app.Services.GetRequiredService<IConfiguration>();
117+
Assert.Equal(nameof(ResourceServiceAuthMode.Unsecured), config["AppHost:ResourceService:AuthMode"]);
118+
Assert.True(string.IsNullOrEmpty(config["AppHost:ResourceService:ApiKey"]));
119+
}
120+
98121
[Fact]
99122
public void AddResource_DuplicateResourceNames_SameCasing_Error()
100123
{

0 commit comments

Comments
 (0)