Skip to content

Commit 6dd1057

Browse files
authored
Assert not authenticated 401 (#3318)
1 parent 0f28c92 commit 6dd1057

File tree

6 files changed

+17
-17
lines changed

6 files changed

+17
-17
lines changed

src/tests/_internal/server/routers/test_files.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ async def test_returns_403_if_not_authenticated(self, client: AsyncClient):
2727
"/api/files/get_archive_by_hash",
2828
json={"hash": "blob_hash"},
2929
)
30-
assert response.status_code == 403
30+
assert response.status_code in [401, 403]
3131

3232
async def test_returns_400_if_archive_does_not_exist(
3333
self, session: AsyncSession, client: AsyncClient
@@ -81,7 +81,7 @@ async def test_returns_403_if_not_authenticated(self, client: AsyncClient):
8181
"/api/files/upload_archive",
8282
files={"file": self.file},
8383
)
84-
assert response.status_code == 403
84+
assert response.status_code in [401, 403]
8585

8686
async def test_returns_existing_archive(
8787
self, session: AsyncSession, client: AsyncClient, default_storage_mock: Mock

src/tests/_internal/server/routers/test_fleets.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ async def test_returns_40x_if_not_authenticated(
5858
self, test_db, session: AsyncSession, client: AsyncClient
5959
):
6060
response = await client.post("/api/fleets/list")
61-
assert response.status_code == 403
61+
assert response.status_code in [401, 403]
6262

6363
@pytest.mark.asyncio
6464
@pytest.mark.parametrize("test_db", ["sqlite", "postgres"], indirect=True)
@@ -147,7 +147,7 @@ async def test_returns_40x_if_not_authenticated(
147147
self, test_db, session: AsyncSession, client: AsyncClient
148148
):
149149
response = await client.post("/api/project/main/fleets/list")
150-
assert response.status_code == 403
150+
assert response.status_code in [401, 403]
151151

152152
@pytest.mark.asyncio
153153
@pytest.mark.parametrize("test_db", ["sqlite", "postgres"], indirect=True)
@@ -188,7 +188,7 @@ async def test_returns_40x_if_not_authenticated(
188188
self, test_db, session: AsyncSession, client: AsyncClient
189189
):
190190
response = await client.post("/api/project/main/fleets/get")
191-
assert response.status_code == 403
191+
assert response.status_code in [401, 403]
192192

193193
@pytest.mark.asyncio
194194
@pytest.mark.parametrize("test_db", ["sqlite", "postgres"], indirect=True)
@@ -309,7 +309,7 @@ async def test_returns_40x_if_not_authenticated(
309309
self, test_db, session: AsyncSession, client: AsyncClient
310310
):
311311
response = await client.post("/api/project/main/fleets/apply")
312-
assert response.status_code == 403
312+
assert response.status_code in [401, 403]
313313

314314
@pytest.mark.asyncio
315315
@pytest.mark.parametrize("test_db", ["sqlite", "postgres"], indirect=True)
@@ -829,7 +829,7 @@ async def test_returns_40x_if_not_authenticated(
829829
self, test_db, session: AsyncSession, client: AsyncClient
830830
):
831831
response = await client.post("/api/project/main/fleets/delete")
832-
assert response.status_code == 403
832+
assert response.status_code in [401, 403]
833833

834834
@pytest.mark.asyncio
835835
@pytest.mark.parametrize("test_db", ["sqlite", "postgres"], indirect=True)
@@ -942,7 +942,7 @@ async def test_returns_40x_if_not_authenticated(
942942
self, test_db, session: AsyncSession, client: AsyncClient
943943
):
944944
response = await client.post("/api/project/main/fleets/delete_instances")
945-
assert response.status_code == 403
945+
assert response.status_code in [401, 403]
946946

947947
@pytest.mark.asyncio
948948
@pytest.mark.parametrize("test_db", ["sqlite", "postgres"], indirect=True)
@@ -1036,7 +1036,7 @@ async def test_returns_40x_if_not_authenticated(
10361036
self, test_db, session: AsyncSession, client: AsyncClient
10371037
):
10381038
response = await client.post("/api/project/main/fleets/get_plan")
1039-
assert response.status_code == 403
1039+
assert response.status_code in [401, 403]
10401040

10411041
@pytest.mark.asyncio
10421042
@pytest.mark.parametrize("test_db", ["sqlite", "postgres"], indirect=True)

src/tests/_internal/server/routers/test_gateways.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ async def test_returns_40x_if_not_authenticated(
2626
self, test_db, session: AsyncSession, client: AsyncClient
2727
):
2828
response = await client.post("/api/project/main/gateways/list")
29-
assert response.status_code == 403
29+
assert response.status_code in [401, 403]
3030

3131
@pytest.mark.asyncio
3232
@pytest.mark.parametrize("test_db", ["sqlite", "postgres"], indirect=True)

src/tests/_internal/server/routers/test_instances.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ async def test_pagination(
265265

266266
async def test_not_authenticated(self, client: AsyncClient, data) -> None:
267267
resp = await client.post("/api/instances/list", json={})
268-
assert resp.status_code == 403
268+
assert resp.status_code in [401, 403]
269269

270270

271271
@pytest.mark.asyncio

src/tests/_internal/server/routers/test_prometheus.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ async def test_returns_403_if_not_authenticated(
375375
else:
376376
headers = None
377377
response = await client.get("/metrics", headers=headers)
378-
assert response.status_code == 403
378+
assert response.status_code in [401, 403]
379379

380380
async def test_returns_200_if_token_is_valid(
381381
self, monkeypatch: pytest.MonkeyPatch, client: AsyncClient

src/tests/_internal/server/routers/test_volumes.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ async def test_returns_40x_if_not_authenticated(
3232
self, test_db, session: AsyncSession, client: AsyncClient
3333
):
3434
response = await client.post("/api/volumes/list")
35-
assert response.status_code == 403
35+
assert response.status_code in [401, 403]
3636

3737
@pytest.mark.asyncio
3838
@pytest.mark.parametrize("test_db", ["sqlite", "postgres"], indirect=True)
@@ -198,7 +198,7 @@ async def test_returns_40x_if_not_authenticated(
198198
self, test_db, session: AsyncSession, client: AsyncClient
199199
):
200200
response = await client.post("/api/project/main/volumes/list")
201-
assert response.status_code == 403
201+
assert response.status_code in [401, 403]
202202

203203
@pytest.mark.asyncio
204204
@pytest.mark.parametrize("test_db", ["sqlite", "postgres"], indirect=True)
@@ -249,7 +249,7 @@ async def test_returns_40x_if_not_authenticated(
249249
self, test_db, session: AsyncSession, client: AsyncClient
250250
):
251251
response = await client.post("/api/project/main/volumes/get")
252-
assert response.status_code == 403
252+
assert response.status_code in [401, 403]
253253

254254
@pytest.mark.asyncio
255255
@pytest.mark.parametrize("test_db", ["sqlite", "postgres"], indirect=True)
@@ -316,7 +316,7 @@ async def test_returns_40x_if_not_authenticated(
316316
self, test_db, session: AsyncSession, client: AsyncClient
317317
):
318318
response = await client.post("/api/project/main/volumes/create")
319-
assert response.status_code == 403
319+
assert response.status_code in [401, 403]
320320

321321
@pytest.mark.asyncio
322322
@pytest.mark.parametrize("test_db", ["sqlite", "postgres"], indirect=True)
@@ -366,7 +366,7 @@ async def test_returns_40x_if_not_authenticated(
366366
self, test_db, session: AsyncSession, client: AsyncClient
367367
):
368368
response = await client.post("/api/project/main/volumes/delete")
369-
assert response.status_code == 403
369+
assert response.status_code in [401, 403]
370370

371371
@pytest.mark.asyncio
372372
@pytest.mark.parametrize("test_db", ["sqlite", "postgres"], indirect=True)

0 commit comments

Comments
 (0)