Example #1
0
 def test_should_determine_file_from_resource_location_if_exists(self):
     expected_path = "{}/{}".format(VAAS_APP_RESOURCES_PATH, 'test.yaml')
     self.file_existence = {
         USER_HOME_PATH: False,
         expected_path: True
     }
     assert_equals(expected_path, YamlConfigLoader([VAAS_APP_RESOURCES_PATH]).determine_config_file('test.yaml'))
Example #2
0
 def test_should_not_determine_file_if_not_exists_in_any_location(self):
     resource_path = "{}/{}".format(VAAS_APP_RESOURCES_PATH, 'test.yaml')
     self.file_existence = {
         USER_HOME_PATH: False,
         resource_path: False
     }
     assert_equals(None, YamlConfigLoader([VAAS_APP_RESOURCES_PATH]).determine_config_file('test.yaml'))
Example #3
0
 def test_should_init_search_paths_with_user_and_resources_paths_if_user_path_exists(self):
     self.file_existence = {
         USER_HOME_PATH: True
     }
     directories = YamlConfigLoader([USER_HOME_PATH, VAAS_APP_RESOURCES_PATH]).config_directories
     assert_equals(2, len(directories))
     assert_equals([USER_HOME_PATH, VAAS_APP_RESOURCES_PATH], directories)
Example #4
0
 def test_should_determine_file_from_users_location_if_exists(self):
     expected_path = "{}/{}".format(USER_HOME_PATH, 'test.yaml')
     self.file_existence = {
         USER_HOME_PATH: True,
         expected_path: True
     }
     assert_equals(expected_path, YamlConfigLoader([USER_HOME_PATH]).determine_config_file('test.yaml'))
Example #5
0
    def test_should_return_config_tree(self):
        expected_tree = {'key1': 'value1', 'key2': 'value2'}
        self.file_existence = {
            USER_HOME_PATH: False,
            "{}/{}".format(VAAS_APP_RESOURCES_PATH, 'test.yaml'): True
        }

        assert_equals(expected_tree, YamlConfigLoader([VAAS_APP_RESOURCES_PATH]).get_config_tree('test.yaml'))
Example #6
0
# -*- coding: utf-8 -*-
from __future__ import unicode_literals, absolute_import

from .base import *

from vaas.configuration.loader import YamlConfigLoader

DEBUG = True
TEMPLATE_DEBUG = True

for key, value in YamlConfigLoader().get_config_tree(
        'pre_prod.yml').iteritems():
    globals()[key] = value

INSTALLED_APPS = INSTALLED_APPS + tuple(INSTALLED_PLUGINS)
MIDDLEWARE_CLASSES = MIDDLEWARE_CLASSES + tuple(MIDDLEWARE_PLUGINS)
Example #7
0
# -*- coding: utf-8 -*-
from __future__ import unicode_literals, absolute_import

from vaas.configuration.loader import YamlConfigLoader

ldap_config = YamlConfigLoader().get_config_tree('ldap.yml')

if ldap_config:
    for key, value in ldap_config.iteritems():
        globals()[key] = value

    import ldap
    from django_auth_ldap.config import LDAPSearch

    from vaas.external.ldap import MappedGroupOfNamesType

    AUTH_LDAP_GROUP_TYPE = MappedGroupOfNamesType(name_attr=AUTH_LDAP_GROUP_TYPE)
    AUTH_LDAP_USER_SEARCH_FILTER = AUTH_LDAP_USER_SEARCH_FILTER.format(AUTH_LDAP_USER_USERNAME_ATTR)
    AUTH_LDAP_USER_SEARCH = LDAPSearch(
        AUTH_LDAP_USER_SEARCH_BASE, ldap.SCOPE_SUBTREE, AUTH_LDAP_USER_SEARCH_FILTER
    )
    AUTH_LDAP_GROUP_SEARCH = LDAPSearch(
        AUTH_LDAP_GROUP_SEARCH[0], ldap.SCOPE_SUBTREE, AUTH_LDAP_GROUP_SEARCH[1]
    )
Example #8
0
import environ

from typing import Optional
from vaas.configuration.loader import YamlConfigLoader


env = environ.Env()


def serialize(value: any) -> str:
    if type(value) in (dict, list, tuple):
        return json.dumps(value)
    return str(value)


config_loader = YamlConfigLoader(['/configuration'])
if config_loader.determine_config_file('config.yaml'):
    # Here we create environments variables from configuration repository and ensure that we have uppercase naming
    os.environ.update({k.upper(): serialize(v) for k, v in config_loader.get_config_tree('config.yaml').items()})

BASE_DIR = os.path.dirname(os.path.dirname(__file__))
current_dir = os.path.abspath(os.path.dirname(__file__))

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = env.str('SECRET_KEY', default='notproductionsecret')

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = env.bool('DEBUG', default=False)
TEMPLATE_DEBUG = env.bool('TEMPLATE_DEBUG', default=False)

# SECURITY WARNING: don't run with debug turned on in production!
Example #9
0
# -*- coding: utf-8 -*-
from __future__ import unicode_literals, absolute_import

