コード例 #1
0
ファイル: actions.py プロジェクト: chrisboyd/lokole
    def _action(self, client, user, **auth_args):  # type: ignore
        domain = client['domain']
        if not is_lowercase(domain):
            return 'domain must be lowercase', 400
        if self._auth.client_id_for(domain) is not None:
            return 'client already exists', 409

        self._task(domain, user)

        self.log_event(events.CLIENT_CREATED, {'domain': domain})  # noqa: E501  # yapf: disable
        return 'accepted', 201
コード例 #2
0
ファイル: actions.py プロジェクト: chrisboyd/lokole
    def _action(self, domain, user, **auth_args):  # type: ignore
        if not is_lowercase(domain):
            return 'domain must be lowercase', 400

        client_id = self._auth.client_id_for(domain)
        if client_id is None:
            return 'client does not exist', 404

        if not self._auth.is_owner(domain, user):
            return 'client does not belong to the user', 403

        self._delete_mailbox(client_id, domain)
        self._delete_mx_records(domain)
        self._delete_index(self._pending_storage, domain)
        self._delete_index(self._mailbox_storage, domain)
        self._delete_index(self._user_storage, domain)
        self._auth.delete(client_id, domain)

        self.log_event(events.CLIENT_DELETED, {'domain': domain})  # noqa: E501  # yapf: disable
        return 'OK', 200
コード例 #3
0
ファイル: actions.py プロジェクト: chrisboyd/lokole
    def _action(self, domain, user, **auth_args):  # type: ignore
        if not is_lowercase(domain):
            return 'domain must be lowercase', 400

        client_id = self._auth.client_id_for(domain)
        if client_id is None:
            return 'client does not exist', 404

        if not self._auth.is_owner(domain, user):
            return 'client does not belong to the user', 403

        access_info = self._client_storage.access_info()

        self.log_event(events.CLIENT_FETCHED, {'domain': domain})  # noqa: E501  # yapf: disable
        return {
            'client_id': client_id,
            'storage_account': access_info.account,
            'storage_key': access_info.key,
            'resource_container': access_info.container,
        }
コード例 #4
0
    def _action(self, client, **auth_args):  # type: ignore
        domain = client['domain']
        if not is_lowercase(domain):
            return 'domain must be lowercase', 400
        if self._auth.client_id_for(domain) is not None:
            return 'client already exists', 409

        client_id = self._client_id_source()
        access_info = self._client_storage.access_info()

        self._setup_mailbox(client_id, domain)
        self._setup_mx_records(domain)
        self._client_storage.ensure_exists()
        self._auth.insert(client_id, domain)

        self.log_event(events.NEW_CLIENT_REGISTERED, {'domain': domain})  # noqa: E501  # yapf: disable
        return {
            'client_id': client_id,
            'storage_account': access_info.account,
            'storage_key': access_info.key,
            'resource_container': access_info.container,
        }
コード例 #5
0
ファイル: test_string.py プロジェクト: chrisboyd/lokole
 def test_lowercase(self):
     self.assertTrue(is_lowercase('foo'))
コード例 #6
0
ファイル: test_string.py プロジェクト: chrisboyd/lokole
 def test_uppercase(self):
     self.assertFalse(is_lowercase('FoO'))