예제 #1
0
파일: test_create.py 프로젝트: makyo/weasyl
def test_create_fails_if_email_is_invalid():
    form = Bag(username=user_name, password='******', passcheck='0123456789',
               email=';--', emailcheck=';--',
               day='12', month='12', year=arrow.now().year - 19)
    with pytest.raises(WeasylError) as err:
        login.create(form)
    assert 'emailInvalid' == err.value.value
예제 #2
0
def test_create_fails_if_pending_account_has_same_email():
    """
    Test checks to see if an email is tied to a pending account creation entry
    in logincreate. If so, login.create() will not permit another account to be
    made for the same address.
    """
    d.engine.execute(
        d.meta.tables["logincreate"].insert(), {
            "token": 40 * "a",
            "username": "******",
            "login_name": "existing",
            "hashpass": login.passhash(raw_password),
            "email": email_addr,
            "birthday": arrow.Arrow(2000, 1, 1),
            "unixtime": arrow.now(),
        })
    form = Bag(username="******",
               password='******',
               passcheck='0123456789',
               email=email_addr,
               emailcheck=email_addr,
               day='12',
               month='12',
               year=arrow.now().year - 19)
    with pytest.raises(WeasylError) as err:
        login.create(form)
    assert 'emailExists' == err.value.value
예제 #3
0
def test_create_fails_if_pending_account_has_same_email():
    """
    Test checks to see if an email is tied to a pending account creation entry
    in logincreate. If so, login.create() will not permit another account to be
    made for the same address.
    """
    d.engine.execute(
        d.meta.tables["logincreate"].insert(), {
            "token": 40 * "a",
            "username": "******",
            "login_name": "existing",
            "hashpass": login.passhash(raw_password),
            "email": email_addr,
            "birthday": arrow.Arrow(2000, 1, 1),
            "unixtime": arrow.now(),
        })
    form = Bag(username="******",
               password='******',
               passcheck='0123456789',
               email=email_addr,
               emailcheck=email_addr,
               day='12',
               month='12',
               year=arrow.now().year - 19)
    login.create(form)
    query = d.engine.scalar("""
        SELECT username FROM logincreate WHERE username = %(username)s AND invalid IS TRUE
    """,
                            username=form.username)
    assert query == "test"
예제 #4
0
    def POST(self):
        form = web.input(
            username="",
            password="",
            passcheck="",
            email="",
            emailcheck="",
            day="",
            month="",
            year="",
            recaptcha_challenge_field="",
            g_recaptcha_response=web.input("g-recaptcha-response"))

        if not define.captcha_verify(form):
            return define.errorpage(
                self.user_id,
                "There was an error validating the CAPTCHA response; you should go back and try again."
            )

        login.create(form)
        return define.errorpage(
            self.user_id, "**Success!** Your username has been reserved and a "
            "message has been sent to the email address you specified with "
            "information on how to complete the registration process. You "
            "should receive this email within the next hour.",
            [["Return to the Home Page", "/index"]])
예제 #5
0
def signup_post_(request):
    form = request.web_input(username="",
                             password="",
                             passcheck="",
                             email="",
                             emailcheck="",
                             day="",
                             month="",
                             year="")

    if 'g-recaptcha-response' not in form or not define.captcha_verify(
            form['g-recaptcha-response']):
        return Response(
            define.errorpage(
                request.userid,
                "There was an error validating the CAPTCHA response; you should go back and try again."
            ))

    login.create(form)
    return Response(
        define.errorpage(
            request.userid,
            "**Success!** Your username has been reserved and a message "
            "has been sent to the email address you provided with "
            "information on how to complete the registration process. You "
            "should receive this email within the next hour.",
            [["Return to the Home Page", "/"]]))
예제 #6
0
파일: test_create.py 프로젝트: makyo/weasyl
def test_create_fails_if_email_and_emailcheck_dont_match():
    form = Bag(username=user_name, password='******', passcheck='0123456789',
               email='*****@*****.**', emailcheck='*****@*****.**',
               day='12', month='12', year=arrow.now().year - 19)
    with pytest.raises(WeasylError) as err:
        login.create(form)
    assert 'emailMismatch' == err.value.value
