Files

113 lines
3.8 KiB
C#
Raw Permalink Normal View History

2023-04-15 07:41:25 +12:00
using System.Linq;
using Content.IntegrationTests.Tests.Interaction;
using Content.Shared.Radio.Components;
using Content.Shared.Wires;
namespace Content.IntegrationTests.Tests.EncryptionKeys;
public sealed class RemoveEncryptionKeys : InteractionTest
{
[Test]
public async Task HeadsetKeys()
{
await SpawnTarget("ClothingHeadsetGrey");
var comp = Comp<EncryptionKeyHolderComponent>();
Assert.Multiple(() =>
{
Assert.That(comp.KeyContainer.ContainedEntities, Has.Count.EqualTo(1));
Assert.That(comp.DefaultChannel, Is.EqualTo("Common"));
Assert.That(comp.Channels, Has.Count.EqualTo(1));
Assert.That(comp.Channels.First(), Is.EqualTo("Common"));
});
2023-04-15 07:41:25 +12:00
// Remove the key
await Interact(Screw);
Assert.Multiple(() =>
{
Assert.That(comp.KeyContainer.ContainedEntities, Has.Count.EqualTo(0));
Assert.That(comp.DefaultChannel, Is.Null);
Assert.That(comp.Channels, Has.Count.EqualTo(0));
});
2023-04-15 07:41:25 +12:00
// Check that the key was ejected and not just deleted or something.
2023-04-15 07:41:25 +12:00
await AssertEntityLookup(("EncryptionKeyCommon", 1));
// Re-insert a key.
await Interact("EncryptionKeyCentCom");
Assert.Multiple(() =>
{
Assert.That(comp.KeyContainer.ContainedEntities, Has.Count.EqualTo(1));
Assert.That(comp.DefaultChannel, Is.EqualTo("CentCom"));
Assert.That(comp.Channels, Has.Count.EqualTo(1));
Assert.That(comp.Channels.First(), Is.EqualTo("CentCom"));
});
2023-04-15 07:41:25 +12:00
}
[Test]
public async Task CommsServerKeys()
{
await SpawnTarget("TelecomServerFilled");
var comp = Comp<EncryptionKeyHolderComponent>();
var panel = Comp<WiresPanelComponent>();
Assert.Multiple(() =>
{
Assert.That(comp.KeyContainer.ContainedEntities, Has.Count.GreaterThan(0));
Assert.That(comp.Channels, Has.Count.GreaterThan(0));
Assert.That(panel.Open, Is.False);
});
2023-04-15 07:41:25 +12:00
// cannot remove keys without opening panel
await Interact(Pry);
Assert.Multiple(() =>
{
Assert.That(comp.KeyContainer.ContainedEntities, Has.Count.GreaterThan(0));
Assert.That(comp.Channels, Has.Count.GreaterThan(0));
Assert.That(panel.Open, Is.False);
});
2023-04-15 07:41:25 +12:00
// Open panel
await Interact(Screw);
Assert.Multiple(() =>
{
Assert.That(panel.Open, Is.True);
2023-04-15 07:41:25 +12:00
// Keys are still here
Assert.That(comp.KeyContainer.ContainedEntities, Has.Count.GreaterThan(0));
Assert.That(comp.Channels, Has.Count.GreaterThan(0));
});
2023-04-15 07:41:25 +12:00
// Now remove the keys
await Interact(Pry);
Assert.Multiple(() =>
{
Assert.That(comp.KeyContainer.ContainedEntities, Has.Count.EqualTo(0));
Assert.That(comp.Channels, Has.Count.EqualTo(0));
});
2023-04-15 07:41:25 +12:00
// Reinsert a key
await Interact("EncryptionKeyCentCom");
Assert.Multiple(() =>
{
Assert.That(comp.KeyContainer.ContainedEntities, Has.Count.EqualTo(1));
Assert.That(comp.DefaultChannel, Is.EqualTo("CentCom"));
Assert.That(comp.Channels, Has.Count.EqualTo(1));
Assert.That(comp.Channels.First(), Is.EqualTo("CentCom"));
});
2023-04-15 07:41:25 +12:00
// Remove it again
await Interact(Pry);
Assert.Multiple(() =>
{
Assert.That(comp.KeyContainer.ContainedEntities, Has.Count.EqualTo(0));
Assert.That(comp.Channels, Has.Count.EqualTo(0));
});
2023-04-15 07:41:25 +12:00
// Prying again will start deconstructing the machine.
AssertPrototype("TelecomServerFilled");
await Interact(Pry);
AssertPrototype("MachineFrame");
}
}