mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-07-09 03:04:54 -04:00
Fix failed tests when env default email/password were changed (#1157)
* fix: failed tests when env default email/password changed * Remove default email exposition in docs
This commit is contained in:
parent
8831c2ec85
commit
aff30adda6
4
tests/fixtures/fixture_admin.py
vendored
4
tests/fixtures/fixture_admin.py
vendored
@ -9,7 +9,7 @@ from tests import utils
|
|||||||
def admin_token(api_client: TestClient, api_routes: utils.AppRoutes):
|
def admin_token(api_client: TestClient, api_routes: utils.AppRoutes):
|
||||||
settings = get_app_settings()
|
settings = get_app_settings()
|
||||||
|
|
||||||
form_data = {"username": "changeme@email.com", "password": settings.DEFAULT_PASSWORD}
|
form_data = {"username": settings.DEFAULT_EMAIL, "password": settings.DEFAULT_PASSWORD}
|
||||||
return utils.login(form_data, api_client, api_routes)
|
return utils.login(form_data, api_client, api_routes)
|
||||||
|
|
||||||
|
|
||||||
@ -17,7 +17,7 @@ def admin_token(api_client: TestClient, api_routes: utils.AppRoutes):
|
|||||||
def admin_user(api_client: TestClient, api_routes: utils.AppRoutes):
|
def admin_user(api_client: TestClient, api_routes: utils.AppRoutes):
|
||||||
settings = get_app_settings()
|
settings = get_app_settings()
|
||||||
|
|
||||||
form_data = {"username": "changeme@email.com", "password": settings.DEFAULT_PASSWORD}
|
form_data = {"username": settings.DEFAULT_EMAIL, "password": settings.DEFAULT_PASSWORD}
|
||||||
|
|
||||||
token = utils.login(form_data, api_client, api_routes)
|
token = utils.login(form_data, api_client, api_routes)
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
from fastapi.testclient import TestClient
|
from fastapi.testclient import TestClient
|
||||||
|
|
||||||
|
from mealie.core.config import get_app_settings
|
||||||
from tests import utils
|
from tests import utils
|
||||||
from tests.utils import routes
|
from tests.utils import routes
|
||||||
from tests.utils.app_routes import AppRoutes
|
from tests.utils.app_routes import AppRoutes
|
||||||
@ -24,6 +25,8 @@ def generate_create_data() -> dict:
|
|||||||
|
|
||||||
|
|
||||||
def test_init_superuser(api_client: TestClient, admin_user: TestUser):
|
def test_init_superuser(api_client: TestClient, admin_user: TestUser):
|
||||||
|
settings = get_app_settings()
|
||||||
|
|
||||||
response = api_client.get(routes.RoutesAdminUsers.item(admin_user.user_id), headers=admin_user.token)
|
response = api_client.get(routes.RoutesAdminUsers.item(admin_user.user_id), headers=admin_user.token)
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
|
|
||||||
@ -33,7 +36,7 @@ def test_init_superuser(api_client: TestClient, admin_user: TestUser):
|
|||||||
assert admin_data["groupId"] == admin_user.group_id
|
assert admin_data["groupId"] == admin_user.group_id
|
||||||
|
|
||||||
assert admin_data["fullName"] == "Change Me"
|
assert admin_data["fullName"] == "Change Me"
|
||||||
assert admin_data["email"] == "changeme@email.com"
|
assert admin_data["email"] == settings.DEFAULT_EMAIL
|
||||||
|
|
||||||
|
|
||||||
def test_create_user(api_client: TestClient, api_routes: AppRoutes, admin_token):
|
def test_create_user(api_client: TestClient, api_routes: AppRoutes, admin_token):
|
||||||
@ -80,10 +83,12 @@ def test_update_user(api_client: TestClient, admin_user: TestUser):
|
|||||||
|
|
||||||
|
|
||||||
def test_update_other_user_as_not_admin(api_client: TestClient, unique_user: TestUser, g2_user: TestUser):
|
def test_update_other_user_as_not_admin(api_client: TestClient, unique_user: TestUser, g2_user: TestUser):
|
||||||
|
settings = get_app_settings()
|
||||||
|
|
||||||
update_data = {
|
update_data = {
|
||||||
"id": unique_user.user_id,
|
"id": unique_user.user_id,
|
||||||
"fullName": "Updated Name",
|
"fullName": "Updated Name",
|
||||||
"email": "changeme@email.com",
|
"email": settings.DEFAULT_EMAIL,
|
||||||
"group": "Home",
|
"group": "Home",
|
||||||
"admin": True,
|
"admin": True,
|
||||||
}
|
}
|
||||||
|
@ -2,19 +2,24 @@ import json
|
|||||||
|
|
||||||
from fastapi.testclient import TestClient
|
from fastapi.testclient import TestClient
|
||||||
|
|
||||||
|
from mealie.core.config import get_app_settings
|
||||||
from tests.utils.app_routes import AppRoutes
|
from tests.utils.app_routes import AppRoutes
|
||||||
from tests.utils.fixture_schemas import TestUser
|
from tests.utils.fixture_schemas import TestUser
|
||||||
|
|
||||||
|
|
||||||
def test_failed_login(api_client: TestClient, api_routes: AppRoutes):
|
def test_failed_login(api_client: TestClient, api_routes: AppRoutes):
|
||||||
form_data = {"username": "changeme@email.com", "password": "WRONG_PASSWORD"}
|
settings = get_app_settings()
|
||||||
|
|
||||||
|
form_data = {"username": settings.DEFAULT_EMAIL, "password": "WRONG_PASSWORD"}
|
||||||
response = api_client.post(api_routes.auth_token, form_data)
|
response = api_client.post(api_routes.auth_token, form_data)
|
||||||
|
|
||||||
assert response.status_code == 401
|
assert response.status_code == 401
|
||||||
|
|
||||||
|
|
||||||
def test_superuser_login(api_client: TestClient, api_routes: AppRoutes, admin_token):
|
def test_superuser_login(api_client: TestClient, api_routes: AppRoutes, admin_token):
|
||||||
form_data = {"username": "changeme@email.com", "password": "MyPassword"}
|
settings = get_app_settings()
|
||||||
|
|
||||||
|
form_data = {"username": settings.DEFAULT_EMAIL, "password": settings.DEFAULT_PASSWORD}
|
||||||
response = api_client.post(api_routes.auth_token, form_data)
|
response = api_client.post(api_routes.auth_token, form_data)
|
||||||
|
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
|
Loading…
x
Reference in New Issue
Block a user