예제 #7
0
파일: test_create.py 프로젝트: makyo/weasyl
def test_under_13_age_raises_birthdayInvalid_WeasylError():
    # Check for failure state if computed birthday is <13 years old
    form = Bag(username=user_name, password='', passcheck='',
               email='*****@*****.**', emailcheck='*****@*****.**',
               day='12', month='12', year=arrow.now().year - 11)
    with pytest.raises(WeasylError) as err:
        login.create(form)
    assert 'birthdayInvalid' == err.value.value
예제 #8
0
파일: test_create.py 프로젝트: makyo/weasyl
def test_passwords_must_match():
    # Check for failure if password != passcheck
    form = Bag(username=user_name, password='******', passcheck='qwe',
               email='*****@*****.**', emailcheck='*****@*****.**',
               day='12', month='12', year=arrow.now().year - 19)
    with pytest.raises(WeasylError) as err:
        login.create(form)
    assert 'passwordMismatch' == err.value.value
예제 #9
0
파일: test_create.py 프로젝트: makyo/weasyl
def test_usernames_must_be_unique():
    db_utils.create_user(username=user_name, email_addr="*****@*****.**")
    form = Bag(username=user_name, password='******', passcheck='0123456789',
               email=email_addr, emailcheck=email_addr,
               day='12', month='12', year=arrow.now().year - 19)
    with pytest.raises(WeasylError) as err:
        login.create(form)
    assert 'usernameExists' == err.value.value
예제 #10
0
파일: test_create.py 프로젝트: makyo/weasyl
def test_username_cannot_match_an_active_alias():
    user_id = db_utils.create_user(username='******')
    d.engine.execute("INSERT INTO useralias VALUES (%(userid)s, %(username)s, 'p')", userid=user_id, username=user_name)
    form = Bag(username=user_name, password='******', passcheck='0123456789',
               email=email_addr, emailcheck=email_addr,
               day='12', month='12', year=arrow.now().year - 19)
    with pytest.raises(WeasylError) as err:
        login.create(form)
    assert 'usernameExists' == err.value.value
예제 #11
0
파일: test_create.py 프로젝트: makyo/weasyl
def test_verify_correct_information_creates_account():
    form = Bag(username=user_name, password='******', passcheck='0123456789',
               email=email_addr, emailcheck=email_addr,
               day='12', month='12', year=arrow.now().year - 19)
    login.create(form)
    # This record should exist when this function completes successfully
    assert d.engine.scalar(
        "SELECT EXISTS (SELECT 0 FROM logincreate WHERE login_name = %(name)s)",
        name=form.username)
예제 #12
0
파일: test_create.py 프로젝트: makyo/weasyl
def test_create_fails_if_username_is_a_prohibited_name():
    form = Bag(username='******', password='******', passcheck='0123456789',
               email='*****@*****.**', emailcheck='*****@*****.**',
               day='12', month='12', year=arrow.now().year - 19)
    prohibited_names = ["admin", "administrator", "mod", "moderator", "weasyl",
                        "weasyladmin", "weasylmod", "staff", "security"]
    for name in prohibited_names:
        form.username = name
        with pytest.raises(WeasylError) as err:
            login.create(form)
        assert 'usernameInvalid' == err.value.value
예제 #13
0
파일: test_create.py 프로젝트: makyo/weasyl
def test_username_cant_be_blank_or_have_semicolon():
    form = Bag(username='******', password='******', passcheck='0123456789',
               email=email_addr, emailcheck=email_addr,
               day='12', month='12', year=arrow.now().year - 19)
    with pytest.raises(WeasylError) as err:
        login.create(form)
    assert 'usernameInvalid' == err.value.value
    form.username = '******'
    with pytest.raises(WeasylError) as err:
        login.create(form)
    assert 'usernameInvalid' == err.value.value
예제 #14
0
def test_create_fails_if_email_is_invalid():
    form = Bag(username=user_name,
               password='******',
               passcheck='0123456789',
               email=';--',
               emailcheck=';--',
               day='12',
               month='12',
               year=arrow.now().year - 19)
    with pytest.raises(WeasylError) as err:
        login.create(form)
    assert 'emailInvalid' == err.value.value
