Updated endpoints and tests for users, rbac, health, file, and auth
This commit is contained in:
1 parent
207b8eea5e
commit
d379fbd621
26 files changed
+582
-28
No files matched your search
@@ -1,13 +0,0 @@
|
||||
"""Unit tests for main.py."""
|
||||
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
from app.main import app
|
||||
|
||||
client = TestClient(app)
|
||||
|
||||
|
||||
def test_status_check() -> None:
|
||||
"""Tests that status check returns 200."""
|
||||
response = client.get("/")
|
||||
assert response.status_code == 200
|
||||
Whitespace-only changes.
File renamed without changes.
@@ -0,0 +1,29 @@
|
||||
from app.platform.auth.security import hash_password, verify_password
|
||||
|
||||
PLAIN_TEXT = "TestPassword1"
|
||||
KNOWN_HASH = "$argon2id$v=19$m=65536,t=3,p=4$REsXKPN2FSbZr7WSb3kfwA$tPcCMPWzX7dY4dHudtvStB5+mKnIZMTtV1xRkWo+Jmg"
|
||||
|
||||
|
||||
def test_password_hash() -> None:
|
||||
hashed_password = hash_password(PLAIN_TEXT)
|
||||
assert verify_password(PLAIN_TEXT, hashed_password)
|
||||
|
||||
|
||||
def test_hash_password_does_not_return_plaintext() -> None:
|
||||
assert hash_password(PLAIN_TEXT) != PLAIN_TEXT
|
||||
|
||||
|
||||
def test_hash_password_is_salted() -> None:
|
||||
assert hash_password(PLAIN_TEXT) != hash_password(PLAIN_TEXT)
|
||||
|
||||
|
||||
def test_verify_password_accepts_correct_password() -> None:
|
||||
assert verify_password(PLAIN_TEXT, KNOWN_HASH)
|
||||
|
||||
|
||||
def test_verify_password_rejects_wrong_password() -> None:
|
||||
assert not verify_password("TestPassword2", KNOWN_HASH)
|
||||
|
||||
|
||||
def test_verify_password_is_case_sensitive() -> None:
|
||||
assert not verify_password(PLAIN_TEXT.lower(), KNOWN_HASH)
|
||||
@@ -0,0 +1,21 @@
|
||||
"""Check that file endpoints exists."""
|
||||
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
|
||||
def test_post_upload_file_url_returns_200(client: TestClient) -> None:
|
||||
"""Verifies POST /api/v1/files/upload returns successful Response."""
|
||||
response = client.post("/api/v1/files/upload")
|
||||
assert response.status_code == 200
|
||||
|
||||
|
||||
def test_post_file_download_url_returns_200(client: TestClient) -> None:
|
||||
"""Verifies GET /api/v1/files/{id}/download returns successful Response."""
|
||||
response = client.post("/api/v1/files/123/download")
|
||||
assert response.status_code == 200
|
||||
|
||||
|
||||
def test_post_file_delete_returns_200(client: TestClient) -> None:
|
||||
"""Verifies DELETE /api/v1/files/{id} returns successful Response."""
|
||||
response = client.delete("/api/v1/files/123")
|
||||
assert response.status_code == 200
|
||||
@@ -1,3 +1,15 @@
|
||||
"""Checks Health based API Endpoints."""
|
||||
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
|
||||
def test_get_health_returns_200(client: TestClient) -> None:
|
||||
"""Verifies GET /health returns successful Response."""
|
||||
response = client.get("/health")
|
||||
assert response.status_code == 200
|
||||
|
||||
|
||||
def test_get_ready_returns_200(client: TestClient) -> None:
|
||||
"""Verifies GET /ready returns successful Response."""
|
||||
response = client.get("/ready")
|
||||
assert response.status_code == 200
|
||||
Whitespace-only changes.
Reference in new issue
Block a user