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

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Alba.Security;
using IntegrationTests;
using JasperFx;
using JasperFx.CodeGeneration;
using JasperFx.MultiTenancy;
using Marten;
using Marten.Metadata;
Expand Down Expand Up @@ -35,7 +36,7 @@ public multi_tenancy_detection_and_integration(ITestOutputHelper output)

public void Dispose()
{
theHost.Dispose();
theHost?.Dispose();
}

// The configuration of the Wolverine.HTTP endpoints is the only variable
Expand Down Expand Up @@ -65,6 +66,11 @@ protected async Task configure(Action<WolverineHttpOptions> configure)
opts.Policies.AutoApplyTransactions();
});

builder.Services.CritterStackDefaults(opts =>
{
opts.Development.GeneratedCodeMode = TypeLoadMode.Auto;
});

builder.Services.AddWolverineHttp();
builder.Services.AddAuthentication("test");
builder.Services.AddAuthorization();
Expand Down Expand Up @@ -365,9 +371,19 @@ await configure(opts =>
opts.TenantId.IsRouteArgumentNamed("tenant");
opts.TenantId.AssertExists();
});



var chain = theHost.Services.GetRequiredService<WolverineHttpOptions>().Endpoints
.ChainFor("POST", "/tenant/{tenant}/formdata");

chain.IsFormData.ShouldBeTrue();

var formData = new Dictionary<string, string> { { "value", "blue" } };
var result = await theHost.Scenario(x => x.Post.FormData(formData).ToUrl("/tenant/red/formdata"));
var result = await theHost.Scenario(x =>
{
x.Post.FormData(formData).ContentType("application/x-www-form-urlencoded").ToUrl("/tenant/red/formdata");
});
result.ReadAsText().ShouldBe("red");
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using JasperFx;
using JasperFx.CodeGeneration.Frames;
using JasperFx.MultiTenancy;
using Microsoft.Extensions.DependencyInjection;
using Shouldly;

namespace Wolverine.Http.Tests.MultiTenancy;

public class using_form_data_on_primitives_with_tenant_id
{
[Fact]
public void determine_that_it_is_form_data_and_tenant_id_is_sourced_from_tenant_detection()
{
var method = new MethodCall(typeof(TenantedEndpoints), "GetTenantIdWithFormData");
var serviceCollection = new ServiceCollection();
var chain1 = new HttpChain(method,
new HttpGraph(new WolverineOptions(), new ServiceContainer(serviceCollection, serviceCollection.BuildServiceProvider())));

chain1.IsFormData.ShouldBeTrue();
chain1.RequestType.ShouldNotBe(typeof(TenantId));

}
}
5 changes: 4 additions & 1 deletion src/Http/Wolverine.Http/CodeGen/FormBindingFrame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ public bool TryMatch(HttpChain chain, IServiceContainer container, ParameterInfo
return false;
}
variable = chain.TryFindOrCreateFormValue(parameter);
if(variable != null){
if(variable != null)
{
chain.RequestType = typeof(void);
chain.IsFormData = true; // THIS IS IMPORTANT!
return true;
}

Expand Down
Loading