예제 #15
0
def test_create_fails_if_email_and_emailcheck_dont_match():
    form = Bag(username=user_name,
               password='******',
               passcheck='0123456789',
               email='*****@*****.**',
               emailcheck='*****@*****.**',
               day='12',
               month='12',
               year=arrow.now().year - 19)
    with pytest.raises(WeasylError) as err:
        login.create(form)
    assert 'emailMismatch' == err.value.value
예제 #16
0
def test_under_13_age_raises_birthdayInvalid_WeasylError():
    # Check for failure state if computed birthday is <13 years old
    form = Bag(username=user_name,
               password='',
               passcheck='',
               email='*****@*****.**',
               emailcheck='*****@*****.**',
               day='12',
               month='12',
               year=arrow.now().year - 11)
    with pytest.raises(WeasylError) as err:
        login.create(form)
    assert 'birthdayInvalid' == err.value.value
예제 #17
0
파일: test_create.py 프로젝트: makyo/weasyl
def test_create_fails_if_another_account_has_email_linked_to_their_account():
    """
    Test checks to see if an email is tied to an active user account. If so,
    login.create() will not permit another account to be made for the same
    address.
    """
    db_utils.create_user(username=user_name, email_addr=email_addr)
    form = Bag(username=user_name, password='******', passcheck='0123456789',
               email=email_addr, emailcheck=email_addr,
               day='12', month='12', year=arrow.now().year - 19)
    with pytest.raises(WeasylError) as err:
        login.create(form)
    assert 'emailExists' == err.value.value
예제 #18
0
def test_usernames_must_be_unique():
    db_utils.create_user(username=user_name, email_addr="*****@*****.**")
    form = Bag(username=user_name,
               password='******',
               passcheck='0123456789',
               email=email_addr,
               emailcheck=email_addr,
               day='12',
               month='12',
               year=arrow.now().year - 19)
    with pytest.raises(WeasylError) as err:
        login.create(form)
    assert 'usernameExists' == err.value.value
예제 #19
0
def signup_post_(request):
    form = request.web_input(
        username="", password="", passcheck="", email="", emailcheck="",
        day="", month="", year="")

    login.create(form)
    return Response(define.errorpage(
        request.userid,
        "**Success!** Your username has been reserved and a message "
        "has been sent to the email address you provided with "
        "information on how to complete the registration process. You "
        "should receive this email within the next hour.",
        [["Return to the Home Page", "/"]]))
예제 #20
0
def test_passwords_must_match():
    # Check for failure if password != passcheck
    form = Bag(username=user_name,
               password='******',
               passcheck='qwe',
               email='*****@*****.**',
               emailcheck='*****@*****.**',
               day='12',
               month='12',
               year=arrow.now().year - 19)
    with pytest.raises(WeasylError) as err:
        login.create(form)
    assert 'passwordMismatch' == err.value.value
예제 #21
0
def test_verify_correct_information_creates_account():
    form = Bag(username=user_name,
               password='******',
               passcheck='0123456789',
               email=email_addr,
               emailcheck=email_addr,
               day='12',
               month='12',
               year=arrow.now().year - 19)
    login.create(form)
    # This record should exist when this function completes successfully
    assert d.engine.scalar(
        "SELECT EXISTS (SELECT 0 FROM logincreate WHERE login_name = %(name)s)",
        name=form.username)
예제 #22
0
def test_create_fails_if_another_account_has_email_linked_to_their_account():
    """
    Test checks to see if an email is tied to an active user account. If so,
    login.create() will not permit another account to be made for the same
    address.
    """
    db_utils.create_user(username=user_name, email_addr=email_addr)
    form = Bag(username="******", password='******', passcheck='0123456789',
               email=email_addr, emailcheck=email_addr,
               day='12', month='12', year=arrow.now().year - 19)
    login.create(form)
    query = d.engine.scalar("""
        SELECT username FROM logincreate WHERE username = %(username)s AND invalid IS TRUE
    """, username=form.username)
    assert query == "user"
예제 #23
0
def test_username_cant_be_blank_or_have_semicolon():
    form = Bag(username='******',
               password='******',
               passcheck='0123456789',
               email=email_addr,
               emailcheck=email_addr,
               day='12',
               month='12',
               year=arrow.now().year - 19)
    with pytest.raises(WeasylError) as err:
        login.create(form)
    assert 'usernameInvalid' == err.value.value
    form.username = '******'
    with pytest.raises(WeasylError) as err:
        login.create(form)
    assert 'usernameInvalid' == err.value.value
