Skip to content

Commit

Permalink
Adapt tests
Browse files Browse the repository at this point in the history
remove trimming

fix tests

fix tests

fix tests

fix test
  • Loading branch information
anna-git committed Oct 11, 2024
1 parent 44de441 commit 7701b11
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,6 @@
<assembly fullname="System.Data.SqlClient" />
<assembly fullname="System.Data.SQLite" />
<assembly fullname="System.Diagnostics.Debug">
<type fullname="System.Diagnostics.Debug" />
<type fullname="System.Diagnostics.Debugger" />
<type fullname="System.Diagnostics.DebuggerBrowsableAttribute" />
<type fullname="System.Diagnostics.DebuggerBrowsableState" />
Expand Down Expand Up @@ -547,8 +546,6 @@
<type fullname="System.Diagnostics.CodeAnalysis.NotNullIfNotNullAttribute" />
<type fullname="System.Diagnostics.CodeAnalysis.NotNullWhenAttribute" />
<type fullname="System.Diagnostics.ConditionalAttribute" />
<type fullname="System.Diagnostics.Debug" />
<type fullname="System.Diagnostics.Debug/AssertInterpolatedStringHandler" />
<type fullname="System.Diagnostics.DebuggableAttribute" />
<type fullname="System.Diagnostics.DebuggableAttribute/DebuggingModes" />
<type fullname="System.Diagnostics.Debugger" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static void AddSpanTags(Span span, IResult result)
}

// We need a context
if (!securityCoordinator.Value.IsAdditiveContextDisposed())
if (securityCoordinator.Value.IsAdditiveContextDisposed())
{
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,24 +54,23 @@ private SecurityCoordinator(Security security, Span span, HttpTransport transpor

private bool CanAccessHeaders => UsingIntegratedPipeline is true or null;

internal static SecurityCoordinator? TryGet(Security security, Span span, HttpTransport? transport = null)
internal static SecurityCoordinator? TryGet(Security security, Span span)
{
if (transport == null)
if (HttpContext.Current is null)
{
if (HttpContext.Current is null)
{
Log.Warning("Can't instantiate SecurityCoordinator.Framework as no transport has been provided and HttpContext.Current null, make sure HttpContext is available");
return null;
}

transport = new HttpTransport(HttpContext.Current);
Log.Warning("Can't instantiate SecurityCoordinator.Framework as no transport has been provided and HttpContext.Current null, make sure HttpContext is available");
return null;
}

var transport = new HttpTransport(HttpContext.Current);

return new SecurityCoordinator(security, span, transport);
}

internal static SecurityCoordinator Get(Security security, Span span, HttpContext context) => new(security, span, new HttpTransport(context));

internal static SecurityCoordinator Get(Security security, Span span, HttpTransport transport) => new(security, span, transport);

private static Action<IResult, HttpStatusCode, string, string>? CreateThrowHttpResponseExceptionDynMeth()
{
try
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

using Datadog.Trace.AppSec.Coordinator;
using FluentAssertions;
using Moq;
using Xunit;

namespace Datadog.Trace.Security.Unit.Tests
Expand All @@ -16,7 +15,8 @@ public class SecurityCoordinatorTests
public void DefaultBehavior()
{
var target = new AppSec.Security();
var secCoord = SecurityCoordinator.TryGet(target, new Mock<Span>().Object);
var span = new Span(new SpanContext(1, 1), new System.DateTimeOffset());
var secCoord = SecurityCoordinator.TryGet(target, span);
secCoord.Should().BeNull();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
using FluentAssertions;
using Moq;
using Xunit;
using static Datadog.Trace.AppSec.Coordinator.SecurityCoordinator;

namespace Datadog.Trace.Tests.Util;

Expand Down Expand Up @@ -79,8 +78,8 @@ private static void CheckRequest(HttpRequest request)
scope.Span.ServiceName = "service";
HttpContext context = new HttpContext(request, new HttpResponse(new System.IO.StringWriter()));
request.ValidateInput();
HttpTransport transport = new HttpTransport(context);
var securityCoordinator = new SecurityCoordinator(security, scope.Span, transport);
var transport = new SecurityCoordinator.HttpTransport(context);
var securityCoordinator = SecurityCoordinator.Get(security, scope.Span, transport);
// We should not launch any exception here
var result = securityCoordinator.GetBasicRequestArgsForWaf();
var iastContext = new IastRequestContext();
Expand Down

0 comments on commit 7701b11

Please sign in to comment.