Skip to content

Commit cfe5f79

Browse files
author
Vianpyro
committed
Add utility tests for email and password handling, including hashing and masking
1 parent 80a7388 commit cfe5f79

17 files changed

+48
-129
lines changed

tests/test_routes/conftest.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import pytest
2+
from flask import Flask
3+
4+
5+
@pytest.fixture
6+
def client(app: Flask):
7+
"""Create a test client for the Flask application"""
8+
with app.test_client() as client:
9+
yield client
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import pytest
2+
from flask import Flask
3+
4+
from routes.authentication import authentication_blueprint
5+
6+
7+
@pytest.fixture
8+
def app():
9+
"""Create and configure a new Flask application instance for testing"""
10+
app = Flask(__name__)
11+
app.register_blueprint(authentication_blueprint)
12+
return app
13+
14+
15+
@pytest.fixture
16+
def sample_email():
17+
return "sample.email@example.com"
18+
19+
20+
@pytest.fixture
21+
def sample_password():
22+
return "SecurePass123!"
23+
24+
25+
@pytest.fixture
26+
def sample_username():
27+
return "sampleuser"

tests/test_routes/test_authentication/test_login.py

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,5 @@
1-
import pytest
2-
from flask import Flask
31
from flask.testing import FlaskClient
42

5-
from routes.authentication import authentication_blueprint
6-
7-
8-
@pytest.fixture
9-
def app():
10-
"""Create and configure a new Flask application instance for testing"""
11-
app = Flask(__name__)
12-
app.register_blueprint(authentication_blueprint)
13-
return app
14-
15-
16-
@pytest.fixture
17-
def client(app: Flask):
18-
"""Create a test client for the Flask application"""
19-
with app.test_client() as client:
20-
yield client
21-
22-
23-
@pytest.fixture
24-
def sample_email():
25-
return "sample.email@example.com"
26-
27-
28-
@pytest.fixture
29-
def sample_password():
30-
return "SecurePass123!"
31-
32-
33-
@pytest.fixture
34-
def sample_username():
35-
return "sampleuser"
36-
373

384
def test_missing_username(client: FlaskClient, sample_password):
395
"""Test login with missing username"""

tests/test_routes/test_authentication/test_refresh_token.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,6 @@
99
from routes.authentication import authentication_blueprint
1010

1111

12-
@pytest.fixture
13-
def app():
14-
"""Create and configure a new Flask application instance for testing"""
15-
app = Flask(__name__)
16-
app.register_blueprint(authentication_blueprint)
17-
app.config["TESTING"] = True
18-
return app
19-
20-
21-
@pytest.fixture
22-
def client(app: Flask):
23-
"""Create a test client for the Flask application"""
24-
with app.test_client() as client:
25-
yield client
26-
27-
2812
@pytest.fixture
2913
def sample_person_id() -> int:
3014
"""Provide a sample person ID for testing"""

tests/test_routes/test_authentication/test_register.py

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,5 @@
1-
import pytest
2-
from flask import Flask
31
from flask.testing import FlaskClient
42

5-
from routes.authentication import authentication_blueprint
6-
7-
8-
@pytest.fixture
9-
def app():
10-
"""Create and configure a new Flask application instance for testing"""
11-
app = Flask(__name__)
12-
app.register_blueprint(authentication_blueprint)
13-
return app
14-
15-
16-
@pytest.fixture
17-
def client(app: Flask):
18-
"""Create a test client for the Flask application"""
19-
with app.test_client() as client:
20-
yield client
21-
22-
23-
@pytest.fixture
24-
def sample_email():
25-
return "sample.email@example.com"
26-
27-
28-
@pytest.fixture
29-
def sample_password():
30-
return "SecurePass123!"
31-
32-
33-
@pytest.fixture
34-
def sample_username():
35-
return "sampleuser"
36-
373

384
def test_missing_email(client: FlaskClient, sample_username, sample_password):
395
"""Test registration with missing email"""

tests/test_utility/test_email/__init__.py

Whitespace-only changes.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import pytest
2+
3+
4+
@pytest.fixture
5+
def sample_email():
6+
return "sample.email@example.com"

tests/test_utility/test_decrypt_email.py renamed to tests/test_utility/test_email/test_decrypt_email.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
1-
import pytest
2-
31
from utility import decrypt_email, encrypt_email
42

53

6-
@pytest.fixture
7-
def sample_email():
8-
return "sample.email@example.com"
9-
10-
114
def test_decrypt_email_type(sample_email):
125
"""Ensure decrypt_email returns a string"""
136
encrypted_email = encrypt_email(sample_email)

tests/test_utility/test_encrypt_email.py renamed to tests/test_utility/test_email/test_encrypt_email.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
1-
import pytest
2-
31
from utility import encrypt_email
42

53

6-
@pytest.fixture
7-
def sample_email():
8-
return "sample.email@example.com"
9-
10-
114
def test_encrypt_email(sample_email):
125
"""Ensure encrypt_email returns an encrypted email"""
136
encrypted_email = encrypt_email(sample_email)

tests/test_utility/test_hash_email.py renamed to tests/test_utility/test_email/test_hash_email.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
1-
import pytest
2-
31
from utility import hash_email
42

53

6-
@pytest.fixture
7-
def sample_email():
8-
return "sample.email@example.com"
9-
10-
114
def test_hash_email_type(sample_email):
125
"""Ensure hash_email returns a string"""
136
hashed_email = hash_email(sample_email)

0 commit comments

Comments
 (0)