예제 #24
0
파일: test_create.py 프로젝트: makyo/weasyl
def test_usernames_cannot_match_pending_account_usernames():
    d.engine.execute(d.meta.tables["logincreate"].insert(), {
        "token": 40 * "a",
        "username": user_name,
        "login_name": user_name,
        "hashpass": login.passhash(raw_password),
        "email": "*****@*****.**",
        "birthday": arrow.Arrow(2000, 1, 1),
        "unixtime": arrow.now(),
    })
    form = Bag(username=user_name, password='******', passcheck='0123456789',
               email=email_addr, emailcheck=email_addr,
               day='12', month='12', year=arrow.now().year - 19)
    with pytest.raises(WeasylError) as err:
        login.create(form)
    assert 'usernameExists' == err.value.value
예제 #25
0
파일: test_create.py 프로젝트: makyo/weasyl
def test_passwords_must_be_of_sufficient_length():
    password = "******"
    form = Bag(username=user_name, password=password, passcheck=password,
               email='foo', emailcheck='foo',
               day='12', month='12', year=arrow.now().year - 19)
    # Insecure length
    with pytest.raises(WeasylError) as err:
        login.create(form)
    assert 'passwordInsecure' == err.value.value
    # Secure length
    password = "******"
    form.passcheck = form.password = password
    # emailInvalid is the next failure state after passwordInsecure, so it is a 'success' for this testcase
    with pytest.raises(WeasylError) as err:
        login.create(form)
    assert 'emailInvalid' == err.value.value
예제 #26
0
def test_username_cannot_match_an_active_alias():
    user_id = db_utils.create_user(username='******')
    d.engine.execute(
        "INSERT INTO useralias VALUES (%(userid)s, %(username)s, 'p')",
        userid=user_id,
        username=user_name)
    form = Bag(username=user_name,
               password='******',
               passcheck='0123456789',
               email=email_addr,
               emailcheck=email_addr,
               day='12',
               month='12',
               year=arrow.now().year - 19)
    with pytest.raises(WeasylError) as err:
        login.create(form)
    assert 'usernameExists' == err.value.value
예제 #27
0
파일: user.py 프로젝트: Weasyl/weasyl
def signup_post_(request):
    form = request.web_input(
        username="", password="", passcheck="", email="", emailcheck="",
        day="", month="", year="")

    if 'g-recaptcha-response' not in form or not define.captcha_verify(form['g-recaptcha-response']):
        return Response(define.errorpage(
            request.userid,
            "There was an error validating the CAPTCHA response; you should go back and try again."))

    login.create(form)
    return Response(define.errorpage(
        request.userid,
        "**Success!** Your username has been reserved and a message "
        "has been sent to the email address you provided with "
        "information on how to complete the registration process. You "
        "should receive this email within the next hour.",
        [["Return to the Home Page", "/"]]))
예제 #28
0
def test_username_cant_be_blank_or_have_semicolon():
    form = Bag(username='******',
               password='******',
               passcheck='0123456789',
               email=email_addr,
               emailcheck=email_addr,
               day='12',
               month='12',
               year=arrow.now().year - 19)
    with pytest.raises(WeasylError) as err:
        login.create(form)
    assert 'usernameInvalid' == err.value.value
    form.username = '******'
    login.create(form)
    assert d.engine.scalar(
        "SELECT username FROM logincreate WHERE email = %(email)s LIMIT 1",
        email=form.email,
    ) == "testloginsuite"
예제 #29
0
def test_create_fails_if_another_account_has_email_linked_to_their_account():
    """
    Test checks to see if an email is tied to an active user account. If so,
    login.create() will not permit another account to be made for the same
    address.
    """
    db_utils.create_user(username=user_name, email_addr=email_addr)
    form = Bag(username=user_name,
               password='******',
               passcheck='0123456789',
               email=email_addr,
               emailcheck=email_addr,
               day='12',
               month='12',
               year=arrow.now().year - 19)
    with pytest.raises(WeasylError) as err:
        login.create(form)
    assert 'emailExists' == err.value.value
