mirror of
https://github.com/azaion/missions.git
synced 2026-06-21 09:51:07 +00:00
6b2c2d998e
Adds 26 blackbox tests (FT-P-01..18, FT-N-01..08) covering full AC
matrices for Vehicles/Missions/Waypoints/Health/Errors. Three
spec-vs-code carry-forwards documented in batch_02_report.md and
pinned with [Trait("carry_forward", ...)].
Shared scaffolding: ApiDtos.cs, AssertProblemEnvelopeAsync helper,
Seeds.cs, StubSchema.cs, CascadeF3/F4 fixtures, PostgresStopStart
fixture (gated by COMPOSE_RESTART_ENABLED). Removes the 4 placeholder
Sanity.cs files (now superseded). docker-compose.test.yml gains the
expected_results volume mount + FIXTURE_SQL_DIR for the consumer.
Co-authored-by: Cursor <cursoragent@cursor.com>
76 lines
2.7 KiB
C#
76 lines
2.7 KiB
C#
using System.Net;
|
|
using System.Net.Http.Headers;
|
|
using System.Net.Http.Json;
|
|
using Azaion.Missions.E2E.Fixtures;
|
|
using Azaion.Missions.E2E.Helpers;
|
|
using Xunit;
|
|
|
|
namespace Azaion.Missions.E2E.Tests.Missions;
|
|
|
|
/// <summary>
|
|
/// FT-N-04 (carry-forward 400 for bogus VehicleId) and FT-N-05 (GET 404).
|
|
/// FT-N-06 (cascade short-circuit) lives in <see cref="CascadeShortCircuitTests"/>
|
|
/// because it manipulates Postgres logging and owns its own collection.
|
|
/// Traces: AC-2.2 (carry-forward), AC-2.4 / AC-8.2.
|
|
/// </summary>
|
|
[Collection("Missions")]
|
|
[Trait("Category", "Blackbox")]
|
|
[Trait("db_access", "seed-or-assert-only")]
|
|
public sealed class NegativeTests : TestBase, IClassFixture<DbResetFixture>
|
|
{
|
|
[Fact]
|
|
[Trait("Traces", "AC-2.2")]
|
|
[Trait("max_ms", "2000")]
|
|
[Trait("carry_forward", "AC-2.2")]
|
|
public async Task FT_N_04_create_mission_with_bogus_vehicle_id_returns_400_today()
|
|
{
|
|
// CARRY-FORWARD: spec wants 404 (results_report.md row 2.2 carry-forward).
|
|
// Today the SUT throws ArgumentException → ErrorHandlingMiddleware maps
|
|
// to 400. Flip to 404 expectation when the divergence is closed.
|
|
|
|
// Arrange
|
|
DbResetFixture.ResetDatabase(TestEnvironment.DbSideChannel);
|
|
var token = await Tokens.MintDefaultAsync();
|
|
var bogusVehicleId = Guid.NewGuid();
|
|
|
|
// Act
|
|
using var http = new HttpRequestMessage(HttpMethod.Post, "/missions")
|
|
{
|
|
Content = JsonContent.Create(new
|
|
{
|
|
Name = "x",
|
|
VehicleId = bogusVehicleId,
|
|
CreatedDate = (DateTime?)null
|
|
})
|
|
};
|
|
http.Headers.Authorization = new AuthenticationHeaderValue("Bearer", token.Jwt);
|
|
using var response = await Missions.SendAsync(http);
|
|
|
|
// Assert
|
|
await HttpAssertions.AssertProblemEnvelopeAsync(response, HttpStatusCode.BadRequest)
|
|
;
|
|
var missionsRows = DbAssertions.TableRowCount("missions");
|
|
Assert.Equal(0L, missionsRows);
|
|
}
|
|
|
|
[Fact]
|
|
[Trait("Traces", "AC-2.4,AC-8.2")]
|
|
[Trait("max_ms", "2000")]
|
|
public async Task FT_N_05_get_mission_returns_404_with_problem_envelope()
|
|
{
|
|
// Arrange
|
|
DbResetFixture.ResetDatabase(TestEnvironment.DbSideChannel);
|
|
var token = await Tokens.MintDefaultAsync();
|
|
var randomId = Guid.NewGuid();
|
|
|
|
// Act
|
|
using var http = new HttpRequestMessage(HttpMethod.Get, $"/missions/{randomId}");
|
|
http.Headers.Authorization = new AuthenticationHeaderValue("Bearer", token.Jwt);
|
|
using var response = await Missions.SendAsync(http);
|
|
|
|
// Assert
|
|
await HttpAssertions.AssertProblemEnvelopeAsync(response, HttpStatusCode.NotFound)
|
|
;
|
|
}
|
|
}
|