Exemplo n.º 1
0
 def create_app(self):
     """Called by flask_testing."""
     app = main.get_app()
     app.config.update(self.TEST_CONFIG)
     attachments.patch("test")
     main.setup_logging(app)
     return app
Exemplo n.º 2
0
 def create_app(self):
     """Called by flask_testing."""
     app = main.get_app()
     app.config.update(self.TEST_CONFIG)
     attachments.patch("test")
     main.setup_logging(app)
     return app
Exemplo n.º 3
0
 def setUp(self):
     """Re-setup the DB to ensure a fresh instance."""
     super(BaseTestCase, self).setUp()
     # Reset config on each call
     app = main.get_app()
     try:
         app.config = copy.deepcopy(self._SAVED_CONFIG)
     except AttributeError:
         self._SAVED_CONFIG = copy.deepcopy(app.config)
     models.db.init_app(app)
     models.db.create_all()
Exemplo n.º 4
0
 def setUp(self):
     """Re-setup the DB to ensure a fresh instance."""
     super(BaseTestCase, self).setUp()
     # Reset config on each call
     try:
         app = main.get_app()
         app.config = copy.deepcopy(self.app._SAVED_CONFIG)
     except AttributeError:
         self.app._SAVED_CONFIG = copy.deepcopy(app.config)
     models.db.init_app(app)
     models.db.create_all()
     cache.global_cache = cache.cache.NullCache()  # Reset cache
Exemplo n.º 5
0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""
This supports multiple auth systems as configured by the LOGIN_METHOD setting.

The required API includes:
    login_user(flask_request): returns User or None
    get_login_uri(): returns URI for login
    get_register_uri(): returns URI for registration
    logout(): returns None
    register(flask_request): register a new user
"""

from scoreboard import main

_login_method = main.get_app().config.get('LOGIN_METHOD')
if _login_method == 'local':
    from scoreboard.auth.local import *  # noqa: F401,F403
else:
    raise ImportError('Unhandled LOGIN_METHOD %s' % _login_method)
Exemplo n.º 6
0
import pytz
from sqlalchemy import exc

from scoreboard import attachments
from scoreboard import auth
from scoreboard import cache
from scoreboard import controllers
from scoreboard import context
from scoreboard import csrfutil
from scoreboard import errors
from scoreboard import main
from scoreboard import models
from scoreboard import utils
from scoreboard import validators

app = main.get_app()
api = flask_restful.Api(app)
context.ensure_setup()


# Custom fields
class ISO8601DateTime(fields.Raw):
    """Show datetimes as ISO8601."""

    def format(self, value):
        if value is None:
            return None
        if isinstance(value, (int, float)):
            value = datetime.fromtimestamp(value)
        if isinstance(value, (datetime.datetime, datetime.date)):
            if getattr(value, 'tzinfo', True) is None:
Exemplo n.º 7
0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import collections

import flask
from sqlalchemy import event

from scoreboard import main
from scoreboard import models
from scoreboard import utils

app = main.get_app()


DEFAULT_CSP_POLICY = {
        'default-src': ["'self'"],
        'script-src': [
            "'self'",
            "'unsafe-eval'",  # Needed for Charts.js
        ],
        'frame-ancestors': ["'none'"],
        'img-src': [
            "'self'",
            'data:',
        ],
        'object-src': ["'none'"],
        'reflected-xss': ['block'],
Exemplo n.º 8
0
 def setUp(self):
     """Re-setup the DB to ensure a fresh instance."""
     super(BaseTestCase, self).setUp()
     models.db.init_app(main.get_app())
     models.db.create_all()
Exemplo n.º 9
0
 def create_app(self):
     app = main.get_app()
     app.config.update(self.TEST_CONFIG)
     attachments.patch("test")
     main.setup_logging(app)
     return app
Exemplo n.º 10
0
 def setUp(self):
     """Re-setup the DB to ensure a fresh instance."""
     super(BaseTestCase, self).setUp()
     models.db.init_app(main.get_app())
     models.db.create_all()
Exemplo n.º 11
0
 def create_app(self):
     app = main.get_app()
     app.config.update(self.TEST_CONFIG)
     attachments.patch("test")
     main.setup_logging(app)
     return app