Try to manually change settings in test

This commit is contained in:
shamoon 2024-05-15 10:27:09 -07:00
parent f62d4da35a
commit 113c7fea3a
2 changed files with 10 additions and 6 deletions

View File

@ -55,12 +55,6 @@ class HttpRemoteUserMiddleware(PersistentRemoteUserMiddleware):
def process_request(self, request: HttpRequest) -> None:
# If remote user auth is enabled only for the frontend, not the API,
# then we need dont want to authenticate the user for API requests.
logger.debug(
request.path,
)
logger.debug(
settings.REST_FRAMEWORK["DEFAULT_AUTHENTICATION_CLASSES"],
)
if (
"/api/" in request.path
and "paperless.auth.PaperlessRemoteUserAuthentication"

View File

@ -107,6 +107,16 @@ class TestRemoteUser(DirectoriesMixin, APITestCase):
},
):
_parse_remote_user_settings()
from django.conf import settings
# Only needed in testing (on ci?), in production this is handled in the settings
if (
"paperless.auth.PaperlessRemoteUserAuthentication"
in settings.REST_FRAMEWORK["DEFAULT_AUTHENTICATION_CLASSES"]
):
settings.REST_FRAMEWORK["DEFAULT_AUTHENTICATION_CLASSES"].remove(
"paperless.auth.PaperlessRemoteUserAuthentication",
)
response = self.client.get(
"/api/documents/",