Exemplo n.º 1
0
from ming.orm import session
from ming.utils import LazyProperty
import ew.jinja2_ew as ew

from allura.lib import helpers as h
from allura.lib.security import has_access, require_access
from allura import model
from allura.controllers import BaseController
from allura.lib.decorators import require_post, memoize
from allura.lib.utils import permanent_redirect, ConfigProxy
from allura import model as M
from allura.tasks import index_tasks

log = logging.getLogger(__name__)

config = ConfigProxy(common_suffix='forgemail.domain')


class ConfigOption(object):
    """Definition of a configuration option for an :class:`Application`.

    """
    def __init__(self,
                 name,
                 ming_type,
                 default,
                 label=None,
                 help_text=None,
                 validator=None,
                 extra_attrs=None):
        """Create a new ConfigOption."""
Exemplo n.º 2
0
from paste.deploy.converters import asbool, asint, aslist
from formencode import validators as fev
from tg import tmpl_context as c
from tg import app_globals as g

from allura.lib.utils import ConfigProxy
from allura.lib import exceptions as exc
from allura.lib import helpers as h
from six.moves import map

log = logging.getLogger(__name__)

RE_MESSAGE_ID = re.compile(r'<(?:[^>]*/)?([^>]*)>')
config = ConfigProxy(
    common_suffix='forgemail.domain',
    common_suffix_alt='forgemail.domain.alternates',
    return_path='forgemail.return_path',
)
EMAIL_VALIDATOR = fev.Email(not_empty=True)


def Header(text, *more_text):
    '''Helper to make sure we encode headers properly'''
    if isinstance(text, header.Header):
        return text
    # email.header.Header handles str vs unicode differently
    # see
    # http://docs.python.org/library/email.header.html#email.header.Header.append
    if not isinstance(text, six.text_type):
        raise TypeError('This must be unicode: %r' % text)
    head = header.Header(text)
from email.MIMEMultipart import MIMEMultipart
from email.MIMEText import MIMEText
from email import header

from nose.tools import raises, assert_equal
from ming.orm import ThreadLocalORMSession

from alluratest.controller import setup_basic_test, setup_global_objects
from allura.lib.utils import ConfigProxy

from allura.lib.mail_util import parse_address, parse_message, Header
from allura.lib.exceptions import AddressException
from allura.tests import decorators as td

config = ConfigProxy(
    common_suffix='forgemail.domain',
    return_path='forgemail.return_path')

class TestReactor(unittest.TestCase):

    def setUp(self):
        setup_basic_test()
        setup_global_objects()
        ThreadLocalORMSession.flush_all()
        ThreadLocalORMSession.close_all()

    @raises(AddressException)
    def test_parse_address_bad_domain(self):
        parse_address('*****@*****.**')

    @raises(AddressException)