feat: restrict admin access to club operations and rollout test environment
This commit is contained in:
@@ -303,55 +303,7 @@ public class ShiftCrudTests : IntegrationTestBase
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task DeleteShift_AsAdmin_DeletesShift()
|
||||
{
|
||||
// Arrange
|
||||
var shiftId = Guid.NewGuid();
|
||||
var clubId = Guid.NewGuid();
|
||||
var createdBy = Guid.NewGuid();
|
||||
var now = DateTimeOffset.UtcNow;
|
||||
|
||||
using (var scope = Factory.Services.CreateScope())
|
||||
{
|
||||
var context = scope.ServiceProvider.GetRequiredService<AppDbContext>();
|
||||
|
||||
context.Shifts.Add(new Shift
|
||||
{
|
||||
Id = shiftId,
|
||||
TenantId = "tenant1",
|
||||
Title = "Test Shift",
|
||||
StartTime = now.AddDays(1),
|
||||
EndTime = now.AddDays(1).AddHours(4),
|
||||
Capacity = 5,
|
||||
ClubId = clubId,
|
||||
CreatedById = createdBy,
|
||||
CreatedAt = now,
|
||||
UpdatedAt = now
|
||||
});
|
||||
|
||||
await context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
SetTenant("tenant1");
|
||||
AuthenticateAs("admin@test.com", new Dictionary<string, string> { ["tenant1"] = "Admin" });
|
||||
|
||||
// Act
|
||||
var response = await Client.DeleteAsync($"/api/shifts/{shiftId}");
|
||||
|
||||
// Assert
|
||||
Assert.Equal(HttpStatusCode.NoContent, response.StatusCode);
|
||||
|
||||
// Verify shift is deleted
|
||||
using (var scope = Factory.Services.CreateScope())
|
||||
{
|
||||
var context = scope.ServiceProvider.GetRequiredService<AppDbContext>();
|
||||
var shift = await context.Shifts.FindAsync(shiftId);
|
||||
Assert.Null(shift);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task DeleteShift_AsManager_ReturnsForbidden()
|
||||
public async Task DeleteShift_AsManager_DeletesShift()
|
||||
{
|
||||
// Arrange
|
||||
var shiftId = Guid.NewGuid();
|
||||
@@ -387,7 +339,15 @@ public class ShiftCrudTests : IntegrationTestBase
|
||||
var response = await Client.DeleteAsync($"/api/shifts/{shiftId}");
|
||||
|
||||
// Assert
|
||||
Assert.Equal(HttpStatusCode.Forbidden, response.StatusCode);
|
||||
Assert.Equal(HttpStatusCode.NoContent, response.StatusCode);
|
||||
|
||||
// Verify shift is deleted
|
||||
using (var scope = Factory.Services.CreateScope())
|
||||
{
|
||||
var context = scope.ServiceProvider.GetRequiredService<AppDbContext>();
|
||||
var shift = await context.Shifts.FindAsync(shiftId);
|
||||
Assert.Null(shift);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
Reference in New Issue
Block a user