Skip to content

Commit

Permalink
fix(backend): add "doc" to forbidden names
Browse files Browse the repository at this point in the history
  • Loading branch information
stevapple committed Oct 25, 2024
1 parent cbf8f6a commit ec0bdea
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docat/docat/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def is_forbidden_project_name(name: str) -> bool:
a page on the docat website.
"""
name = name.lower().strip()
return name in ["upload", "claim", "delete", "help"]
return name in ["upload", "claim", "delete", "help", "doc"]


UNITS_MAPPING = [
Expand Down
2 changes: 1 addition & 1 deletion docat/tests/test_rename.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def test_rename_rejects_forbidden_project_name(client_with_claimed_project):
assert create_response.status_code == 201

with patch("os.rename") as rename_mock:
for project_name in ["upload", "claim", "Delete ", "help"]:
for project_name in ["upload", "claim", "Delete ", "help", "Doc"]:
rename_response = client_with_claimed_project.put(f"/api/some-project/rename/{project_name}", headers={"Docat-Api-Key": "1234"})
assert rename_response.status_code == 400
assert rename_response.json() == {
Expand Down
2 changes: 1 addition & 1 deletion docat/tests/test_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def test_upload_rejects_forbidden_project_name(client_with_claimed_project):
"""

with patch("docat.app.remove_docs") as remove_mock:
for project_name in ["upload", "claim", " Delete ", "help"]:
for project_name in ["upload", "claim", " Delete ", "help", "DOC"]:
response = client_with_claimed_project.post(
f"/api/{project_name}/1.0.0", files={"file": ("index.html", io.BytesIO(b"<h1>Hello World</h1>"), "plain/text")}
)
Expand Down

0 comments on commit ec0bdea

Please sign in to comment.