Do not CRUD on entries, files & conversations in DB for null user

Increase defense-in-depth by reducing paths to create, read, update or
delete entries, files and conversations in DB when user is unset.
This commit is contained in:
Debanjum
2024-11-04 19:45:28 -08:00
parent 27fa39353e
commit ff5c10c221
19 changed files with 92 additions and 47 deletions

View File

@@ -253,11 +253,11 @@ def test_regenerate_with_github_fails_without_pat(client):
# ----------------------------------------------------------------------------------------------------
@pytest.mark.django_db
def test_get_configured_types_via_api(client, sample_org_data):
def test_get_configured_types_via_api(client, sample_org_data, default_user3: KhojUser):
# Act
text_search.setup(OrgToEntries, sample_org_data, regenerate=False)
text_search.setup(OrgToEntries, sample_org_data, regenerate=False, user=default_user3)
enabled_types = EntryAdapters.get_unique_file_types(user=None).all().values_list("file_type", flat=True)
enabled_types = EntryAdapters.get_unique_file_types(user=default_user3).all().values_list("file_type", flat=True)
# Assert
assert list(enabled_types) == ["org"]