Skip to content

Commit

Permalink
Merge pull request #369 from mrannanj/warmup
Browse files Browse the repository at this point in the history
Warmup
  • Loading branch information
neilcook authored May 18, 2022
2 parents 0ee38ef + a9697d9 commit 9f9ed12
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 2 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
Weakforced
----------
[![Build Status](https://travis-ci.org/PowerDNS/weakforced.svg?branch=master)](https://travis-ci.org/PowerDNS/weakforced)

The goal of 'wforce' is to detect brute forcing of passwords across many
servers, services and instances. In order to support the real world, brute
Expand Down
15 changes: 14 additions & 1 deletion regression-tests/test_Basics.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,22 @@ def test_auth_stats(self):
self.assertEquals(r.status_code, requests.codes.ok)

def test_ping(self):
for _ in range(10):
r = self.pingFunc()
j = r.json()
if j['status'] == 'ok':
break
time.sleep(1)
self.assertEquals(j['status'], 'ok')

def test_ping_acl_deny(self):
self.writeCmdToConsole('setACL({})')
r = self.pingFunc()
self.assertEquals(r.status_code, 401)
j = r.json()
self.assertEquals(j['status'], 'ok')
self.assertEquals(j['status'], 'failure')
self.assertEquals(j['reason'], 'Source IP Address not in ACL')
self.writeCmdToConsole('setACL({"0.0.0.0/0"})')

def test_getBL(self):
r = self.getBLFunc()
Expand Down
53 changes: 53 additions & 0 deletions regression-tests/test_LogLevel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import subprocess
import time
from test_helper import ApiTestCase

ERROR = 3
WARNING = 4
INFO = 6
DEBUG = 7


class TestBasics(ApiTestCase):

def check_loglevel(self, loglevel, content):
cmd = ('../wforce/wforce -v -D -C ./wforce3.conf -R '
'../wforce/regexes.yaml --loglevel %d' % loglevel).split()
try:
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE)
self.generate_log_entries()
finally:
proc.terminate()
proc.wait()
out, err = proc.communicate()
if out:
out = out.decode()
if err:
err = err.decode()
assert content in out, out

def trigger_log_entry(self, cmd):
for i in range(20):
out = self.writeCmdToConsole3(cmd).decode()
if "Connection refused" not in out:
break
time.sleep(1)
assert "Connection refused" not in out

def generate_log_entries(self):
self.trigger_log_entry('debugLog("Debug Test", {})')
self.trigger_log_entry('infoLog("Info Test", {})')
self.trigger_log_entry('warnLog("Warning Test", {})')
self.trigger_log_entry('errorLog("Error Test", {})')

def test_debug(self):
self.check_loglevel(DEBUG, "Debug Test")

def test_info(self):
self.check_loglevel(INFO, "Info Test")

def test_warning(self):
self.check_loglevel(WARNING, "Warning Test")

def test_error(self):
self.check_loglevel(ERROR, "Error Test")

0 comments on commit 9f9ed12

Please sign in to comment.