import os
from django.conf import global_settings
from vaas.configuration.loader import YamlConfigLoader

BASE_DIR = os.path.dirname(os.path.dirname(__file__))
current_dir = os.path.abspath(os.path.dirname(__file__))
config_loader = YamlConfigLoader()

if not config_loader.determine_config_file('db_config.yml'):
    raise EnvironmentError('Cannot find db_config file')

DATABASES = config_loader.get_config_tree('db_config.yml')

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'pwm_&@a%yd8+7mqf9=*l56+y!@sb7ab==g942j7++gnr9l2%*d'

# SECURITY WARNING: don't run with debug turned on in production!
ALLOWED_HOSTS = []

MESSAGE_STORAGE = 'django.contrib.messages.storage.session.SessionStorage'

# Application definition
INSTALLED_APPS = (
    'django_nose',
    'vaas.adminext',
    'django_admin_bootstrapped',
    'django.contrib.admin',
    'django.contrib.auth',
Example #10
0
# -*- coding: utf-8 -*-
from __future__ import unicode_literals, absolute_import

from .base import *

from vaas.configuration.loader import YamlConfigLoader

DEBUG = True
TEMPLATE_DEBUG = True

for key, value in YamlConfigLoader().get_config_tree('dev.yml').items():
    globals()[key] = value

INSTALLED_APPS = tuple(INSTALLED_PLUGINS) + INSTALLED_APPS
MIDDLEWARE_CLASSES = MIDDLEWARE_CLASSES + tuple(MIDDLEWARE_PLUGINS)
Example #11
0
# -*- coding: utf-8 -*-
from __future__ import unicode_literals, absolute_import

from .base import *
from vaas.configuration.loader import YamlConfigLoader

DEBUG = False
TEMPLATE_DEBUG = False
ALLOWED_HOSTS = ["*"]

# override some configurations
for key, value in YamlConfigLoader().get_config_tree('production.yml').items():
    globals()[key] = value

INSTALLED_APPS = tuple(INSTALLED_PLUGINS) + INSTALLED_APPS
MIDDLEWARE_CLASSES = MIDDLEWARE_CLASSES + tuple(MIDDLEWARE_PLUGINS)

SOCIAL_AUTH_REDIRECT_IS_HTTPS = True

from .oauth import *
Example #12
0
# -*- coding: utf-8 -*-
from __future__ import unicode_literals, absolute_import

import os
from django.conf import global_settings
from vaas.configuration.loader import YamlConfigLoader


BASE_DIR = os.path.dirname(os.path.dirname(__file__))
current_dir = os.path.abspath(os.path.dirname(__file__))
config_loader = YamlConfigLoader()

if not config_loader.determine_config_file('db_config.yml'):
    raise EnvironmentError('Cannot find db_config file')

DATABASES = config_loader.get_config_tree('db_config.yml')

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'pwm_&@a%yd8+7mqf9=*l56+y!@sb7ab==g942j7++gnr9l2%*d'

# SECURITY WARNING: don't run with debug turned on in production!
ALLOWED_HOSTS = []

MESSAGE_STORAGE = 'django.contrib.messages.storage.session.SessionStorage'

# Application definition
INSTALLED_APPS = (
    'django_nose',
    'vaas.adminext',
    'django_admin_bootstrapped',
    'django.contrib.admin',
Example #13
0
# -*- coding: utf-8 -*-
from __future__ import unicode_literals, absolute_import

from vaas.configuration.loader import YamlConfigLoader

oauth_config = YamlConfigLoader().get_config_tree('oauth.yml')
if oauth_config:
    for key, value in oauth_config.items():
        globals()[key] = value

    AUTHENTICATION_BACKENDS = tuple(AUTHENTICATION_BACKENDS)
    SOCIAL_AUTH_PIPELINE = tuple(SOCIAL_AUTH_PIPELINE)
Example #14
0
# -*- coding: utf-8 -*-
import os
from __future__ import unicode_literals, absolute_import

from vaas.configuration.loader import YamlConfigLoader
from vaas.settings.base import env, serialize

ldap_config = YamlConfigLoader(['/configuration']).get_config_tree('ldap.yaml')
if ldap_config:
    os.environ.update(
        {k.upper(): serialize(v)
         for k, v in ldap_config.items()})

    import ldap
    from django_auth_ldap.config import LDAPSearch

    from vaas.external.ldap_config import MappedGroupOfNamesType

    AUTH_LDAP_USER_ATTR_MAP = {
        "first_name": "givenName",
        "last_name": "sn",
        "email": "mail"
    }

    AUTH_LDAP_GROUP_SEARCH = env.json('AUTH_LDAP_GROUP_SEARCH',
                                      default=['', ''])

    AUTH_LDAP_GROUP_TYPE = MappedGroupOfNamesType(
        name_attr=env.str('AUTH_LDAP_GROUP_TYPE', default=''))
    AUTH_LDAP_USER_SEARCH_FILTER = env.str(
        'AUTH_LDAP_USER_SEARCH_FILTER', default='{}').format(