Esempio n. 1
0
    def test_config_from_env(self):
        """If an env var is set, then it is used as the config value"""

        # make env with random values
        fake_env = {}
        for kk in CONFIG_KEYS.keys():
            if kk == 'UAA_VERIFY_TLS':
                fake_env[kk] = random.choice([True, False])
            else:
                fake_env[kk] = ''.join(random.choice(string.ascii_uppercase) for _ in range(16))

        app = create_app(fake_env)
        # validate they all match
        for kk in CONFIG_KEYS.keys():
            assert app.config[kk] == fake_env[kk]
Esempio n. 2
0
    def test_config_from_env(self):
        """If an env var is set, then it is used as the config value"""

        # make env with random values
        fake_env = {}
        for kk in CONFIG_KEYS.keys():
            if kk == 'UAA_VERIFY_TLS':
                fake_env[kk] = random.choice([True, False])
            else:
                fake_env[kk] = ''.join(random.choice(string.ascii_uppercase) for _ in range(16))

        app = create_app(fake_env)
        # validate they all match
        for kk in CONFIG_KEYS.keys():
            assert app.config[kk] == fake_env[kk]
Esempio n. 3
0
    def test_config_from_env_default(self):
        """The default config is loaded if config key isn't present"""

        app = create_app({})
        for kk, vv in CONFIG_KEYS.items():
            assert app.config[kk] == vv
Esempio n. 4
0
import json
import random
import string
from posixpath import join as urljoin
import unittest

import redis
import flask
from flask import appcontext_pushed
from mock import Mock, patch
from requests.auth import HTTPBasicAuth

from uaaextras.webapp import create_app, send_email, str_to_bool, CONFIG_KEYS
from uaaextras.clients import UAAError, UAAClient

app = create_app({'UAA_CLIENT_ID': 'client-id', 'UAA_CLIENT_SECRET': 'client-secret'})


@contextmanager
def uaac_set(app, uaac=Mock()):
    """Shim in a mock object to flask.g"""
    def handler(sender, **kwargs):
        flask.g.uaac = uaac
    with appcontext_pushed.connected_to(handler, app):
        yield


class TestAppConfig(unittest.TestCase):
    def test_str_bool(self):
        """Strings are apprpriate converted to booleans"""
Esempio n. 5
0
from uaaextras.webapp import create_app

app = create_app()
Esempio n. 6
0
    def test_config_from_env_default(self):
        """The default config is loaded if config key isn't present"""

        app = create_app({})
        for kk, vv in CONFIG_KEYS.items():
            assert app.config[kk] == vv
Esempio n. 7
0
import string
from posixpath import join as urljoin
import unittest

import redis
import flask
from flask import appcontext_pushed
from mock import Mock, patch
from requests.auth import HTTPBasicAuth

import sqlalchemy

from uaaextras.webapp import create_app, send_email, str_to_bool, CONFIG_KEYS
from uaaextras.clients import UAAError, UAAClient, TOTPClient

app = create_app({"UAA_CLIENT_ID": "client-id", "UAA_CLIENT_SECRET": "client-secret"})


@contextmanager
def uaac_set(app, uaac=Mock()):
    """Shim in a mock object to flask.g"""

    def handler(sender, **kwargs):
        flask.g.uaac = uaac

    with appcontext_pushed.connected_to(handler, app):
        yield


class TestAppConfig(unittest.TestCase):
    def test_str_bool(self):
Esempio n. 8
0
from contextlib import contextmanager
import json
import random
import string
from posixpath import join as urljoin
import unittest

import flask
from flask import appcontext_pushed
from mock import Mock, patch
from requests.auth import HTTPBasicAuth

from uaaextras.webapp import create_app, send_email, str_to_bool, CONFIG_KEYS, do_expiring_pw_notifications
from uaaextras.clients import UAAError, UAAClient

app = create_app({'UAA_CLIENT_ID': 'client-id', 'UAA_CLIENT_SECRET': 'client-secret',
                  'PW_EXPIRES_DAYS': 30, 'PW_EXPIRATION_WARN_DAYS': 5})


@contextmanager
def uaac_set(app, uaac=Mock()):
    """Shim in a mock object to flask.g"""
    def handler(sender, **kwargs):
        flask.g.uaac = uaac
    with appcontext_pushed.connected_to(handler, app):
        yield


class TestAppConfig(unittest.TestCase):
    def test_str_bool(self):
        """Strings are apprpriate converted to booleans"""