Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public static IResourceBuilder<OpenTelemetryCollectorResource> AddOpenTelemetryC
resourceBuilder.WithEndpoint(targetPort: 4318, name: OpenTelemetryCollectorResource.HttpEndpointName, scheme: isHttpsEnabled ? "https" : "http");


if (!settings.ForceNonSecureReceiver && isHttpsEnabled && builder.ExecutionContext.IsRunMode && builder.Environment.IsDevelopment())
if (!settings.ForceNonSecureReceiver && isHttpsEnabled && builder.ExecutionContext.IsRunMode)
{
resourceBuilder.RunWithHttpsDevCertificate();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,37 +329,6 @@ public void ForceNonSecureReceiverOverridesHttpsEndpoints()
Assert.Equal("http", httpEndpoint.UriScheme);
}

[Fact]
public void DevCertificateLogicIsNotTriggeredInNonDevelopmentEnvironment()
{
var builder = DistributedApplication.CreateBuilder();
builder.Configuration["ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL"] = "https://localhost:18889";

builder.AddOpenTelemetryCollector("collector", settings =>
{
settings.ForceNonSecureReceiver = false; // Allow HTTPS
})
.WithAppForwarding();

using var app = builder.Build();

var appModel = app.Services.GetRequiredService<DistributedApplicationModel>();
var collectorResource = appModel.Resources.OfType<OpenTelemetryCollectorResource>().SingleOrDefault();
Assert.NotNull(collectorResource);

// In non-development environment (default test environment), dev cert args should not be added
var args = collectorResource.Annotations.OfType<CommandLineArgsCallbackAnnotation>().ToList();
var context = new CommandLineArgsCallbackContext([]);
foreach (var arg in args)
{
arg.Callback(context);
}

// Should not contain TLS certificate configuration args since we're not in Development environment with RunMode
Assert.DoesNotContain(context.Args.Cast<string>(), a => a.Contains("receivers::otlp::protocols::http::tls::cert_file"));
Assert.DoesNotContain(context.Args.Cast<string>(), a => a.Contains("receivers::otlp::protocols::grpc::tls::cert_file"));
}

[Fact]
public void DevCertificateLogicIsNotTriggeredWhenForceNonSecureReceiverEnabled()
{
Expand Down Expand Up @@ -464,7 +433,7 @@ public void RunWithHttpsDevCertificateAddsContainerFilesAndWaitAnnotation()
public void RunWithHttpsDevCertificateNotTriggeredInNonRunMode()
{
// Use regular builder (not TestDistributedApplicationBuilder.Create) which defaults to non-Run mode
var builder = DistributedApplication.CreateBuilder();
var builder = TestDistributedApplicationBuilder.Create(DistributedApplicationOperation.Publish);
builder.Configuration["ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL"] = "https://localhost:18889";

builder.AddOpenTelemetryCollector("collector", settings =>
Expand Down Expand Up @@ -522,7 +491,7 @@ public void RunWithHttpsDevCertificateNotTriggeredWhenForceNonSecureEnabled()
}

[Fact]
public void DevCertificateResourcesAddedWhenHttpsEnabledInDevelopment()
public void DevCertificateResourcesAddedWhenHttpsEnabled()
{
var builder = TestDistributedApplicationBuilder.Create(DistributedApplicationOperation.Run);
builder.Configuration["ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL"] = "https://localhost:18889";
Expand Down
Loading