public void TestTextCommandRegister() { var textCommands = new TextCommandController(); ICommandResult result = textCommands.Tunnel(new Command() { Origin = CommandOrigin.Local, CommandType = CommandType.TextCommandsRegister, Parameters = new List<ICommandParameter>() { new CommandParameter() { Data = { TextCommands = new List<TextCommandModel>() { new TextCommandModel() { PluginGuid = Guid.NewGuid(), PluginCommand = "Command1", Commands = new List<String>() { "RegisterTest" } } } } } } }); Assert.IsTrue(result.Success); Assert.AreEqual(CommandResultType.Success, result.CommandResultType); Assert.AreEqual(1, textCommands.TextCommands.Count); Assert.AreEqual("RegisterTest", textCommands.TextCommands.First().Commands.First()); }
public void TestTextCommandParsingExecute() { var textCommands = new TextCommandController() { //Languages = languages, Connection = new ConnectionController() { Protocol = new SandboxProtocolController() { SandboxedProtocol = new MockProtocol() { Additional = "", Password = "" } } }.Execute() as ConnectionController }; textCommands.Execute(); textCommands.Tunnel(new Command() { Origin = CommandOrigin.Local, CommandType = CommandType.TextCommandsRegister, Parameters = new List<ICommandParameter>() { new CommandParameter() { Data = { TextCommands = new List<TextCommandModel>() { new TextCommandModel() { PluginGuid = Guid.NewGuid(), PluginCommand = "Command1", Commands = new List<String>() { "ExecuteTest" } } } } } } }); Assert.AreEqual(1, textCommands.TextCommands.Count); Assert.AreEqual("ExecuteTest", textCommands.TextCommands.First().Commands.First()); ICommandResult result = textCommands.Tunnel(new Command() { Origin = CommandOrigin.Local, CommandType = CommandType.TextCommandsExecute, Parameters = TestHelpers.ObjectListToContentList(new List<Object>() { "ExecuteTest stuff" }) }); Assert.IsTrue(result.Success); Assert.AreEqual(CommandResultType.Success, result.CommandResultType); }
public void TestTextCommandControllerDispose() { var textCommands = new TextCommandController(); var testCommand = new TextCommandModel() { Commands = new List<String>() { "DisposeTest" } }; textCommands.Tunnel(new Command() { Origin = CommandOrigin.Local, CommandType = CommandType.TextCommandsRegister, Parameters = TestHelpers.ObjectListToContentList(new List<Object>() { testCommand }) }); textCommands.Dispose(); Assert.IsNull(textCommands.TextCommands); Assert.IsNull(textCommands.Connection); }
public void TestTextCommandParsingExecuteInsufficientPermissions() { var textCommands = new TextCommandController() { Shared = { Security = new SecurityController().Execute() as SecurityController } }; ICommandResult result = textCommands.Tunnel(new Command() { Origin = CommandOrigin.Remote, Authentication = { Username = "******" }, CommandType = CommandType.TextCommandsExecute, Parameters = TestHelpers.ObjectListToContentList(new List<Object>() { "!test something something something dark side" }) }); Assert.IsFalse(result.Success); Assert.AreEqual(CommandResultType.InsufficientPermissions, result.CommandResultType); }
public void TestTextCommandParsingExecuteUsePreferredLanguage() { var security = (SecurityController)new SecurityController().Execute(); security.Tunnel(new Command() { Origin = CommandOrigin.Local, CommandType = CommandType.SecurityAddGroup, Parameters = TestHelpers.ObjectListToContentList(new List<Object>() { "TestGroup" }) }); security.Tunnel(new Command() { Origin = CommandOrigin.Local, CommandType = CommandType.SecurityGroupAddAccount, Parameters = TestHelpers.ObjectListToContentList(new List<Object>() { "TestGroup", "Phogue" }) }); security.Tunnel(new Command() { Origin = CommandOrigin.Local, CommandType = CommandType.SecurityAccountAddPlayer, Parameters = TestHelpers.ObjectListToContentList(new List<Object>() { "Phogue", CommonProtocolType.DiceBattlefield3, "EA_63A9F96745B22DFB509C558FC8B5C50F" }) }); security.Tunnel(new Command() { Origin = CommandOrigin.Local, CommandType = CommandType.SecurityAccountSetPreferredLanguageCode, Parameters = TestHelpers.ObjectListToContentList(new List<Object>() { "Phogue", "de-DE" }) }); security.Tunnel(new Command() { Origin = CommandOrigin.Local, CommandType = CommandType.SecurityGroupSetPermission, Parameters = TestHelpers.ObjectListToContentList(new List<Object>() { "TestGroup", CommandType.TextCommandsExecute, 100 }) }); var textCommands = new TextCommandController() { Shared = { Security = security }, //Languages = languages, Connection = new ConnectionController() { Protocol = new SandboxProtocolController() { SandboxedProtocol = new MockProtocol() { Additional = "", Password = "" } } }.Execute() as ConnectionController }; textCommands.Execute(); textCommands.Tunnel(new Command() { Origin = CommandOrigin.Local, CommandType = CommandType.TextCommandsRegister, Parameters = new List<ICommandParameter>() { new CommandParameter() { Data = { TextCommands = new List<TextCommandModel>() { new TextCommandModel() { PluginGuid = Guid.NewGuid(), PluginCommand = "Command1", Commands = new List<String>() { "ExecuteTest" } } } } } } }); Assert.AreEqual(1, textCommands.TextCommands.Count); Assert.AreEqual("ExecuteTest", textCommands.TextCommands.First().Commands.First()); ICommandResult result = textCommands.Tunnel(new Command() { Origin = CommandOrigin.Plugin, Authentication = { Username = "******" }, CommandType = CommandType.TextCommandsExecute, Parameters = TestHelpers.ObjectListToContentList(new List<Object>() { "ExecuteTest stuff" }) }); Assert.IsTrue(result.Success); Assert.AreEqual(CommandResultType.Success, result.CommandResultType); }
public void TestTextCommandRegisterDuplication() { var textCommands = new TextCommandController(); var guid = Guid.NewGuid(); textCommands.Tunnel(new Command() { Origin = CommandOrigin.Local, CommandType = CommandType.TextCommandsRegister, Parameters = new List<ICommandParameter>() { new CommandParameter() { Data = { TextCommands = new List<TextCommandModel>() { new TextCommandModel() { PluginGuid = guid, PluginCommand = "Command1", Commands = new List<String>() { "RegisterTest" } } } } } } }); ICommandResult result = textCommands.Tunnel(new Command() { Origin = CommandOrigin.Local, CommandType = CommandType.TextCommandsRegister, Parameters = new List<ICommandParameter>() { new CommandParameter() { Data = { TextCommands = new List<TextCommandModel>() { new TextCommandModel() { PluginGuid = guid, PluginCommand = "Command1", Commands = new List<String>() { "RegisterTest" } } } } } } }); Assert.IsFalse(result.Success); Assert.AreEqual(CommandResultType.AlreadyExists, result.CommandResultType); Assert.AreEqual(1, textCommands.TextCommands.Count); }
public void TestTextCommandUnregisterInsufficientPermission() { var textCommands = new TextCommandController(); var guid = Guid.NewGuid(); textCommands.Tunnel(new Command() { Origin = CommandOrigin.Local, CommandType = CommandType.TextCommandsRegister, Parameters = new List<ICommandParameter>() { new CommandParameter() { Data = { TextCommands = new List<TextCommandModel>() { new TextCommandModel() { PluginGuid = guid, PluginCommand = "Command1", Commands = new List<String>() { "RegisterTest" } } } } } } }); // Test that the initial command was entered before we attempt to remove it. Assert.AreEqual(1, textCommands.TextCommands.Count); Assert.AreEqual("RegisterTest", textCommands.TextCommands.First().Commands.First()); ICommandResult result = textCommands.Tunnel(new Command() { Authentication = { Username = "******" }, Origin = CommandOrigin.Remote, CommandType = CommandType.TextCommandsUnregister, Parameters = new List<ICommandParameter>() { new CommandParameter() { Data = { TextCommands = new List<TextCommandModel>() { new TextCommandModel() { PluginGuid = guid, PluginCommand = "Command1", Commands = new List<String>() { "RegisterTest" } } } } } } }); Assert.IsFalse(result.Success); Assert.AreEqual(CommandResultType.InsufficientPermissions, result.CommandResultType); }
public void TestTextCommandUnregisterDoesNotExist() { var textCommands = new TextCommandController(); ICommandResult result = textCommands.Tunnel(new Command() { Origin = CommandOrigin.Local, CommandType = CommandType.TextCommandsUnregister, Parameters = new List<ICommandParameter>() { new CommandParameter() { Data = { TextCommands = new List<TextCommandModel>() { new TextCommandModel() { PluginGuid = Guid.NewGuid(), PluginCommand = "Command1" } } } } } }); Assert.IsFalse(result.Success); Assert.AreEqual(CommandResultType.DoesNotExists, result.CommandResultType); }
public void TestTextCommandRegisterInsufficientPermission() { var textCommands = new TextCommandController(); ICommandResult result = textCommands.Tunnel(new Command() { Authentication = { Username = "******" }, Origin = CommandOrigin.Remote, CommandType = CommandType.TextCommandsRegister, Parameters = new List<ICommandParameter>() { new CommandParameter() { Data = { TextCommands = new List<TextCommandModel>() { new TextCommandModel() { PluginGuid = Guid.NewGuid(), PluginCommand = "Command1", Commands = new List<String>() { "RegisterTest" } } } } } } }); Assert.IsFalse(result.Success); Assert.AreEqual(CommandResultType.InsufficientPermissions, result.CommandResultType); }