@@ -279,8 +279,10 @@ public async Task DashboardResourceServiceUriIsSet()
279279 Assert . Equal ( "http://localhost:5000" , config . Single ( e => e . Key == DashboardConfigNames . ResourceServiceUrlName . EnvVarName ) . Value ) ;
280280 }
281281
282- [ Fact ]
283- public async Task DashboardResource_OtlpHttpEndpoint_CorsEnvVarSet ( )
282+ [ Theory ]
283+ [ InlineData ( "*" ) ]
284+ [ InlineData ( null ) ]
285+ public async Task DashboardResource_OtlpHttpEndpoint_CorsEnvVarSet ( string ? explicitCorsAllowedOrigins )
284286 {
285287 // Arrange
286288 using var builder = TestDistributedApplicationBuilder . Create (
@@ -296,7 +298,8 @@ public async Task DashboardResource_OtlpHttpEndpoint_CorsEnvVarSet()
296298 builder . Configuration . AddInMemoryCollection ( new Dictionary < string , string ? >
297299 {
298300 [ "ASPNETCORE_URLS" ] = "http://localhost" ,
299- [ "DOTNET_DASHBOARD_OTLP_HTTP_ENDPOINT_URL" ] = "http://localhost"
301+ [ "DOTNET_DASHBOARD_OTLP_HTTP_ENDPOINT_URL" ] = "http://localhost" ,
302+ [ "DOTNET_DASHBOARD_CORS_ALLOWED_ORIGINS" ] = explicitCorsAllowedOrigins
300303 } ) ;
301304
302305 using var app = builder . Build ( ) ;
@@ -314,12 +317,15 @@ public async Task DashboardResource_OtlpHttpEndpoint_CorsEnvVarSet()
314317
315318 var config = await EnvironmentVariableEvaluator . GetEnvironmentVariablesAsync ( dashboard , DistributedApplicationOperation . Run , app . Services ) ;
316319
317- Assert . Equal ( "http://localhost:8081,http://localhost:58080" , config . Single ( e => e . Key == DashboardConfigNames . DashboardOtlpCorsAllowedOriginsKeyName . EnvVarName ) . Value ) ;
320+ var expectedAllowedOrigins = ! string . IsNullOrEmpty ( explicitCorsAllowedOrigins ) ? explicitCorsAllowedOrigins : "http://localhost:8081,http://localhost:58080" ;
321+ Assert . Equal ( expectedAllowedOrigins , config . Single ( e => e . Key == DashboardConfigNames . DashboardOtlpCorsAllowedOriginsKeyName . EnvVarName ) . Value ) ;
318322 Assert . Equal ( "*" , config . Single ( e => e . Key == DashboardConfigNames . DashboardOtlpCorsAllowedHeadersKeyName . EnvVarName ) . Value ) ;
319323 }
320324
321- [ Fact ]
322- public async Task DashboardResource_OtlpGrpcEndpoint_CorsEnvVarNotSet ( )
325+ [ Theory ]
326+ [ InlineData ( "*" ) ]
327+ [ InlineData ( null ) ]
328+ public async Task DashboardResource_OtlpGrpcEndpoint_CorsEnvVarNotSet ( string ? explicitCorsAllowedOrigins )
323329 {
324330 // Arrange
325331 using var builder = TestDistributedApplicationBuilder . Create (
@@ -335,7 +341,8 @@ public async Task DashboardResource_OtlpGrpcEndpoint_CorsEnvVarNotSet()
335341 builder . Configuration . AddInMemoryCollection ( new Dictionary < string , string ? >
336342 {
337343 [ "ASPNETCORE_URLS" ] = "http://localhost" ,
338- [ "DOTNET_DASHBOARD_OTLP_ENDPOINT_URL" ] = "http://localhost"
344+ [ "DOTNET_DASHBOARD_OTLP_ENDPOINT_URL" ] = "http://localhost" ,
345+ [ "DOTNET_DASHBOARD_CORS_ALLOWED_ORIGINS" ] = explicitCorsAllowedOrigins
339346 } ) ;
340347
341348 using var app = builder . Build ( ) ;
0 commit comments