Files
tbd-station-14/Content.IntegrationTests/Tests/Toolshed/AdminTest.cs
Pieter-Jan Briers fb35b52da5 Ignore non-content commands in AllCommandsHavePermissions (#39336)
Causing a test failure every time a Toolshed command gets added to engine is ridiculous.
2025-09-10 13:08:16 -07:00

39 lines
1.3 KiB
C#

using System.Collections.Generic;
using System.Reflection;
using Content.Server.Administration.Managers;
using Robust.Shared.Toolshed;
namespace Content.IntegrationTests.Tests.Toolshed;
[TestFixture]
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.Multiple(() =>
{
foreach (var cmd in toolMan.DefaultEnvironment.AllCommands())
{
if (ignored.Contains(cmd.Cmd.GetType().Assembly))
continue;
// Only care about content commands.
var assemblyName = cmd.Cmd.GetType().Assembly.FullName;
if (assemblyName == null || !assemblyName.StartsWith("Content."))
continue;
Assert.That(admin.TryGetCommandFlags(cmd, out _), $"Command does not have admin permissions set up: {cmd.FullName()}");
}
});
});
}
}