Toolshed refactor (#33598)
* Content changes for engine toolshed PR * add contains command * more permissive commands
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Content.Server.Administration.Managers;
|
||||
using Robust.Shared.Toolshed;
|
||||
|
||||
namespace Content.IntegrationTests.Tests.Toolshed;
|
||||
@@ -10,10 +11,23 @@ public sealed class AdminTest : ToolshedTest
|
||||
[Test]
|
||||
public async Task AllCommandsHavePermissions()
|
||||
{
|
||||
var toolMan = Server.ResolveDependency<ToolshedManager>();
|
||||
var admin = Server.ResolveDependency<IAdminManager>();
|
||||
var ignored = new HashSet<Assembly>()
|
||||
{typeof(LocTest).Assembly, typeof(Robust.UnitTesting.Shared.Toolshed.LocTest).Assembly};
|
||||
|
||||
await Server.WaitAssertion(() =>
|
||||
{
|
||||
Assert.That(InvokeCommand("cmd:list where { acmd:perms isnull }", out var res));
|
||||
Assert.That((IEnumerable<CommandSpec>) res, Is.Empty, "All commands must have admin permissions set up.");
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
foreach (var cmd in toolMan.DefaultEnvironment.AllCommands())
|
||||
{
|
||||
if (ignored.Contains(cmd.Cmd.GetType().Assembly))
|
||||
continue;
|
||||
|
||||
Assert.That(admin.TryGetCommandFlags(cmd, out _), $"Command does not have admin permissions set up: {cmd.FullName()}");
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user