-
-
Notifications
You must be signed in to change notification settings - Fork 142
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Option to disable persistence altogether with a HostBuilderExtension. C…
…loses GH-723
- Loading branch information
1 parent
29a1d05
commit b9dfeab
Showing
10 changed files
with
117 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/Http/Wolverine.Http.Tests/bootstrap_with_no_persistence.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using Alba; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Shouldly; | ||
using Wolverine.Persistence.Durability; | ||
using Wolverine.Tracking; | ||
|
||
namespace Wolverine.Http.Tests; | ||
|
||
public class bootstrap_with_no_persistence | ||
{ | ||
[Fact] | ||
public async Task start_up_with_no_persistence() | ||
{ | ||
#region sample_bootstrap_with_no_persistence | ||
|
||
using var host = await AlbaHost.For<Program>(builder => | ||
{ | ||
builder.ConfigureServices(services => | ||
{ | ||
// You probably have to do both | ||
services.DisableAllExternalWolverineTransports(); | ||
services.DisableAllWolverineMessagePersistence(); | ||
}); | ||
}); | ||
|
||
#endregion | ||
|
||
host.Services.GetRequiredService<IMessageStore>().ShouldBeOfType<NullMessageStore>(); | ||
host.GetRuntime().Storage.ShouldBeOfType<NullMessageStore>(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,8 @@ | |
using IntegrationTests; | ||
using Marten; | ||
using Marten.Metadata; | ||
using Microsoft.AspNetCore.Authentication; | ||
using Microsoft.AspNetCore.Authorization; | ||
using Microsoft.AspNetCore.Builder; | ||
using Microsoft.AspNetCore.Http; | ||
using Microsoft.AspNetCore.Http.Features; | ||
|
@@ -41,6 +43,7 @@ public void Dispose() | |
protected async Task configure(Action<WolverineHttpOptions> configure) | ||
{ | ||
var builder = WebApplication.CreateBuilder([]); | ||
|
||
builder.Services.AddScoped<IUserService, UserService>(); | ||
|
||
// Haven't gotten around to it yet, but there'll be some end to | ||
|
@@ -57,17 +60,21 @@ protected async Task configure(Action<WolverineHttpOptions> configure) | |
}); | ||
|
||
builder.Services.AddWolverineHttp(); | ||
builder.Services.AddAuthentication("test"); | ||
builder.Services.AddAuthorization(); | ||
|
||
// Setting up Alba stubbed authentication so that we can fake | ||
// out ClaimsPrincipal data on requests later | ||
var securityStub = new AuthenticationStub() | ||
var securityStub = new AuthenticationStub("test") | ||
.With("foo", "bar") | ||
.With(JwtRegisteredClaimNames.Email, "[email protected]") | ||
.WithName("jeremy"); | ||
|
||
// Spinning up a test application using Alba | ||
theHost = await AlbaHost.For(builder, app => | ||
{ | ||
app.UseAuthentication(); | ||
app.UseAuthorization(); | ||
app.MapWolverineEndpoints(configure); | ||
}, securityStub); | ||
|
||
|
@@ -367,12 +374,14 @@ public async Task does_tag_current_activity_with_tenant_id() | |
|
||
public static class TenantedEndpoints | ||
{ | ||
[Authorize] | ||
[WolverineGet("/tenant/route/{tenant}")] | ||
public static string GetTenantIdFromRoute(IMessageBus bus) | ||
{ | ||
return bus.TenantId; | ||
} | ||
|
||
[Authorize] | ||
[WolverineGet("/tenant")] | ||
public static string GetTenantIdFromWhatever(IMessageBus bus, HttpContext httpContext) | ||
{ | ||
|
@@ -470,4 +479,12 @@ public static CustomActivityFeature FromHttpContext(HttpContext httpContext) | |
var activity = httpContext.Features.Get<IHttpActivityFeature>()?.Activity; | ||
return new CustomActivityFeature(activity); | ||
} | ||
} | ||
|
||
public class StubAuthenticationHandlerProvider : IAuthenticationHandlerProvider | ||
{ | ||
public Task<IAuthenticationHandler?> GetHandlerAsync(HttpContext context, string authenticationScheme) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters