Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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);
        }