コード例 #1
0
ファイル: test_auth.py プロジェクト: chrisboyd/lokole
 def setUp(self):
     self._folder = mkdtemp()
     self._storage = AzureObjectStorage(
         account=self._folder,
         key='key',
         container='auth',
         provider='LOCAL',
     )
     self._auth = AzureAuth(storage=self._storage, sudo_scope='sudo')
コード例 #2
0
def get_mailbox_storage() -> AzureObjectStorage:
    return AzureObjectStorage(
        account=config.BLOBS_ACCOUNT,
        key=config.BLOBS_KEY,
        host=config.BLOBS_HOST,
        secure=config.BLOBS_SECURE,
        container=constants.CONTAINER_MAILBOX,
        provider=config.STORAGE_PROVIDER,
    )
コード例 #3
0
 def setUp(self):
     self._folder = mkdtemp()
     self._container = 'container'
     mkdir(join(self._folder, self._container))
     self._storage = AzureObjectStorage(
         text_storage=AzureTextStorage(
             account=self._folder,
             key='unused',
             container=self._container,
             provider='LOCAL'))
コード例 #4
0
ファイル: azure.py プロジェクト: chrisboyd/lokole
def get_user_storage() -> AzureObjectStorage:
    return AzureObjectStorage(
        account=config.TABLES_ACCOUNT,
        key=config.TABLES_KEY,
        host=config.TABLES_HOST,
        secure=config.TABLES_SECURE,
        container=config.CONTAINER_USERS,
        provider=config.STORAGE_PROVIDER,
        case_sensitive=False,
    )
コード例 #5
0
ファイル: azure.py プロジェクト: chrisboyd/lokole
def get_auth() -> Auth:
    return AzureAuth(
        storage=AzureObjectStorage(
            account=config.TABLES_ACCOUNT,
            key=config.TABLES_KEY,
            host=config.TABLES_HOST,
            secure=config.TABLES_SECURE,
            container=config.CONTAINER_AUTH,
            provider=config.STORAGE_PROVIDER,
        ),
        sudo_scope=config.REGISTRATION_SUDO_TEAM,
    )
コード例 #6
0
    def given_storage(cls, lines=None):
        client_mock = MagicMock()
        storage = AzureObjectStorage(account='account',
                                     key='key',
                                     container='container',
                                     file_storage=client_mock)

        if lines:
            # noinspection PyUnusedLocal
            def compress_data(*args, **kwargs):
                with NamedTemporaryFile(mode='wb', delete=False) as fobj:
                    with GzipFile(fileobj=fobj, mode='wb') as gzip_fobj:
                        gzip_fobj.write(lines)
                return fobj.name

            client_mock.fetch_file.side_effect = compress_data

        return storage, client_mock
コード例 #7
0
from typing import Iterable

from opwen_email_server import azure_constants as constants
from opwen_email_server import config
from opwen_email_server.services.storage import AzureObjectStorage

STORAGE = AzureObjectStorage(account=config.CLIENT_STORAGE_ACCOUNT,
                             key=config.CLIENT_STORAGE_KEY,
                             container=constants.CONTAINER_CLIENT_PACKAGES)


def unpack_emails(resource_id: str) -> Iterable[dict]:
    return STORAGE.fetch_objects(resource_id)


def delete(resource_id: str):
    STORAGE.delete(resource_id)
コード例 #8
0
def get_email_storage() -> AzureObjectStorage:
    return AzureObjectStorage(
        text_storage=AzureTextStorage(account=config.BLOBS_ACCOUNT,
                                      key=config.BLOBS_KEY,
                                      container=constants.CONTAINER_EMAILS,
                                      provider=config.STORAGE_PROVIDER))
コード例 #9
0
#!/usr/bin/env python3

from argparse import ArgumentParser

from opwen_email_server import azure_constants as constants
from opwen_email_server import config
from opwen_email_server.services.auth import AzureAuth
from opwen_email_server.services.storage import AzureObjectStorage

parser = ArgumentParser()
parser.add_argument('--tables_account', default=config.TABLES_ACCOUNT)
parser.add_argument('--tables_key', default=config.TABLES_KEY)
parser.add_argument('--client_account', default=config.CLIENT_STORAGE_ACCOUNT)
parser.add_argument('--client_key', default=config.CLIENT_STORAGE_KEY)
parser.add_argument('--table', default=constants.TABLE_AUTH)
parser.add_argument('--container', default=constants.CONTAINER_CLIENT_PACKAGES)
parser.add_argument('--client', required=True)
parser.add_argument('--domain', required=True)
args = parser.parse_args()

auth = AzureAuth(account=args.tables_account,
                 key=args.tables_key,
                 table=args.table)
auth.insert(client_id=args.client, domain=args.domain)

# noinspection PyStatementEffect,PyProtectedMember
# hack to ensure that the container gets created before the client accesses it
storage = AzureObjectStorage(account=args.client_account,
                             key=args.client_key,
                             container=args.container)._file_storage._client