mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-25 09:26:17 -05:00
Samba is installed and can be configured in the Controller.
This commit is contained in:
parent
0ceac364ec
commit
ce0cdd3a2e
15 changed files with 837 additions and 5 deletions
55
controller/test/test_samba_api.py
Normal file
55
controller/test/test_samba_api.py
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
"""
|
||||
Integration tests for Controller Samba API endpoints.
|
||||
"""
|
||||
|
||||
|
||||
class TestSambaStatusEndpoint:
|
||||
"""Tests for /api/samba/status endpoint."""
|
||||
|
||||
def test_returns_200(self, test_client):
|
||||
response = test_client.get("/api/samba/status")
|
||||
assert response.status_code == 200
|
||||
|
||||
def test_returns_expected_fields(self, test_client):
|
||||
response = test_client.get("/api/samba/status")
|
||||
data = response.json()
|
||||
assert "enabled" in data
|
||||
assert "available" in data
|
||||
assert "shares" in data
|
||||
|
||||
def test_shows_unavailable_in_docker(self, test_client_docker_mode):
|
||||
response = test_client_docker_mode.get("/api/samba/status")
|
||||
data = response.json()
|
||||
assert data["available"] is False
|
||||
|
||||
|
||||
class TestSambaShareAddEndpoint:
|
||||
"""Tests for POST /api/samba/shares endpoint."""
|
||||
|
||||
def test_rejects_invalid_name(self, test_client):
|
||||
response = test_client.post("/api/samba/shares", json={
|
||||
"name": "bad/name",
|
||||
"path": "/media/wrolpi",
|
||||
})
|
||||
assert response.status_code == 400
|
||||
|
||||
def test_fails_in_docker(self, test_client_docker_mode):
|
||||
response = test_client_docker_mode.post("/api/samba/shares", json={
|
||||
"name": "test",
|
||||
"path": "/media/wrolpi",
|
||||
})
|
||||
assert response.status_code == 400
|
||||
|
||||
|
||||
class TestSambaShareRemoveEndpoint:
|
||||
"""Tests for DELETE /api/samba/shares/{name} endpoint."""
|
||||
|
||||
def test_returns_404_for_missing_share(self, test_client):
|
||||
response = test_client.delete("/api/samba/shares/nonexistent")
|
||||
assert response.status_code == 404
|
||||
|
||||
def test_fails_in_docker(self, test_client_docker_mode):
|
||||
response = test_client_docker_mode.delete("/api/samba/shares/test")
|
||||
assert response.status_code == 404
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue