Exemplo n.º 1
0
def init(request):
    from mailur import local

    for i in range(len(request.session.items)):
        users.append(
            ['test1_%s' % uuid.uuid4().hex,
             'test2_%s' % uuid.uuid4().hex])

    users_str = ' '.join(sum(users, []))
    subprocess.call('''
    path=/home/vmail/test
    rm -rf $path
    mkdir -p $path
    chown vmail:vmail $path
    names="%s" home=$path append=1 bin/install-users
    systemctl restart dovecot
    ''' % users_str,
                    shell=True,
                    cwd=root)

    # try to connect to dovecot
    for i in range(5):
        try:
            username, pwd = local.master_login(username=users[0][0])
            local.connect(username, pwd)
            return
        except Exception as e:
            err = e
            time.sleep(1)
            print('Another try to connect to dovecot: %s' % err)
    raise err
Exemplo n.º 2
0
def gm_fake():
    from mailur import local

    def uid(name, *a, **kw):
        responces = getattr(gm_client, name.lower(), None)
        if responces:
            return responces.pop()
        return con._uid(name, *a, **kw)

    def xlist(*a, **kw):
        responces = getattr(gm_client, 'list', None)
        if responces:
            return responces.pop()
        return 'OK', [
            b'(\\HasNoChildren \\All) "/" mlr',
            b'(\\HasNoChildren \\Junk) "/" mlr/All',
            b'(\\HasNoChildren \\Trash) "/" mlr/All',
            b'(\\HasNoChildren \\Draft) "/" mlr/All',
        ]

    con = local.connect(*local.master_login(username=test2))

    con._uid = con.uid
    con.uid = uid
    con._list = con.list
    con.list = xlist
    return con
Exemplo n.º 3
0
def gm_fake():
    from mailur import local

    def uid(name, *a, **kw):
        responces = getattr(gm_client, name.lower(), None)
        if responces:
            return responces.pop()
        return gm_client._uid(name, *a, **kw)

    con = local.connect(test2)

    gm_client.con = con
    gm_client._uid = con.uid
    con.uid = uid
    return con
Exemplo n.º 4
0
def setup(new_users, gm_client, sendmail, patch_conf):
    from mailur import imap, local, remote

    global con_local, con_gmail

    con_local = local.client(None)
    con_gmail = local.connect(*local.master_login(username=test2))

    remote.data_account({
        'username': '******',
        'password': '******',
        'imap_host': 'imap.gmail.com',
        'smtp_host': 'smtp.gmail.com',
    })

    yield

    con_local.logout()
    con_gmail.logout()
    imap.clean_pool(test1)
    imap.clean_pool(test2)