mirror of
https://github.com/tiennm99/DocsGPT.git
synced 2026-10-15 22:14:46 +00:00
patch: key
This commit is contained in:
1 parent
249dd9ce37
commit
6b6495f48c
3 files changed
+67
-15
No files matched your search
@@ -2105,23 +2105,35 @@ class TestInternalRoutes:
|
||||
app.register_blueprint(internal)
|
||||
return app
|
||||
|
||||
_TEST_KEY = "test-key"
|
||||
_AUTH_HEADERS = {"X-Internal-Key": "test-key"}
|
||||
|
||||
def test_upload_index_no_user(self, app):
|
||||
with app.test_client() as client:
|
||||
with patch(
|
||||
"application.api.internal.routes.settings"
|
||||
) as ms:
|
||||
ms.INTERNAL_KEY = None
|
||||
resp = client.post("/api/upload_index")
|
||||
ms.INTERNAL_KEY = self._TEST_KEY
|
||||
resp = client.post("/api/upload_index", headers=self._AUTH_HEADERS)
|
||||
assert resp.get_json()["status"] == "no user"
|
||||
|
||||
def test_upload_index_no_name(self, app):
|
||||
with app.test_client() as client:
|
||||
with patch(
|
||||
"application.api.internal.routes.settings"
|
||||
) as ms:
|
||||
ms.INTERNAL_KEY = self._TEST_KEY
|
||||
resp = client.post("/api/upload_index", data={"user": "u1"}, headers=self._AUTH_HEADERS)
|
||||
assert resp.get_json()["status"] == "no name"
|
||||
|
||||
def test_upload_index_rejected_without_internal_key(self, app):
|
||||
with app.test_client() as client:
|
||||
with patch(
|
||||
"application.api.internal.routes.settings"
|
||||
) as ms:
|
||||
ms.INTERNAL_KEY = None
|
||||
resp = client.post("/api/upload_index", data={"user": "u1"})
|
||||
assert resp.get_json()["status"] == "no name"
|
||||
assert resp.status_code == 401
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
Reference in new issue
Block a user