def get_context(self):
        conf = Config()
        conf.STATSD_HOST = ''
        ctx = Context(config=conf)
        ctx.request = RequestParameters()

        return ctx
        def topic(self, callback):
            conf = Config()
            conf.define('TC_AWS_ALLOWED_BUCKETS', [], '')

            context = Context(config=conf)
            s3_loader.load(context, '/'.join([s3_bucket, IMAGE_PATH]),
                           callback)
Exemple #3
0
            def topic(self):
                os.environ['SOME_CONFIGURATION'] = "test value"
                config = Config()

                Config.allow_environment_variables()

                return config.SOME_CONFIGURATION
    def get_context(self):
        conf = Config()
        conf.STATSD_HOST = ''
        ctx = Context(config=conf)
        ctx.request = RequestParameters()
        ctx.request.filters.append('auto')

        return ctx
    def test_can_validate_buckets(self):
        conf = Config(
            TC_AWS_ALLOWED_BUCKETS=['whitelist_bucket'],
            TC_AWS_LOADER_BUCKET=None,
        )

        image = yield presigning_loader.load(Context(config=conf),
                                             '/'.join([s3_bucket, IMAGE_PATH]))
        self.assertIsNone(image)
    def test_should_use_http_loader(self, load_sync_patch):
        def cb(a, b, callback, *args, **kwargs):
            callback('foobar')
            return None

        load_sync_patch.side_effect = cb

        conf = Config(TC_AWS_ENABLE_HTTP_LOADER=True)
        presigning_loader.load(Context(config=conf), 'http://foo.bar')
        self.assertTrue(load_sync_patch.called)
Exemple #7
0
 def topic(self, callback):
     conf = Config(TC_AWS_ENDPOINT_URL='http://test.example.com:9000',
                   TC_AWS_CONFIG={
                       's3': {
                           'addressing_style': 'path'
                       },
                       'signature_version': 's3v4'
                   })
     context = Context(config=conf)
     presigning_loader._generate_presigned_url(context, "bucket-name",
                                               "some-s3-key", callback)
Exemple #8
0
        def topic(self):
            conn = boto.connect_s3()
            bucket = conn.create_bucket(s3_bucket)

            k = Key(bucket)
            k.key = IMAGE_PATH
            k.set_contents_from_string(IMAGE_BYTES)

            conf = Config()
            conf.define('TC_AWS_LOADER_BUCKET', s3_bucket, '')
            conf.define('TC_AWS_LOADER_ROOT_PATH', 'root_path', '')

            return Context(config=conf)
        def topic(self, callback):
            conn = boto.connect_s3()
            bucket = conn.create_bucket(s3_bucket)

            k = Key(bucket)
            k.key = '/'.join(['root_path', IMAGE_PATH])
            k.set_contents_from_string(IMAGE_BYTES)

            conf = Config()
            conf.define('TC_AWS_LOADER_BUCKET', s3_bucket, '')
            conf.define('TC_AWS_LOADER_ROOT_PATH', 'root_path', '')

            context = Context(config=conf)

            s3_loader.load(context, IMAGE_PATH, callback)
Exemple #10
0
    def test_can_load_image(self):
        client = botocore.session.get_session().create_client('s3')
        client.create_bucket(Bucket=s3_bucket)

        client.put_object(
            Bucket=s3_bucket,
            Key=''.join(['root_path', IMAGE_PATH]),
            Body=IMAGE_BYTES,
            ContentType='image/jpeg',
        )

        conf = Config(TC_AWS_LOADER_BUCKET=s3_bucket,
                      TC_AWS_LOADER_ROOT_PATH='root_path')

        image = yield s3_loader.load(Context(config=conf), IMAGE_PATH)
        self.assertEqual(image, IMAGE_BYTES)
    def test_can_build_presigned_url(self):
        context = Context(config=(Config()))
        url = yield presigning_loader._generate_presigned_url(
            context, "bucket-name", "some-s3-key")

        url = urlparse(url)
        self.assertEqual(url.scheme[0:4], 'http')
        self.assertEqual(url.path, '/bucket-name/some-s3-key')

        url_params = parse_qs(url.query)
        # We can't test Expires & Signature values as they vary depending on the TZ
        self.assertIn('Expires', url_params)
        self.assertIn('Signature', url_params)

        self.assertDictContainsSubset(
            {
                'AWSAccessKeyId': ['test-key'],
                'x-amz-security-token': ['test-session-token']
            }, url_params)
 def topic(self, callback):
     os.environ['AWS_SHARED_CREDENTIALS_FILE'] = ''
     conf = Config()
     context = Context(config=conf)
     presigning_loader._generate_presigned_url(context, "bucket-name",
                                               "some-s3-key", callback)
