Ejemplo n.º 1
0
    def test_update_csp(self):
        with self.settings(CSP_IMG_SRC=('https://f.c', 'self', 'http://f.c'),
                           DEBUG=False,
                           IN_TEST_SUITE=False):
            update_csp()
            self.assertSetEqual(set(settings.CSP_IMG_SRC),
                                set(('https://f.c', 'self')))

        with self.settings(CSP_IMG_SRC=('https://f.c', 'self', 'http://f.c'),
                           DEBUG=True):
            update_csp()
            self.assertSetEqual(set(settings.CSP_IMG_SRC),
                                set(('https://f.c', 'self', 'http://f.c')))
Ejemplo n.º 2
0
    def test_update_csp(self):
        with self.settings(CSP_SCRIPT_SRC=('https://f.c', 'self', 'http://f.c'),
                           DEBUG=False,
                           IN_TEST_SUITE=False):
            update_csp()
            self.assertSetEqual(set(settings.CSP_SCRIPT_SRC),
                                set(('https://f.c', 'self')))

        with self.settings(CSP_SCRIPT_SRC=('https://f.c', 'self', 'http://f.c'),
                           DEBUG=True):
            update_csp()
            self.assertSetEqual(set(settings.CSP_SCRIPT_SRC),
                                set(('https://f.c', 'self', 'http://f.c')))
Ejemplo n.º 3
0
    def test_secret_key(self):
        with self.settings(DEBUG=True,
                           IN_TEST_SUITE=False,
                           SECRET_KEY='please change this',
                           SITE_URL='http://testserver'):
            validate_settings()

        with self.settings(DEBUG=False,
                           IN_TEST_SUITE=False,
                           SECRET_KEY='please change this',
                           SITE_URL='http://testserver'):
            update_csp()
            with self.assertRaises(ImproperlyConfigured):
                validate_settings()

        with self.settings(DEBUG=False,
                           IN_TEST_SUITE=False,
                           SECRET_KEY='so changed',
                           SESSION_COOKIE_SECURE=True,
                           APP_PURCHASE_SECRET='so changed'):
            update_csp()
            validate_settings()
Ejemplo n.º 4
0
    def test_secret_key(self):
        with self.settings(DEBUG=True,
                           IN_TEST_SUITE=False,
                           SECRET_KEY='please change this',
                           SITE_URL='http://testserver'):
            validate_settings()

        with self.settings(DEBUG=False,
                           IN_TEST_SUITE=False,
                           SECRET_KEY='please change this',
                           SITE_URL='http://testserver'):
            update_csp()
            with self.assertRaises(ImproperlyConfigured):
                validate_settings()

        with self.settings(DEBUG=False,
                           IN_TEST_SUITE=False,
                           SECRET_KEY='so changed',
                           SESSION_COOKIE_SECURE=True,
                           APP_PURCHASE_SECRET='so changed'):
            update_csp()
            validate_settings()
Ejemplo n.º 5
0
    try:
        return mod(self, arg)
    except Exception:
        trans_log.error(unicode(self))
        return ''


Markup.__mod__ = new

import djcelery
djcelery.setup_loader()

# Import for side-effect: configures our logging handlers.
# pylint: disable-msg=W0611
from lib.utils import update_csp, validate_modules, validate_settings
update_csp()
validate_modules()
validate_settings()

import django.conf
newrelic_ini = getattr(django.conf.settings, 'NEWRELIC_INI', None)
load_newrelic = False

# Monkey patches DRF to not use fqdn urls.
from mkt.api.patch import patch
patch()

if newrelic_ini:
    import newrelic.agent
    try:
        newrelic.agent.initialize(newrelic_ini)
Ejemplo n.º 6
0
        return mod(self, arg)
    except Exception:
        trans_log.error(unicode(self))
        return ''

Markup.__mod__ = new

import djcelery
djcelery.setup_loader()

# Import for side-effect: configures our logging handlers.
# pylint: disable-msg=W0611
from lib.utils import update_csp, validate_settings
from lib.log_settings_base import log_configure
log_configure()
update_csp()
validate_settings()

import django.conf
newrelic_ini = getattr(django.conf.settings, 'NEWRELIC_INI', None)
load_newrelic = False

# Monkey patches DRF to not use fqdn urls.
from mkt.api.patch import patch
patch()

if newrelic_ini:
    import newrelic.agent
    try:
        newrelic.agent.initialize(newrelic_ini)
        load_newrelic = True