예제 #30
0
파일: test_create.py 프로젝트: makyo/weasyl
def test_create_fails_if_email_domain_is_blacklisted():
    """
    Test verifies that login.create() will properly fail to register new accounts
    when the domain portion of the email address is contained in the emailblacklist
    table.
    """
    d.engine.execute(d.meta.tables["emailblacklist"].insert(), {
        "domain_name": "blacklisted.com",
        "reason": "test case for login.create()",
        "added_by": db_utils.create_user(),
    })
    blacklisted_email = "*****@*****.**"
    form = Bag(username=user_name, password='******', passcheck='0123456789',
               email=blacklisted_email, emailcheck=blacklisted_email,
               day='12', month='12', year=arrow.now().year - 19)
    with pytest.raises(WeasylError) as err:
        login.create(form)
    assert 'emailBlacklisted' == err.value.value
예제 #31
0
def test_create_fails_if_username_is_a_prohibited_name():
    form = Bag(username='******',
               password='******',
               passcheck='0123456789',
               email='*****@*****.**',
               emailcheck='*****@*****.**',
               day='12',
               month='12',
               year=arrow.now().year - 19)
    prohibited_names = [
        "admin", "administrator", "mod", "moderator", "weasyl", "weasyladmin",
        "weasylmod", "staff", "security"
    ]
    for name in prohibited_names:
        form.username = name
        with pytest.raises(WeasylError) as err:
            login.create(form)
        assert 'usernameInvalid' == err.value.value
예제 #32
0
파일: user.py 프로젝트: 0x15/weasyl
    def POST(self):
        form = web.input(
            username="", password="", passcheck="", email="", emailcheck="",
            day="", month="", year="", recaptcha_challenge_field="", recaptcha_response_field="")

        if not define.captcha_verify(form):
            return define.errorpage(
                self.user_id,
                "The image verification you entered was not correct; you should go back and try again.")

        login.create(form)
        return define.errorpage(
            self.user_id,
            "**Success!** Your username has been reserved and a "
            "message has been sent to the email address you specified with "
            "information on how to complete the registration process. You "
            "should receive this email within the next hour.",
            [["Return to the Home Page", "/index"]])
예제 #33
0
def test_usernames_cannot_match_pending_account_usernames():
    d.engine.execute(
        d.meta.tables["logincreate"].insert(), {
            "token": 40 * "a",
            "username": user_name,
            "login_name": user_name,
            "hashpass": login.passhash(raw_password),
            "email": "*****@*****.**",
            "birthday": arrow.Arrow(2000, 1, 1),
        })
    form = Bag(username=user_name,
               password='******',
               passcheck='0123456789',
               email=email_addr,
               emailcheck=email_addr,
               day='12',
               month='12',
               year=arrow.now().year - 19)
    with pytest.raises(WeasylError) as err:
        login.create(form)
    assert 'usernameExists' == err.value.value
예제 #34
0
def test_passwords_must_be_of_sufficient_length():
    password = "******"
    form = Bag(username=user_name,
               password=password,
               passcheck=password,
               email='foo',
               emailcheck='foo',
               day='12',
               month='12',
               year=arrow.now().year - 19)
    # Insecure length
    with pytest.raises(WeasylError) as err:
        login.create(form)
    assert 'passwordInsecure' == err.value.value
    # Secure length
    password = "******"
    form.passcheck = form.password = password
    # emailInvalid is the next failure state after passwordInsecure, so it is a 'success' for this testcase
    with pytest.raises(WeasylError) as err:
        login.create(form)
    assert 'emailInvalid' == err.value.value
예제 #35
0
def test_create_fails_if_another_account_has_email_linked_to_their_account():
    """
    Test checks to see if an email is tied to an active user account. If so,
    login.create() will not permit another account to be made for the same
    address.
    """
    db_utils.create_user(username=user_name, email_addr=email_addr)
    form = Bag(username="******",
               password='******',
               passcheck='0123456789',
               email=email_addr,
               emailcheck=email_addr,
               day='12',
               month='12',
               year=arrow.now().year - 19)
    login.create(form)
    query = d.engine.scalar("""
        SELECT username FROM logincreate WHERE username = %(username)s AND invalid IS TRUE
    """,
                            username=form.username)
    assert query == "user"
