This repository has been archived on 2020-03-24. You can view files and clone it, but cannot push or open issues or pull requests.
quay/endpoints/test/test_anon_checked.py
2019-11-12 11:09:47 -05:00

27 lines
826 B
Python

import pytest
from app import app
from endpoints.v1 import v1_bp
from endpoints.v2 import v2_bp
from endpoints.verbs import verbs
@pytest.mark.parametrize('blueprint', [
v2_bp,
v1_bp,
verbs,
])
def test_verify_blueprint(blueprint):
class Checker(object):
def __init__(self):
self.first_registration = True
self.app = app
def add_url_rule(self, rule, endpoint, view_function, methods=None):
result = ('__anon_protected' in dir(view_function) or
'__anon_allowed' in dir(view_function))
error_message = ('Missing anonymous access protection decorator on function ' +
'%s under blueprint %s' % (endpoint, blueprint.name))
assert result, error_message
for deferred_function in blueprint.deferred_functions:
deferred_function(Checker())