Skip to content

Commit 05f43ab

Browse files
authored
Update test_api.py
1 parent 7cdbd73 commit 05f43ab

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

‎tests/test_api.py‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,18 @@ def test_bad_name_rejected(self, client: TestClient, auth_headers: dict) -> None
173173
)
174174
assert res.status_code == 422
175175

176+
def test_body_name_must_match_path(self, client: TestClient, auth_headers: dict) -> None:
177+
"""Otherwise the write would land on a different secret than the
178+
URL names."""
179+
res = client.put(
180+
"/secrets/WANTED",
181+
json={"name": "OTHER", "value": "v"},
182+
headers=auth_headers,
183+
)
184+
assert res.status_code == 400, res.text
185+
assert res.json()["detail"] == "name mismatch with path"
186+
assert client.get("/secrets", headers=auth_headers).json() == []
187+
176188
def test_isolated_per_user(self, client: TestClient) -> None:
177189
t1 = client.post(
178190
"/auth/register", json={"email": "s1@example.com", "password": "password-1"}

0 commit comments

Comments
 (0)