예제 #36
0
파일: test_create.py 프로젝트: makyo/weasyl
def test_create_fails_if_pending_account_has_same_email():
    """
    Test checks to see if an email is tied to a pending account creation entry
    in logincreate. If so, login.create() will not permit another account to be
    made for the same address.
    """
    d.engine.execute(d.meta.tables["logincreate"].insert(), {
        "token": 40 * "a",
        "username": "******",
        "login_name": "existing",
        "hashpass": login.passhash(raw_password),
        "email": email_addr,
        "birthday": arrow.Arrow(2000, 1, 1),
        "unixtime": arrow.now(),
    })
    form = Bag(username="******", password='******', passcheck='0123456789',
               email=email_addr, emailcheck=email_addr,
               day='12', month='12', year=arrow.now().year - 19)
    with pytest.raises(WeasylError) as err:
        login.create(form)
    assert 'emailExists' == err.value.value
예제 #37
0
def test_create_fails_if_pending_account_has_same_email():
    """
    Test checks to see if an email is tied to a pending account creation entry
    in logincreate. If so, login.create() will not permit another account to be
    made for the same address.
    """
    d.engine.execute(d.meta.tables["logincreate"].insert(), {
        "token": 40 * "a",
        "username": "******",
        "login_name": "existing",
        "hashpass": login.passhash(raw_password),
        "email": email_addr,
        "birthday": arrow.Arrow(2000, 1, 1),
        "unixtime": arrow.now(),
    })
    form = Bag(username="******", password='******', passcheck='0123456789',
               email=email_addr, emailcheck=email_addr,
               day='12', month='12', year=arrow.now().year - 19)
    login.create(form)
    query = d.engine.scalar("""
        SELECT username FROM logincreate WHERE username = %(username)s AND invalid IS TRUE
    """, username=form.username)
    assert query == "test"
예제 #38
0
def test_create_fails_if_email_domain_is_blacklisted():
    """
    Test verifies that login.create() will properly fail to register new accounts
    when the domain portion of the email address is contained in the emailblacklist
    table.
    """
    d.engine.execute(
        d.meta.tables["emailblacklist"].insert(), {
            "domain_name": "blacklisted.com",
            "reason": "test case for login.create()",
            "added_by": db_utils.create_user(),
        })
    blacklisted_email = "*****@*****.**"
    form = Bag(username=user_name,
               password='******',
               passcheck='0123456789',
               email=blacklisted_email,
               emailcheck=blacklisted_email,
               day='12',
               month='12',
               year=arrow.now().year - 19)
    with pytest.raises(WeasylError) as err:
        login.create(form)
    assert 'emailBlacklisted' == err.value.value
예제 #39
0
    def test_verify_subdomains_of_blocked_sites_blocked(self):
        """
        Blacklisted: badsite.net
        Blocked: badsite.net
        Also blocked: subdomain.badsite.net
        """
        d.engine.execute(
            d.meta.tables["emailblacklist"].insert(), {
                "domain_name": "blacklisted.com",
                "reason": "test case for login.create()",
                "added_by": db_utils.create_user(),
            })
        # Test the domains from the emailblacklist table
        blacklisted_email = "*****@*****.**"
        form = Bag(username=user_name,
                   password='******',
                   passcheck='0123456789',
                   email=blacklisted_email,
                   emailcheck=blacklisted_email,
                   day='12',
                   month='12',
                   year=arrow.now().year - 19)
        with pytest.raises(WeasylError) as err:
            login.create(form)
        assert 'emailBlacklisted' == err.value.value

        # Test the domains from the code that would download the list of disposable domains
        blacklisted_email = "*****@*****.**"
        form = Bag(username=user_name,
                   password='******',
                   passcheck='0123456789',
                   email=blacklisted_email,
                   emailcheck=blacklisted_email,
                   day='12',
                   month='12',
                   year=arrow.now().year - 19)
        with pytest.raises(WeasylError) as err:
            login.create(form)
        assert 'emailBlacklisted' == err.value.value

        # Ensure address in the form of <domain.domain> is blocked
        blacklisted_email = "*****@*****.**"
        form = Bag(username=user_name,
                   password='******',
                   passcheck='0123456789',
                   email=blacklisted_email,
                   emailcheck=blacklisted_email,
                   day='12',
                   month='12',
                   year=arrow.now().year - 19)
        with pytest.raises(WeasylError) as err:
            login.create(form)
        assert 'emailBlacklisted' == err.value.value
