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
2 changes: 1 addition & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<PackageVersion Include="PANiXiDA.Core.Infrastructure.Messaging.Wolverine" Version="2.0.4" />
<PackageVersion Include="PANiXiDA.Core.Infrastructure.Persistence.Ef" Version="2.0.1" />
<PackageVersion Include="PANiXiDA.Core.Observability" Version="1.0.3" />
<PackageVersion Include="PANiXiDA.Core.Presentation.Http" Version="2.0.6" />
<PackageVersion Include="PANiXiDA.Core.Presentation.Http" Version="2.0.7" />
<PackageVersion Include="PANiXiDA.Core.ResultPattern" Version="1.0.2" />
<PackageVersion Include="PANiXiDA.Core.SpecificationPattern" Version="1.0.2" />
<PackageVersion Include="PANiXiDA.Core.Ef.Migrator" Version="1.0.3" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using System.Text.Json;

using Microsoft.Extensions.Hosting;

namespace PANiXiDA.TacticalHeroes.Identity.FunctionalTests.Presentation.Features.OAuth.OpenApi;

public sealed class IdentityOpenApiDocumentTests(FunctionalTestFixture fixture)
: FunctionalTestBase(fixture)
{
[Fact(DisplayName = "GET Identity OpenAPI document should include OAuth endpoints when requested")]
public async Task GetIdentityOpenApiDocument_Should_IncludeOAuthEndpoints_When_Requested()
{
var cancellationToken = TestContext.Current.CancellationToken;
using var client = Fixture.CreateClient(Environments.Development);

using var response = await client.GetAsync(
"/openapi/identity.json",
cancellationToken);
var responseBody = await response.Content.ReadAsStringAsync(cancellationToken);

response.StatusCode.ShouldBe(HttpStatusCode.OK, responseBody);
using var document = JsonDocument.Parse(responseBody);
var paths = document.RootElement
.GetProperty("paths")
.EnumerateObject()
.Select(path => path.Name)
.ToArray();

paths.ShouldContain("/connect/authorize");
paths.ShouldContain("/connect/introspect");
paths.ShouldContain("/connect/logout");
paths.ShouldContain("/connect/par");
paths.ShouldContain("/connect/revoke");
paths.ShouldContain("/connect/token");
paths.ShouldContain("/connect/userinfo");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,17 @@ public HttpClient CreateClient(WebApplicationFactoryClientOptions options)
return client;
}

public HttpClient CreateClient(string environmentName)
{
var factory = new FunctionalTestWebApplicationFactory(environmentName);
_factories.Add(factory);

var client = factory.CreateClient();
_clients.Add(client);

return client;
}

private void CreateCurrentClient()
{
_factory = new FunctionalTestWebApplicationFactory();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@

namespace PANiXiDA.TacticalHeroes.Identity.FunctionalTests.Presentation;

internal sealed class FunctionalTestWebApplicationFactory
internal sealed class FunctionalTestWebApplicationFactory(string environmentName = "Test")
: WebApplicationFactory<Program>
{
public CapturingEventBus EventBus { get; } = new();

protected override void ConfigureWebHost(IWebHostBuilder builder)
{
builder.UseEnvironment("Test");
builder.UseEnvironment(environmentName);
builder.ConfigureLogging(logging => logging.ClearProviders());
builder.ConfigureServices(services =>
{
Expand Down