Fully migrate API security tests into the pytest test suite
Also adds an additional test that ensures that at least one security test exists for every (api endpoint, http method) pair.
This commit is contained in:
parent
beebe6d5ed
commit
924dda296f
7 changed files with 1340 additions and 4493 deletions
|
@ -128,23 +128,23 @@ class DelegateUserfiles(object):
|
|||
|
||||
|
||||
class Userfiles(object):
|
||||
def __init__(self, app=None, distributed_storage=None):
|
||||
def __init__(self, app=None, distributed_storage=None, path='userfiles',
|
||||
handler_name='userfiles_handler'):
|
||||
self.app = app
|
||||
if app is not None:
|
||||
self.state = self.init_app(app, distributed_storage)
|
||||
self.state = self.init_app(app, distributed_storage, path=path, handler_name=handler_name)
|
||||
else:
|
||||
self.state = None
|
||||
|
||||
def init_app(self, app, distributed_storage):
|
||||
def init_app(self, app, distributed_storage, path='userfiles', handler_name='userfiles_handler'):
|
||||
location = app.config.get('USERFILES_LOCATION')
|
||||
path = app.config.get('USERFILES_PATH', None)
|
||||
userfiles_path = app.config.get('USERFILES_PATH', None)
|
||||
|
||||
if path is not None:
|
||||
handler_name = 'userfiles_handlers'
|
||||
userfiles = DelegateUserfiles(app, distributed_storage, location, path,
|
||||
if userfiles_path is not None:
|
||||
userfiles = DelegateUserfiles(app, distributed_storage, location, userfiles_path,
|
||||
handler_name=handler_name)
|
||||
|
||||
app.add_url_rule('/userfiles/<regex("[0-9a-zA-Z-]+"):file_id>',
|
||||
app.add_url_rule('/%s/<regex("[0-9a-zA-Z-]+"):file_id>' % path,
|
||||
view_func=UserfilesHandlers.as_view(handler_name,
|
||||
distributed_storage=distributed_storage,
|
||||
location=location,
|
||||
|
|
Reference in a new issue