Remove auth references from conftest.py
- Removed expected_password from _reset_state - Removed password field from args_directory/args_zip fixtures - Removed set_auth_password calls from initialized_dir/initialized_zip - Removed _dummy_auth_header function - Removed Authorization headers from client_dir/client_zip fixtures
This commit is contained in:
parent
8a8fff37e0
commit
22bf57f896
6
TODO.md
6
TODO.md
@ -21,9 +21,9 @@ Remove all authentication from the server and convert `order`/`delay` from path
|
|||||||
- [x] Update the play/pause button URLs to use query param format
|
- [x] Update the play/pause button URLs to use query param format
|
||||||
|
|
||||||
### 3. Update `conftest.py`
|
### 3. Update `conftest.py`
|
||||||
- [ ] Remove `_dummy_auth_header` function and `Authorization` header from `client_dir`/`client_zip` fixtures
|
- [x] Remove `_dummy_auth_header` function and `Authorization` header from `client_dir`/`client_zip` fixtures
|
||||||
- [ ] Remove `set_auth_password(None)` calls from `initialized_dir`/`initialized_zip` fixtures
|
- [x] Remove `set_auth_password(None)` calls from `initialized_dir`/`initialized_zip` fixtures
|
||||||
- [ ] Remove `password` field from `args_directory`/`args_zip` fixtures (or keep as None if still in argparse)
|
- [x] Remove `password` field from `args_directory`/`args_zip` fixtures (or keep as None if still in argparse)
|
||||||
|
|
||||||
### 4. Update `test_auth.py`
|
### 4. Update `test_auth.py`
|
||||||
- [ ] Delete the entire `test_auth.py` file (all auth tests are no longer relevant)
|
- [ ] Delete the entire `test_auth.py` file (all auth tests are no longer relevant)
|
||||||
|
|||||||
@ -15,7 +15,6 @@ def _reset_state() -> None:
|
|||||||
"""Reset all global state to defaults."""
|
"""Reset all global state to defaults."""
|
||||||
main.file_mapping.clear()
|
main.file_mapping.clear()
|
||||||
main.indexers.clear()
|
main.indexers.clear()
|
||||||
main.expected_password = None
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
@ -83,7 +82,6 @@ def args_directory(sample_files: dict[str, Path], tmp_path: Path) -> argparse.Na
|
|||||||
host="127.0.0.1",
|
host="127.0.0.1",
|
||||||
port=0,
|
port=0,
|
||||||
salt="test-salt",
|
salt="test-salt",
|
||||||
password=None,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -95,51 +93,32 @@ def args_zip(sample_zip: dict[str, Path], tmp_path: Path) -> argparse.Namespace:
|
|||||||
host="127.0.0.1",
|
host="127.0.0.1",
|
||||||
port=0,
|
port=0,
|
||||||
salt="test-salt",
|
salt="test-salt",
|
||||||
password=None,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def initialized_dir(args_directory: argparse.Namespace) -> None:
|
def initialized_dir(args_directory: argparse.Namespace) -> None:
|
||||||
"""Initialize the server with sample directory files (no auth)."""
|
"""Initialize the server with sample directory files."""
|
||||||
main.initialize_server(args_directory)
|
main.initialize_server(args_directory)
|
||||||
main.set_auth_password(None)
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def initialized_zip(args_zip: argparse.Namespace) -> None:
|
def initialized_zip(args_zip: argparse.Namespace) -> None:
|
||||||
"""Initialize the server with sample zip files (no auth)."""
|
"""Initialize the server with sample zip files."""
|
||||||
main.initialize_server(args_zip)
|
main.initialize_server(args_zip)
|
||||||
main.set_auth_password(None)
|
|
||||||
|
|
||||||
|
|
||||||
def _dummy_auth_header() -> str:
|
|
||||||
"""Create a dummy Basic Auth header (any creds work when no password is set)."""
|
|
||||||
import base64
|
|
||||||
|
|
||||||
creds = "test:test"
|
|
||||||
return f"Basic {base64.b64encode(creds.encode()).decode()}"
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
async def client_dir(initialized_dir: None) -> Generator[AsyncClient, None, None]:
|
async def client_dir(initialized_dir: None) -> Generator[AsyncClient, None, None]:
|
||||||
"""Async HTTP client against the app initialized with directory files.
|
"""Async HTTP client against the app initialized with directory files."""
|
||||||
|
|
||||||
Sends dummy auth headers since HTTPBasic() always requires them.
|
|
||||||
"""
|
|
||||||
transport = ASGITransport(app=main.app)
|
transport = ASGITransport(app=main.app)
|
||||||
async with AsyncClient(transport=transport, base_url="http://test") as ac:
|
async with AsyncClient(transport=transport, base_url="http://test") as ac:
|
||||||
ac.headers["Authorization"] = _dummy_auth_header()
|
|
||||||
yield ac
|
yield ac
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
async def client_zip(initialized_zip: None) -> Generator[AsyncClient, None, None]:
|
async def client_zip(initialized_zip: None) -> Generator[AsyncClient, None, None]:
|
||||||
"""Async HTTP client against the app initialized with zip files.
|
"""Async HTTP client against the app initialized with zip files."""
|
||||||
|
|
||||||
Sends dummy auth headers since HTTPBasic() always requires them.
|
|
||||||
"""
|
|
||||||
transport = ASGITransport(app=main.app)
|
transport = ASGITransport(app=main.app)
|
||||||
async with AsyncClient(transport=transport, base_url="http://test") as ac:
|
async with AsyncClient(transport=transport, base_url="http://test") as ac:
|
||||||
ac.headers["Authorization"] = _dummy_auth_header()
|
|
||||||
yield ac
|
yield ac
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user