public void TestResultSuccess() { EventsController events = new EventsController(); ICommandResult result = events.Tunnel(CommandBuilder.EventsLog(new GenericEvent() { Name = "Nothing" }).SetOrigin(CommandOrigin.Local)); Assert.IsTrue(result.Success); Assert.AreEqual(CommandResultType.Success, result.CommandResultType); }
public void TestResultInsufficientPermissions() { EventsController events = new EventsController(); ICommandResult result = events.Tunnel(CommandBuilder.EventsLog(new GenericEvent() { Name = "Nothing" }).SetOrigin(CommandOrigin.Remote).SetAuthentication(new CommandAuthenticationModel() { Username = "******" })); Assert.IsFalse(result.Success); Assert.AreEqual(CommandResultType.InsufficientPermissions, result.CommandResultType); }
public void TestEventsAfterEventIdExcludingExpired() { var events = new EventsController(); events.Log(new GenericEvent() { Success = true, GenericEventType = GenericEventType.SecurityGroupAdded, Scope = new CommandData() { Accounts = new List<AccountModel>() { new AccountModel() { Username = "******" } } } }); events.Log(new GenericEvent() { Success = true, GenericEventType = GenericEventType.SecurityGroupAdded, Scope = new CommandData() { Accounts = new List<AccountModel>() { new AccountModel() { Username = "******" } } }, Stamp = DateTime.Now.AddHours(-1) }); ICommandResult result = events.Tunnel(new Command() { Origin = CommandOrigin.Local, CommandType = CommandType.EventsFetchAfterEventId, Parameters = TestHelpers.ObjectListToContentList(new List<Object>() { 0 }) }); Assert.IsTrue(result.Success); Assert.AreEqual(CommandResultType.Success, result.CommandResultType); Assert.AreEqual(1, result.Now.Events.Count); Assert.AreEqual("Phogue", result.Now.Events.First().Scope.Accounts.First().Username); }
public void TestEventsAfterEventIdInsufficientPermission() { var events = new EventsController(); events.Log(new GenericEvent() { Success = true, GenericEventType = GenericEventType.SecurityGroupAdded, Scope = new CommandData() { Accounts = new List<AccountModel>() { new AccountModel() { Username = "******" } } } }); ICommandResult result = events.Tunnel(new Command() { Authentication = { Username = "******" }, Origin = CommandOrigin.Remote, CommandType = CommandType.EventsFetchAfterEventId, Parameters = TestHelpers.ObjectListToContentList(new List<Object>() { 0 }) }); Assert.IsFalse(result.Success); Assert.AreEqual(CommandResultType.InsufficientPermissions, result.CommandResultType); }