mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-10-14 17:54:42 +00:00
Migrate Auth/Brewery/Location repositories to pure Dapper; rename Timer to RowVersion (#237)
* Integrate Spectre.Console into seed application, use async data loading * Replace stored-procedure repositories with Dapper-based repositories Removes the USP_* stored procedures for Auth, Location, and Brewery data access in favour of services built with Dapper. Adds a new Features.Locations slice and optimistic concurrency support for the Brewery slice. * Add new documentation for Dapper migration/database schema * Update FluentAssertions to most recent open source ver * Update XML doc comment in backend projects * Modify brewery location dto to include denormalized data * - Updated column names from 'Timer' to 'RowVersion' in schema.sql for - Introduced new BeerPost entity and updated BreweryPost and BreweryPostLocation entities to use 'RowVersion' for concurrency. - Modified UserAccount, UserCredential, UserVerification, City, StateProvince, and Country entities to use 'RowVersion' instead of 'Timer'. - Updated tests and command handlers to reflect changes in concurrency token from 'Timer' to 'RowVersion'. - Adjusted BreweryDto and BreweryDtoMapper to include 'RowVersion' and updated mapping logic accordingly. - Ensured all repository methods and interfaces are aligned with the new concurrency handling approach. * updates * Add BeerStyle entity and related properties; refactor BreweryDto to remove BeerPosts * Fix Api.Specs test failures: stale Timer column refs and missing test.user fixture * Remove repository tests, usages of registration dto used in repo * archive old stored procs/functions * update stale docs * Add instructions for generating cryptographically secure base64 secrets on macOS/Linux and Windows
This commit is contained in:
@@ -83,10 +83,59 @@ public class AuthSteps(ScenarioContext scenario)
|
||||
);
|
||||
}
|
||||
|
||||
private const string FixtureUsername = "test.user";
|
||||
private const string FixturePassword = "Password1!";
|
||||
private const string FixtureEmail = "test.user@thebiergarten.app";
|
||||
|
||||
// Scenarios run in parallel across feature classes, and this fixture is shared by name.
|
||||
// Serializing provisioning avoids two scenarios racing to INSERT the same username/email,
|
||||
// which would otherwise surface as a raw SQL unique-constraint error instead of a clean 409.
|
||||
private static readonly SemaphoreSlim FixtureProvisioningLock = new(1, 1);
|
||||
|
||||
[Given("I have an existing account")]
|
||||
public void GivenIHaveAnExistingAccount()
|
||||
public async Task GivenIHaveAnExistingAccount()
|
||||
{
|
||||
scenario[TestUserKey] = ("test.user", "password");
|
||||
scenario[TestUserKey] = (FixtureUsername, FixturePassword);
|
||||
|
||||
HttpClient client = GetClient();
|
||||
var registrationData = new
|
||||
{
|
||||
username = FixtureUsername,
|
||||
firstName = "Test",
|
||||
lastName = "User",
|
||||
email = FixtureEmail,
|
||||
dateOfBirth = "1990-01-01",
|
||||
password = FixturePassword,
|
||||
};
|
||||
|
||||
HttpRequestMessage requestMessage = new(HttpMethod.Post, "/api/auth/register")
|
||||
{
|
||||
Content = new StringContent(
|
||||
JsonSerializer.Serialize(registrationData),
|
||||
Encoding.UTF8,
|
||||
"application/json"
|
||||
),
|
||||
};
|
||||
|
||||
// Registration is used (rather than relying on seeded data) so the fixture account is
|
||||
// guaranteed to exist regardless of run order. A 409 means another scenario in this run
|
||||
// already provisioned it, which is equally fine.
|
||||
await FixtureProvisioningLock.WaitAsync();
|
||||
HttpResponseMessage response;
|
||||
try
|
||||
{
|
||||
response = await client.SendAsync(requestMessage);
|
||||
}
|
||||
finally
|
||||
{
|
||||
FixtureProvisioningLock.Release();
|
||||
}
|
||||
|
||||
if ((int)response.StatusCode is not (201 or 409))
|
||||
throw new InvalidOperationException(
|
||||
$"Failed to provision fixture account '{FixtureUsername}': "
|
||||
+ $"{(int)response.StatusCode} {response.StatusCode}"
|
||||
);
|
||||
}
|
||||
|
||||
[Given("I do not have an existing account")]
|
||||
@@ -320,7 +369,7 @@ public class AuthSteps(ScenarioContext scenario)
|
||||
public async Task GivenIAmLoggedIn()
|
||||
{
|
||||
HttpClient client = GetClient();
|
||||
var loginData = new { username = "test.user", password = "password" };
|
||||
var loginData = new { username = FixtureUsername, password = FixturePassword };
|
||||
string body = JsonSerializer.Serialize(loginData);
|
||||
|
||||
HttpRequestMessage requestMessage = new(HttpMethod.Post, "/api/auth/login")
|
||||
|
||||
Reference in New Issue
Block a user