mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 18:21:10 +00:00
Hardens the library API security tests
This commit is contained in:
1 parent
3d089b063f
commit
ab5cbfb949
17 files changed
+457
-40
No files matched your search
+18
@@ -220,6 +220,24 @@ public class LuminaApiFactory : WebApplicationFactory<Program>, IDisposable
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes a test user and its owned libraries from the database.
|
||||
/// </summary>
|
||||
/// <param name="username">The username of the test user to remove.</param>
|
||||
public void RemoveTestUser(string username)
|
||||
{
|
||||
using IServiceScope scope = Services.CreateScope();
|
||||
LuminaDbContext dbContext = scope.ServiceProvider.GetRequiredService<LuminaDbContext>();
|
||||
|
||||
UserEntity? user = dbContext.Users.Include(candidate => candidate.Libraries).FirstOrDefault(candidate => candidate.Username == username);
|
||||
if (user is not null)
|
||||
{
|
||||
dbContext.Libraries.RemoveRange(user.Libraries);
|
||||
dbContext.Users.Remove(user);
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes a test admin user, its role, and its user-role link from the database.
|
||||
/// </summary>
|
||||
|
||||
Reference in new issue
Block a user