Exemple #13
0
 def topic(self, callback):
     conf = Config()
     context = Context(config=conf)
     presigning_loader._generate_presigned_url(context, "bucket-name",
                                               "some-s3-key", callback)
Exemple #14
0
        def topic(self):
            conf = Config()
            conf.define('TC_AWS_ALLOWED_BUCKETS', [], '')

            return Context(config=conf)
Exemple #15
0
 def topic(self):
     conf = Config()
     return Context(config=conf)
Exemple #16
0
 def topic(self):
     conf = Config()
     conf.TC_AWS_LOADER_BUCKET = None
     conf.TC_AWS_LOADER_ROOT_PATH = ''
     return Context(config=conf)
Exemple #17
0
 def topic(self):
     Config.alias('OTHER_ENGINE', 'ENGINE')
     return Config(OTHER_ENGINE='x')
Exemple #18
0
 def topic(self):
     Config.alias('LOADER_ALIAS', 'LOADER')
     return Config(LOADER='y')
Exemple #19
0
 def topic(self):
     conf = Config()
     conf.TC_AWS_LOADER_BUCKET = None
     conf.TC_AWS_LOADER_ROOT_PATH = ''
     context = Context(config=conf)
     return _get_key(IMAGE_PATH, context)
Exemple #20
0
 def test_should_not_use_http_loader_if_not_prefixed_with_scheme(
         self, load_sync_patch):
     conf = Config(TC_AWS_ENABLE_HTTP_LOADER=True)
     yield s3_loader.load(Context(config=conf), 'foo/bar')
     self.assertFalse(load_sync_patch.called)
        def topic(self):

            conf = Config()
            conf.define('TC_AWS_MAX_RETRIES', 3, '')
            return Context(config=conf)
    def get_context(self):
        conf = Config()
        conf.PNGCRUSH_PATH = self.pngcrush_path
        conf.STATSD_HOST = ''

        return Context(config=conf)
    def get_context(self):
        conf = Config()
        conf.OPTIPNG_PATH = self.optipng_path
        conf.STATSD_HOST = ''

        return Context(config=conf)
        def topic(self):
            conf = Config()
            conf.define('TC_AWS_ENABLE_HTTP_LOADER', True, '')

            return Context(config=conf)
Exemple #25
0
 def topic(self):
     Config.alias('STORAGE_ALIAS', 'STORAGE')
     Config.alias('STORAGE_ALIAS_ALIAS', 'STORAGE_ALIAS')
     return Config(STORAGE_ALIAS_ALIAS='z')
Exemple #26
0
from derpconf.config import Config


def INSTANCE(x):
    return os.path.join(os.path.dirname(__file__), x)


if 'test' in sys.argv:
    config_file = INSTANCE('tests.config')
else:
    config_file = INSTANCE('local.config')

if os.path.isfile(config_file):
    conf = Config.load(config_file)
else:
    conf = Config()

DEBUG = conf.get('DEBUG', True)

ADMINS = conf.get('ADMINS', ())

MANAGERS = ADMINS

DEAFAULT_DATABASE = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': INSTANCE('db.sqlite3'),
        'USER': '',
        'PASSWORD': '',
        'HOST': '',
        'PORT': '',
Exemple #27
0
 def topic(self):
     return Config()