예제 #40
0
    def test_similarly_named_domains_are_not_blocked(self):
        """
        Blacklisted: badsite.net
        /Not/ Blocked: notabadsite.net
        Also /Not/ blocked: subdomain.notabadsite.net
        """
        d.engine.execute(
            d.meta.tables["emailblacklist"].insert(), {
                "domain_name": "blacklisted.com",
                "reason": "test case for login.create()",
                "added_by": db_utils.create_user(),
            })
        mail = "*****@*****.**"
        form = Bag(username=user_name,
                   password='******',
                   passcheck='0123456789',
                   email=mail,
                   emailcheck=mail,
                   day='12',
                   month='12',
                   year=arrow.now().year - 19)
        login.create(form)

        mail = "*****@*****.**"
        form = Bag(username=user_name + "1",
                   password='******',
                   passcheck='0123456789',
                   email=mail,
                   emailcheck=mail,
                   day='12',
                   month='12',
                   year=arrow.now().year - 19)
        login.create(form)

        mail = "*****@*****.**"
        form = Bag(username=user_name + "2",
                   password='******',
                   passcheck='0123456789',
                   email=mail,
                   emailcheck=mail,
                   day='12',
                   month='12',
                   year=arrow.now().year - 19)
        login.create(form)
예제 #41
0
def test_DMY_not_integer_raises_birthdayInvalid_WeasylError():
    # Check for failure state if 'day' is not an integer, e.g., string
    form = Bag(username=user_name,
               password='',
               passcheck='',
               email='*****@*****.**',
               emailcheck='*****@*****.**',
               day='test',
               month='31',
               year='1942')
    with pytest.raises(WeasylError) as err:
        login.create(form)
    assert 'birthdayInvalid' == err.value.value

    # Check for failure state if 'month' is not an integer, e.g., string
    form = Bag(username=user_name,
               password='',
               passcheck='',
               email='*****@*****.**',
               emailcheck='*****@*****.**',
               day='12',
               month='test',
               year='1942')
    with pytest.raises(WeasylError) as err:
        login.create(form)
    assert 'birthdayInvalid' == err.value.value

    # Check for failure state if 'year' is not an integer, e.g., string
    form = Bag(username=user_name,
               password='',
               passcheck='',
               email='*****@*****.**',
               emailcheck='*****@*****.**',
               day='12',
               month='31',
               year='test')
    with pytest.raises(WeasylError) as err:
        login.create(form)
    assert 'birthdayInvalid' == err.value.value
예제 #42
0
def test_DMY_missing_raises_birthdayInvalid_WeasylError():
    # Check for failure state if 'year' is not an valid year e.g., -1
    form = Bag(username=user_name,
               password='',
               passcheck='',
               email='*****@*****.**',
               emailcheck='*****@*****.**',
               day=None,
               month='12',
               year='2000')
    with pytest.raises(WeasylError) as err:
        login.create(form)
    assert 'birthdayInvalid' == err.value.value

    # Check for failure state if 'year' is not an valid year e.g., -1
    form = Bag(username=user_name,
               password='',
               passcheck='',
               email='*****@*****.**',
               emailcheck='*****@*****.**',
               day='12',
               month=None,
               year='2000')
    with pytest.raises(WeasylError) as err:
        login.create(form)
    assert 'birthdayInvalid' == err.value.value

    # Check for failure state if 'year' is not an valid year e.g., -1
    form = Bag(username=user_name,
               password='',
               passcheck='',
               email='*****@*****.**',
               emailcheck='*****@*****.**',
               day='12',
               month='12',
               year=None)
    with pytest.raises(WeasylError) as err:
        login.create(form)
    assert 'birthdayInvalid' == err.value.value
예제 #43
0
def test_DMY_out_of_valid_ranges_raises_birthdayInvalid_WeasylError():
    # Check for failure state if 'day' is not an valid day e.g., 42
    form = Bag(username=user_name,
               password='',
               passcheck='',
               email='*****@*****.**',
               emailcheck='*****@*****.**',
               day='42',
               month='12',
               year='2000')
    with pytest.raises(WeasylError) as err:
        login.create(form)
    assert 'birthdayInvalid' == err.value.value

    # Check for failure state if 'month' is not an valid month e.g., 42
    form = Bag(username=user_name,
               password='',
               passcheck='',
               email='*****@*****.**',
               emailcheck='*****@*****.**',
               day='12',
               month='42',
               year='2000')
    with pytest.raises(WeasylError) as err:
        login.create(form)
    assert 'birthdayInvalid' == err.value.value

    # Check for failure state if 'year' is not an valid year e.g., -1
    form = Bag(username=user_name,
               password='',
               passcheck='',
               email='*****@*****.**',
               emailcheck='*****@*****.**',
               day='12',
               month='12',
               year='-1')
    with pytest.raises(WeasylError) as err:
        login.create(form)
    assert 'birthdayInvalid' == err.value.value
예제 #44
0
파일: test_create.py 프로젝트: makyo/weasyl
def test_DMY_out_of_valid_ranges_raises_birthdayInvalid_WeasylError():
    # Check for failure state if 'day' is not an valid day e.g., 42
    form = Bag(username=user_name, password='', passcheck='',
               email='*****@*****.**', emailcheck='*****@*****.**',
               day='42', month='12', year='2000')
    with pytest.raises(WeasylError) as err:
        login.create(form)
    assert 'birthdayInvalid' == err.value.value

    # Check for failure state if 'month' is not an valid month e.g., 42
    form = Bag(username=user_name, password='', passcheck='',
               email='*****@*****.**', emailcheck='*****@*****.**',
               day='12', month='42', year='2000')
    with pytest.raises(WeasylError) as err:
        login.create(form)
    assert 'birthdayInvalid' == err.value.value

    # Check for failure state if 'year' is not an valid year e.g., -1
    form = Bag(username=user_name, password='', passcheck='',
               email='*****@*****.**', emailcheck='*****@*****.**',
               day='12', month='12', year='-1')
    with pytest.raises(WeasylError) as err:
        login.create(form)
    assert 'birthdayInvalid' == err.value.value
예제 #45
0
파일: test_create.py 프로젝트: makyo/weasyl
def test_DMY_not_integer_raises_birthdayInvalid_WeasylError():
    # Check for failure state if 'day' is not an integer, e.g., string
    form = Bag(username=user_name, password='', passcheck='',
               email='*****@*****.**', emailcheck='*****@*****.**',
               day='test', month='31', year='1942')
    with pytest.raises(WeasylError) as err:
        login.create(form)
    assert 'birthdayInvalid' == err.value.value

    # Check for failure state if 'month' is not an integer, e.g., string
    form = Bag(username=user_name, password='', passcheck='',
               email='*****@*****.**', emailcheck='*****@*****.**',
               day='12', month='test', year='1942')
    with pytest.raises(WeasylError) as err:
        login.create(form)
    assert 'birthdayInvalid' == err.value.value

    # Check for failure state if 'year' is not an integer, e.g., string
    form = Bag(username=user_name, password='', passcheck='',
               email='*****@*****.**', emailcheck='*****@*****.**',
               day='12', month='31', year='test')
    with pytest.raises(WeasylError) as err:
        login.create(form)
    assert 'birthdayInvalid' == err.value.value
예제 #46
0
파일: test_create.py 프로젝트: makyo/weasyl
def test_DMY_missing_raises_birthdayInvalid_WeasylError():
    # Check for failure state if 'year' is not an valid year e.g., -1
    form = Bag(username=user_name, password='', passcheck='',
               email='*****@*****.**', emailcheck='*****@*****.**',
               day=None, month='12', year='2000')
    with pytest.raises(WeasylError) as err:
        login.create(form)
    assert 'birthdayInvalid' == err.value.value

    # Check for failure state if 'year' is not an valid year e.g., -1
    form = Bag(username=user_name, password='', passcheck='',
               email='*****@*****.**', emailcheck='*****@*****.**',
               day='12', month=None, year='2000')
    with pytest.raises(WeasylError) as err:
        login.create(form)
    assert 'birthdayInvalid' == err.value.value

    # Check for failure state if 'year' is not an valid year e.g., -1
    form = Bag(username=user_name, password='', passcheck='',
               email='*****@*****.**', emailcheck='*****@*****.**',
               day='12', month='12', year=None)
    with pytest.raises(WeasylError) as err:
        login.create(form)
    assert 'birthdayInvalid' == err.value.value