forked from Weasyl/weasyl
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into Birthday_to_date
- Loading branch information
Showing
8 changed files
with
47 additions
and
152 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
libweasyl/alembic/versions/63baa2713e72_remove_signup_birthdate_column.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
"""Remove signup birthdate column | ||
Revision ID: 63baa2713e72 | ||
Revises: 57171ee9e989 | ||
Create Date: 2024-08-21 23:50:18.122609 | ||
""" | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = '63baa2713e72' | ||
down_revision = '57171ee9e989' | ||
|
||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
|
||
def upgrade(): | ||
op.drop_column('logincreate', 'birthday') | ||
|
||
|
||
def downgrade(): | ||
op.add_column('logincreate', sa.Column('birthday', sa.INTEGER(), autoincrement=False, nullable=True)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,4 @@ | ||
from datetime import date | ||
|
||
import pytest | ||
import arrow | ||
from web.utils import Storage as Bag | ||
|
||
from weasyl import define as d | ||
|
@@ -18,92 +15,9 @@ | |
|
||
|
||
@pytest.mark.usefixtures('db') | ||
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='', | ||
email='[email protected]', | ||
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='', | ||
email='[email protected]', | ||
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='', | ||
email='[email protected]', | ||
day='12', month='31', year='test') | ||
with pytest.raises(WeasylError) as err: | ||
login.create(form) | ||
assert 'birthdayInvalid' == err.value.value | ||
|
||
|
||
@pytest.mark.usefixtures('db') | ||
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='', | ||
email='[email protected]', | ||
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='', | ||
email='[email protected]', | ||
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='', | ||
email='[email protected]', | ||
day='12', month='12', year='-1') | ||
with pytest.raises(WeasylError) as err: | ||
login.create(form) | ||
assert 'birthdayInvalid' == err.value.value | ||
|
||
|
||
@pytest.mark.usefixtures('db') | ||
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='', | ||
email='[email protected]', | ||
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 | ||
def test_age_minimum(): | ||
form = Bag(username=user_name, password='', | ||
email='[email protected]', | ||
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='', | ||
email='[email protected]', | ||
day='12', month='12', year=None) | ||
with pytest.raises(WeasylError) as err: | ||
login.create(form) | ||
assert 'birthdayInvalid' == err.value.value | ||
|
||
|
||
@pytest.mark.usefixtures('db') | ||
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='', | ||
email='[email protected]', | ||
day='12', month='12', year=arrow.utcnow().year - 11) | ||
email='[email protected]') | ||
with pytest.raises(WeasylError) as err: | ||
login.create(form) | ||
assert 'birthdayInvalid' == err.value.value | ||
|
@@ -114,7 +28,7 @@ def test_passwords_must_be_of_sufficient_length(): | |
password = "tooShort" | ||
form = Bag(username=user_name, password=password, | ||
email='foo', | ||
day='12', month='12', year=arrow.utcnow().year - 19) | ||
age="13+") | ||
# Insecure length | ||
with pytest.raises(WeasylError) as err: | ||
login.create(form) | ||
|
@@ -132,7 +46,7 @@ def test_passwords_must_be_of_sufficient_length(): | |
def test_create_fails_if_email_is_invalid(): | ||
form = Bag(username=user_name, password='0123456789', | ||
email=';--', | ||
day='12', month='12', year=arrow.utcnow().year - 19) | ||
age="13+") | ||
with pytest.raises(WeasylError) as err: | ||
login.create(form) | ||
assert 'emailInvalid' == err.value.value | ||
|
@@ -148,7 +62,7 @@ def test_create_fails_if_another_account_has_email_linked_to_their_account(): | |
db_utils.create_user(username=user_name, email_addr=email_addr) | ||
form = Bag(username="user", password='0123456789', | ||
email=email_addr, | ||
day='12', month='12', year=arrow.utcnow().year - 19) | ||
age="13+") | ||
login.create(form) | ||
query = d.engine.scalar(""" | ||
SELECT username FROM logincreate WHERE username = %(username)s AND invalid IS TRUE | ||
|
@@ -169,11 +83,10 @@ def test_create_fails_if_pending_account_has_same_email(): | |
"login_name": "existing", | ||
"hashpass": login.passhash(raw_password), | ||
"email": email_addr, | ||
"birthday": date(2000, 1, 1), | ||
}) | ||
form = Bag(username="test", password='0123456789', | ||
email=email_addr, | ||
day='12', month='12', year=arrow.utcnow().year - 19) | ||
age="13+") | ||
login.create(form) | ||
query = d.engine.scalar(""" | ||
SELECT username FROM logincreate WHERE username = %(username)s AND invalid IS TRUE | ||
|
@@ -185,7 +98,7 @@ def test_create_fails_if_pending_account_has_same_email(): | |
def test_username_cant_be_blank_or_have_semicolon(): | ||
form = Bag(username='...', password='0123456789', | ||
email=email_addr, | ||
day='12', month='12', year=arrow.utcnow().year - 19) | ||
age="13+") | ||
with pytest.raises(WeasylError) as err: | ||
login.create(form) | ||
assert 'usernameInvalid' == err.value.value | ||
|
@@ -201,7 +114,7 @@ def test_username_cant_be_blank_or_have_semicolon(): | |
def test_create_fails_if_username_is_a_prohibited_name(): | ||
form = Bag(username='testloginsuite', password='0123456789', | ||
email='[email protected]', | ||
day='12', month='12', year=arrow.utcnow().year - 19) | ||
age="13+") | ||
prohibited_names = ["admin", "administrator", "mod", "moderator", "weasyl", | ||
"weasyladmin", "weasylmod", "staff", "security"] | ||
for name in prohibited_names: | ||
|
@@ -216,7 +129,7 @@ def test_usernames_must_be_unique(): | |
db_utils.create_user(username=user_name, email_addr="[email protected]") | ||
form = Bag(username=user_name, password='0123456789', | ||
email=email_addr, | ||
day='12', month='12', year=arrow.utcnow().year - 19) | ||
age="13+") | ||
with pytest.raises(WeasylError) as err: | ||
login.create(form) | ||
assert 'usernameExists' == err.value.value | ||
|
@@ -230,11 +143,10 @@ def test_usernames_cannot_match_pending_account_usernames(): | |
"login_name": user_name, | ||
"hashpass": login.passhash(raw_password), | ||
"email": "[email protected]", | ||
"birthday": date(2000, 1, 1), | ||
}) | ||
form = Bag(username=user_name, password='0123456789', | ||
email=email_addr, | ||
day='12', month='12', year=arrow.utcnow().year - 19) | ||
age="13+") | ||
with pytest.raises(WeasylError) as err: | ||
login.create(form) | ||
assert 'usernameExists' == err.value.value | ||
|
@@ -246,7 +158,7 @@ def test_username_cannot_match_an_active_alias(): | |
d.engine.execute("INSERT INTO useralias VALUES (%(userid)s, %(username)s, 'p')", userid=user_id, username=user_name) | ||
form = Bag(username=user_name, password='0123456789', | ||
email=email_addr, | ||
day='12', month='12', year=arrow.utcnow().year - 19) | ||
age="13+") | ||
with pytest.raises(WeasylError) as err: | ||
login.create(form) | ||
assert 'usernameExists' == err.value.value | ||
|
@@ -256,7 +168,7 @@ def test_username_cannot_match_an_active_alias(): | |
def test_verify_correct_information_creates_account(): | ||
form = Bag(username=user_name, password='0123456789', | ||
email=email_addr, | ||
day='12', month='12', year=arrow.utcnow().year - 19) | ||
age="13+") | ||
login.create(form) | ||
# This record should exist when this function completes successfully | ||
assert d.engine.scalar( | ||
|
@@ -280,7 +192,7 @@ def test_create_fails_if_email_domain_is_blacklisted(self): | |
blacklisted_email = "[email protected]" | ||
form = Bag(username=user_name, password='0123456789', | ||
email=blacklisted_email, | ||
day='12', month='12', year=arrow.utcnow().year - 19) | ||
age="13+") | ||
with pytest.raises(WeasylError) as err: | ||
login.create(form) | ||
assert 'emailBlacklisted' == err.value.value | ||
|
@@ -301,7 +213,7 @@ def test_verify_subdomains_of_blocked_sites_blocked(self): | |
blacklisted_email = "[email protected]" | ||
form = Bag(username=user_name, password='0123456789', | ||
email=blacklisted_email, | ||
day='12', month='12', year=arrow.utcnow().year - 19) | ||
age="13+") | ||
with pytest.raises(WeasylError) as err: | ||
login.create(form) | ||
assert 'emailBlacklisted' == err.value.value | ||
|
@@ -310,7 +222,7 @@ def test_verify_subdomains_of_blocked_sites_blocked(self): | |
blacklisted_email = "[email protected]" | ||
form = Bag(username=user_name, password='0123456789', | ||
email=blacklisted_email, | ||
day='12', month='12', year=arrow.utcnow().year - 19) | ||
age="13+") | ||
with pytest.raises(WeasylError) as err: | ||
login.create(form) | ||
assert 'emailBlacklisted' == err.value.value | ||
|
@@ -319,7 +231,7 @@ def test_verify_subdomains_of_blocked_sites_blocked(self): | |
blacklisted_email = "[email protected]" | ||
form = Bag(username=user_name, password='0123456789', | ||
email=blacklisted_email, | ||
day='12', month='12', year=arrow.utcnow().year - 19) | ||
age="13+") | ||
with pytest.raises(WeasylError) as err: | ||
login.create(form) | ||
assert 'emailBlacklisted' == err.value.value | ||
|
@@ -339,17 +251,17 @@ def test_similarly_named_domains_are_not_blocked(self): | |
mail = "[email protected]" | ||
form = Bag(username=user_name, password='0123456789', | ||
email=mail, | ||
day='12', month='12', year=arrow.utcnow().year - 19) | ||
age="13+") | ||
login.create(form) | ||
|
||
mail = "[email protected]" | ||
form = Bag(username=user_name + "1", password='0123456789', | ||
email=mail, | ||
day='12', month='12', year=arrow.utcnow().year - 19) | ||
age="13+") | ||
login.create(form) | ||
|
||
mail = "[email protected]" | ||
form = Bag(username=user_name + "2", password='0123456789', | ||
email=mail, | ||
day='12', month='12', year=arrow.utcnow().year - 19) | ||
age="13+") | ||
login.create(form) |
Oops, something went wrong.