Beispiel #1
0
def test_null_sender():
    d = {
        'sender': '',
        'sasl_username': tdata.user,
        'recipient': 'test' + tdata.user,
    }
    s = utils.set_smtp_session(**d)
    action = utils.send_policy(s)

    assert action == SMTP_ACTIONS['reject_null_sender']
def test_policy_subdomain():
    utils.add_domain()
    utils.add_user()
    utils.add_alias(policy=MAILLIST_POLICY_SUBDOMAIN)

    d = {
        'sender': tdata.ext_user,
        'recipient': tdata.alias,
    }
    s = utils.set_smtp_session(**d)
    action = utils.send_policy(s)

    assert action == SMTP_ACTIONS['reject_not_authorized']
def test_policy_public():
    utils.add_domain()
    utils.add_user()
    utils.add_alias(policy=MAILLIST_POLICY_PUBLIC)

    d = {
        'sender': tdata.ext_user,
        'recipient': tdata.alias,
    }
    s = utils.set_smtp_session(**d)
    action = utils.send_policy(s)

    assert action == SMTP_ACTIONS['default']
def test_policy_moderators_as_ext_user():
    utils.add_domain()
    utils.add_user()
    utils.add_alias(policy=MAILLIST_POLICY_MODERATORS)

    d = {
        'sender': tdata.ext_user,
        'recipient': tdata.alias,
    }

    s = utils.set_smtp_session(**d)
    action = utils.send_policy(s)

    assert action == SMTP_ACTIONS['reject_not_authorized']

    utils.assign_alias_moderator(moderator=tdata.ext_user)
    action = utils.send_policy(s)
    assert action == SMTP_ACTIONS['default']
def test_policy_membersonly_as_internal_user():
    utils.add_domain()
    utils.add_user()
    utils.add_alias(policy=MAILLIST_POLICY_MEMBERSONLY)

    d = {
        'sender': tdata.user,
        'recipient': tdata.alias,
    }

    s = utils.set_smtp_session(**d)
    action = utils.send_policy(s)

    assert action == SMTP_ACTIONS['reject_not_authorized']

    utils.assign_alias_member()
    action = utils.send_policy(s)
    assert action == SMTP_ACTIONS['default']
Beispiel #6
0
def test_whitelist_subdomain_match():
    utils.add_domain()
    utils.add_user()

    rdns = tdata.rdns_subdomain_name
    utils.add_wblist_rdns_whitelist(rdns=rdns)

    d = {
        'sender': tdata.ext_user,
        'recipient': tdata.user,
        'reverse_client_name': rdns,
    }
    s = utils.set_smtp_session(**d)
    action = utils.send_policy(s)

    assert action == SMTP_ACTIONS['default']

    utils.remove_wblist_rdns_whitelist(rdns=rdns)
Beispiel #7
0
def test_blacklist_exact_match():
    utils.add_domain()
    utils.add_user()

    rdns = tdata.rdns_exact_name
    utils.add_wblist_rdns_blacklist(rdns=rdns)

    d = {
        'sender': tdata.ext_user,
        'recipient': tdata.user,
        'reverse_client_name': rdns,
    }

    s = utils.set_smtp_session(**d)
    action = utils.send_policy(s)

    assert action == SMTP_ACTIONS['reject_blacklisted_rdns'] + ' (' + rdns + ')'

    utils.remove_wblist_rdns_blacklist(rdns=rdns)
def test_policy_membersandmoderators_as_internal_user():
    utils.add_domain()
    utils.add_user()
    utils.add_alias(policy=MAILLIST_POLICY_MEMBERSANDMODERATORSONLY)

    _user = tdata.user
    d = {
        'sender': _user,
        'recipient': tdata.alias,
    }

    s = utils.set_smtp_session(**d)
    action = utils.send_policy(s)

    # Not member or moderator
    assert action == SMTP_ACTIONS['reject_not_authorized']

    # is member
    utils.assign_alias_member(member=_user)
    action = utils.send_policy(s)
    assert action == SMTP_ACTIONS['default']

    # Not member or moderator
    utils.remove_alias_member(member=_user)
    action = utils.send_policy(s)
    assert action == SMTP_ACTIONS['reject_not_authorized']

    # is moderator
    utils.assign_alias_moderator(moderator=_user)
    action = utils.send_policy(s)
    assert action == SMTP_ACTIONS['default']

    # Not member or moderator
    utils.remove_alias_moderator(moderator=_user)
    action = utils.send_policy(s)
    assert action == SMTP_ACTIONS['reject_not_authorized']