mirror of
https://github.com/ziirish/burp-ui.git
synced 2026-05-21 06:45:24 -06:00
improve coverage
This commit is contained in:
parent
dca66c9ec8
commit
5edb2879f9
5 changed files with 110 additions and 6 deletions
|
|
@ -137,7 +137,7 @@ def init(conf=None, debug=False, logfile=None, gunicorn=True):
|
|||
|
||||
bui.setup(app.config['CFG'])
|
||||
|
||||
if gunicorn:
|
||||
if gunicorn: # pragma: no cover
|
||||
from werkzeug.contrib.fixers import ProxyFix
|
||||
app.wsgi_app = ProxyFix(app.wsgi_app)
|
||||
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ class ClientTree(Resource):
|
|||
if not server:
|
||||
server = self.parser.parse_args()['server']
|
||||
j = []
|
||||
if not name or not backup:
|
||||
if not name or not backup: # pargma: no cover
|
||||
return jsonify(results=j)
|
||||
root = self.parser.parse_args()['root']
|
||||
try:
|
||||
|
|
@ -89,7 +89,7 @@ class ClientTree(Resource):
|
|||
except BUIserverException as e:
|
||||
err = [[2, str(e)]]
|
||||
return jsonify(notif=err)
|
||||
return jsonify(results=j)
|
||||
return jsonify(results=j) # pargma: no cover
|
||||
|
||||
|
||||
@api.resource('/api/client-stats.json/<name>',
|
||||
|
|
|
|||
|
|
@ -110,12 +110,15 @@ VIRTUALENV=$(which virtualenv)
|
|||
echo "test python$VERSION"
|
||||
$VIRTUALENV -p $PYTHON py$VERSION
|
||||
source py${VERSION}/bin/activate
|
||||
pip install -r requirements.txt
|
||||
pip install -r test-requirements.txt
|
||||
|
||||
pip install --upgrade pip
|
||||
pip install --upgrade -r requirements.txt
|
||||
pip install --upgrade -r test-requirements.txt
|
||||
|
||||
mkdir -p /etc/burp
|
||||
cp burpui.sample.cfg /etc/burp/burpui.cfg
|
||||
nosetests --with-coverage --cover-package=burpui test/test_burpui.py
|
||||
ret=$?
|
||||
rm /etc/burp/burpui.cfg
|
||||
|
||||
echo "cleanup"
|
||||
deactivate
|
||||
|
|
|
|||
62
test/test7.cfg
Normal file
62
test/test7.cfg
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
[Global]
|
||||
# On which port is the application listening
|
||||
port: 5001
|
||||
# On which address is the application listening
|
||||
# '::' is the default for all IPv6
|
||||
bind: ::
|
||||
# enable SSL
|
||||
ssl: false
|
||||
# ssl cert
|
||||
sslcert: /etc/burp/ssl_cert-server.pem
|
||||
# ssl key
|
||||
sslkey: /etc/burp/ssl_cert-server.key
|
||||
# burp server version (currently only burp 1.x is implemented)
|
||||
version: 1
|
||||
# Handle multiple bui-servers or not
|
||||
# If set to 'false', you will need to declare at least one 'Agent' section (see
|
||||
# bellow)
|
||||
standalone: false
|
||||
# authentication plugin (mandatory)
|
||||
# list the misc/auth directory to see the available backends
|
||||
# to disable authentication you can set "auth: none"
|
||||
auth: basic
|
||||
# acl plugin
|
||||
# list misc/auth directory to see the available backends
|
||||
# default is no ACL
|
||||
acl: basic
|
||||
|
||||
[UI]
|
||||
# refresh interval of the pages in seconds
|
||||
refresh: 15
|
||||
|
||||
# burp1 backend specific options
|
||||
[Burp1]
|
||||
# burp status address (can only be '127.0.0.1' or '::1'
|
||||
bhost: 127.0.0.1
|
||||
# burp status port
|
||||
bport: 9999
|
||||
# burp binary
|
||||
burpbin: this-file-should-not-exist
|
||||
# vss_strip binary
|
||||
stripbin: this-file-should-not-exist
|
||||
# temporary dir for the on the fly restoration
|
||||
tmpdir: this-file-should-not-exist
|
||||
# burp client configuration file used for the restoration (Default: None)
|
||||
bconfcli: this-file-should-not-exist
|
||||
# burp server configuration file used for the setting page
|
||||
bconfsrv: this-file-should-not-exist
|
||||
|
||||
[BASIC]
|
||||
admin: admin
|
||||
user1: password
|
||||
toto: toto
|
||||
|
||||
[BASIC:ACL]
|
||||
user1: ["client1", "client2"]
|
||||
user2: {"agent1": ["client3"]}
|
||||
|
||||
[Agent:dummy]
|
||||
host: 127.0.0.1
|
||||
port: 10000
|
||||
password: password
|
||||
ssl: false
|
||||
|
|
@ -298,5 +298,44 @@ class BurpuiTestInit(TestCase):
|
|||
self.assertRaises(IOError, BUIinit, 'thisfileisnotlikelytoexist', False, self.tmpFile, False)
|
||||
|
||||
|
||||
class BurpuiAPILoginTestCase(TestCase):
|
||||
|
||||
def setUp(self):
|
||||
print ('\nBegin Test 7\n')
|
||||
|
||||
def tearDown(self):
|
||||
print ('\nTest 7 Finished!\n')
|
||||
|
||||
def login(self, username, password):
|
||||
return self.client.post(url_for('view.login'), data=dict(
|
||||
username=username,
|
||||
password=password
|
||||
), follow_redirects=True)
|
||||
|
||||
def create_app(self):
|
||||
conf = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'test7.cfg')
|
||||
app.config['TESTING'] = True
|
||||
app.config['LOGIN_DISABLED'] = True
|
||||
app.config['CFG'] = conf
|
||||
bui.setup(conf)
|
||||
login_manager.init_app(app)
|
||||
return app
|
||||
|
||||
def test_server_config_parsing(self):
|
||||
rv = self.login('toto', 'toto')
|
||||
response = self.client.get(url_for('api.server_settings', server='dummy'))
|
||||
self.assertEquals(response.json, {u'message': u'Sorry, you don\'t have rights to access the setting panel'})
|
||||
|
||||
def test_client_config_parsing(self):
|
||||
rv = self.login('toto', 'toto')
|
||||
response = self.client.get(url_for('api.client_settings', client='toto', server='dummy'))
|
||||
self.assertEquals(response.json, {u'message': u'Sorry, you don\'t have rights to access the setting panel'})
|
||||
|
||||
def test_restore(self):
|
||||
rv = self.login('toto', 'toto')
|
||||
response = self.client.post(url_for('api.restore', name='dummy', backup=1, server='dummy'), data=dict(strip=False))
|
||||
self.assert500(response)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue