only check api keys on selected resources

This commit is contained in:
Martin
2016-11-14 00:10:57 +01:00
parent c7fdb2684b
commit 8e28378cb8
7 changed files with 20 additions and 8 deletions
+1
View File
@@ -6,3 +6,4 @@ ESALES_URL = ''
TESTING = True
DEBUG = True
SQLALCHEMY_ECHO = False
API_KEYS = None # api keys are disabled in test
+9 -1
View File
@@ -5,6 +5,7 @@ import json
import base64
from api import create_app
from flask import Flask
from api.helpers import check_api_key
from api.validators import ValidationError, validate_exists, validate_number, validate_territory, validate_jsonschema
@@ -13,7 +14,14 @@ class TestHttpBasicAuth(flask_testing.TestCase):
api_key = 'secret'
def create_app(self):
return create_app('tests.config')
app = Flask(__name__)
app.before_request(check_api_key)
@app.route('/', methods=['GET'])
def index():
return 'ok'
return app
def _enable_basic_auth(self):
self.app.config['API_KEYS'] = [self.api_key]