Use HWIDs for bans.

This commit is contained in:
Pieter-Jan Briers
2021-03-22 01:30:50 +01:00
parent 071362ed25
commit a321b4302e
19 changed files with 1589 additions and 181 deletions

View File

@@ -31,17 +31,17 @@ namespace Content.IntegrationTests.Tests.Commands
var clientId = clientSession.UserId;
// No bans on record
Assert.That(await sDatabase.GetServerBanAsync(null, clientId), Is.Null);
Assert.That(await sDatabase.GetServerBanAsync(null, clientId, null), Is.Null);
Assert.That(await sDatabase.GetServerBanAsync(1), Is.Null);
Assert.That(await sDatabase.GetServerBansAsync(null, clientId), Is.Empty);
Assert.That(await sDatabase.GetServerBansAsync(null, clientId, null), Is.Empty);
// Try to pardon a ban that does not exist
sConsole.ExecuteCommand("pardon 1");
// Still no bans on record
Assert.That(await sDatabase.GetServerBanAsync(null, clientId), Is.Null);
Assert.That(await sDatabase.GetServerBanAsync(null, clientId, null), Is.Null);
Assert.That(await sDatabase.GetServerBanAsync(1), Is.Null);
Assert.That(await sDatabase.GetServerBansAsync(null, clientId), Is.Empty);
Assert.That(await sDatabase.GetServerBansAsync(null, clientId, null), Is.Empty);
var banReason = "test";
@@ -49,20 +49,20 @@ namespace Content.IntegrationTests.Tests.Commands
sConsole.ExecuteCommand($"ban {clientSession.Name} {banReason} 1440");
// Should have one ban on record now
Assert.That(await sDatabase.GetServerBanAsync(null, clientId), Is.Not.Null);
Assert.That(await sDatabase.GetServerBanAsync(null, clientId, null), Is.Not.Null);
Assert.That(await sDatabase.GetServerBanAsync(1), Is.Not.Null);
Assert.That(await sDatabase.GetServerBansAsync(null, clientId), Has.Count.EqualTo(1));
Assert.That(await sDatabase.GetServerBansAsync(null, clientId, null), Has.Count.EqualTo(1));
// Try to pardon a ban that does not exist
sConsole.ExecuteCommand("pardon 2");
// The existing ban is unaffected
Assert.That(await sDatabase.GetServerBanAsync(null, clientId), Is.Not.Null);
Assert.That(await sDatabase.GetServerBanAsync(null, clientId, null), Is.Not.Null);
var ban = await sDatabase.GetServerBanAsync(1);
Assert.That(ban, Is.Not.Null);
Assert.That(await sDatabase.GetServerBansAsync(null, clientId), Has.Count.EqualTo(1));
Assert.That(await sDatabase.GetServerBansAsync(null, clientId, null), Has.Count.EqualTo(1));
// Check that it matches
Assert.That(ban.Id, Is.EqualTo(1));
@@ -81,14 +81,14 @@ namespace Content.IntegrationTests.Tests.Commands
sConsole.ExecuteCommand("pardon 1");
// No bans should be returned
Assert.That(await sDatabase.GetServerBanAsync(null, clientId), Is.Null);
Assert.That(await sDatabase.GetServerBanAsync(null, clientId, null), Is.Null);
// Direct id lookup returns a pardoned ban
var pardonedBan = await sDatabase.GetServerBanAsync(1);
Assert.That(pardonedBan, Is.Not.Null);
// The list is still returned since that ignores pardons
Assert.That(await sDatabase.GetServerBansAsync(null, clientId), Has.Count.EqualTo(1));
Assert.That(await sDatabase.GetServerBansAsync(null, clientId, null), Has.Count.EqualTo(1));
// Check that it matches
Assert.That(pardonedBan.Id, Is.EqualTo(1));
@@ -114,13 +114,13 @@ namespace Content.IntegrationTests.Tests.Commands
// Nothing changes
// No bans should be returned
Assert.That(await sDatabase.GetServerBanAsync(null, clientId), Is.Null);
Assert.That(await sDatabase.GetServerBanAsync(null, clientId, null), Is.Null);
// Direct id lookup returns a pardoned ban
Assert.That(await sDatabase.GetServerBanAsync(1), Is.Not.Null);
// The list is still returned since that ignores pardons
Assert.That(await sDatabase.GetServerBansAsync(null, clientId), Has.Count.EqualTo(1));
Assert.That(await sDatabase.GetServerBansAsync(null, clientId, null), Has.Count.EqualTo(1));
});
}
}