mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-07-24 15:49:42 +02:00
feat: Redirect Logged Out Users to Default Group, If It's Public (#2772)
Some checks are pending
CodeQL / Analyze (javascript-typescript) (push) Waiting to run
CodeQL / Analyze (python) (push) Waiting to run
Docker Nightly Production / Backend Server Tests (push) Waiting to run
Docker Nightly Production / Frontend and End-to-End Tests (push) Waiting to run
Docker Nightly Production / Build Tagged Release (push) Blocked by required conditions
Docker Nightly Production / Notify Discord (push) Blocked by required conditions
Some checks are pending
CodeQL / Analyze (javascript-typescript) (push) Waiting to run
CodeQL / Analyze (python) (push) Waiting to run
Docker Nightly Production / Backend Server Tests (push) Waiting to run
Docker Nightly Production / Frontend and End-to-End Tests (push) Waiting to run
Docker Nightly Production / Build Tagged Release (push) Blocked by required conditions
Docker Nightly Production / Notify Discord (push) Blocked by required conditions
* add default group slug to app info if public * redirect public user to default group * added tests --------- Co-authored-by: Kuchenpirat <24235032+Kuchenpirat@users.noreply.github.com>
This commit is contained in:
parent
e686fa671c
commit
f42114e966
5 changed files with 50 additions and 3 deletions
|
@ -1,11 +1,36 @@
|
|||
import pytest
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
from mealie.core.config import get_app_settings
|
||||
from mealie.core.settings.static import APP_VERSION
|
||||
from mealie.repos.repository_factory import AllRepositories
|
||||
from tests.utils import api_routes
|
||||
from tests.utils.fixture_schemas import TestUser
|
||||
|
||||
|
||||
@pytest.mark.parametrize("is_private_group", [True, False], ids=["private group", "public group"])
|
||||
def test_public_about_get_app_info(api_client: TestClient, is_private_group: bool, database: AllRepositories):
|
||||
settings = get_app_settings()
|
||||
group = database.groups.get_by_name(settings.DEFAULT_GROUP)
|
||||
assert group and group.preferences
|
||||
|
||||
group.preferences.private_group = is_private_group
|
||||
database.group_preferences.update(group.id, group.preferences)
|
||||
|
||||
response = api_client.get(api_routes.app_about)
|
||||
as_dict = response.json()
|
||||
|
||||
assert as_dict["production"] == settings.PRODUCTION
|
||||
assert as_dict["version"] == APP_VERSION
|
||||
assert as_dict["demoStatus"] == settings.IS_DEMO
|
||||
assert as_dict["allowSignup"] == settings.ALLOW_SIGNUP
|
||||
|
||||
if is_private_group:
|
||||
assert as_dict["defaultGroupSlug"] == None
|
||||
else:
|
||||
assert as_dict["defaultGroupSlug"] == group.slug
|
||||
|
||||
|
||||
def test_admin_about_get_app_info(api_client: TestClient, admin_user: TestUser):
|
||||
response = api_client.get(api_routes.admin_about, headers=admin_user.token)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue