예제 #1
0
        public async Task deleteExistingRulesOnStartup()
        {
            banManager.Dispose();

            firewallRules.Add(new FirewallWASRule("deleteme1", FirewallAction.Block, FirewallDirection.Inbound, FirewallProfiles.Public)
            {
                Grouping = "Fail2Ban4Win"
            });
            firewallRules.Add(new FirewallWASRule("deleteme2", FirewallAction.Block, FirewallDirection.Inbound, FirewallProfiles.Public)
            {
                Grouping = "Fail2Ban4Win"
            });

            Assert.NotEmpty(firewallRules);

            var manager = new BanManagerImpl(eventLogListener, configuration, firewallFacade);

            Assert.NotEmpty(firewallRules);

            //deletion runs asynchronously to speed up startup
            await Task.Delay(100);

            Assert.Empty(firewallRules);

            manager.Dispose();
        }
예제 #2
0
        public void dontBanInDryRunMode()
        {
            banManager.Dispose();

            configuration.isDryRun = true;

            var manager = new BanManagerImpl(eventLogListener, configuration, firewallFacade);

            for (int i = 0; i < MAX_ALLOWED_FAILURES + 1; i++)
            {
                eventLogListener.failure += Raise.With(null, SOURCE_ADDRESS);
            }

            Assert.Empty(firewallRules);

            manager.Dispose();
        }