refactor: rename namespace to FiscalFlow and upgrade to .NET 10
- Rename InvoiceMaster.* to FiscalFlow.* namespace - Upgrade from .NET 8 to .NET 10 - Update all NuGet packages to latest versions - Update C# language version to 14.0
This commit is contained in:
@@ -0,0 +1,94 @@
|
||||
using FiscalFlow.IntegrationTests.Factories;
|
||||
using System.Net;
|
||||
using System.Net.Http.Json;
|
||||
using System.Text.Json;
|
||||
using Xunit;
|
||||
using FluentAssertions;
|
||||
|
||||
namespace FiscalFlow.IntegrationTests.Controllers;
|
||||
|
||||
public class AuthControllerTests : IClassFixture<CustomWebApplicationFactory>
|
||||
{
|
||||
private readonly CustomWebApplicationFactory _factory;
|
||||
private readonly HttpClient _client;
|
||||
|
||||
public AuthControllerTests(CustomWebApplicationFactory factory)
|
||||
{
|
||||
_factory = factory;
|
||||
_client = factory.CreateClient();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Register_WithValidData_ShouldReturnSuccess()
|
||||
{
|
||||
var request = new
|
||||
{
|
||||
email = $"test{Guid.NewGuid()}@example.com",
|
||||
password = "Password123!",
|
||||
fullName = "Test User"
|
||||
};
|
||||
|
||||
var response = await _client.PostAsJsonAsync("/api/v1/auth/register", request);
|
||||
var content = await response.Content.ReadAsStringAsync();
|
||||
|
||||
response.StatusCode.Should().Be(HttpStatusCode.OK);
|
||||
content.Should().Contain("success\"");
|
||||
content.Should().Contain("accessToken\"");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Register_WithInvalidEmail_ShouldReturnBadRequest()
|
||||
{
|
||||
var request = new
|
||||
{
|
||||
email = "invalid-email",
|
||||
password = "Password123!"
|
||||
};
|
||||
|
||||
var response = await _client.PostAsJsonAsync("/api/v1/auth/register", request);
|
||||
|
||||
response.StatusCode.Should().Be(HttpStatusCode.BadRequest);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Login_WithValidCredentials_ShouldReturnTokens()
|
||||
{
|
||||
var email = $"login{Guid.NewGuid()}@example.com";
|
||||
var password = "Password123!";
|
||||
|
||||
var registerRequest = new { email, password, fullName = "Test User" };
|
||||
await _client.PostAsJsonAsync("/api/v1/auth/register", registerRequest);
|
||||
|
||||
var loginRequest = new { email, password };
|
||||
var response = await _client.PostAsJsonAsync("/api/v1/auth/login", loginRequest);
|
||||
var content = await response.Content.ReadAsStringAsync();
|
||||
|
||||
response.StatusCode.Should().Be(HttpStatusCode.OK);
|
||||
content.Should().Contain("accessToken\"");
|
||||
content.Should().Contain("refreshToken\"");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Login_WithInvalidCredentials_ShouldReturnUnauthorized()
|
||||
{
|
||||
var request = new
|
||||
{
|
||||
email = "nonexistent@example.com",
|
||||
password = "WrongPassword"
|
||||
};
|
||||
|
||||
var response = await _client.PostAsJsonAsync("/api/v1/auth/login", request);
|
||||
|
||||
response.StatusCode.Should().Be(HttpStatusCode.Unauthorized);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task HealthCheck_ShouldReturnHealthy()
|
||||
{
|
||||
var response = await _client.GetAsync("/api/v1/health");
|
||||
var content = await response.Content.ReadAsStringAsync();
|
||||
|
||||
response.StatusCode.Should().Be(HttpStatusCode.OK);
|
||||
content.Should().Contain("healthy");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user