- Introduced a new test suite for the PlaylistService covering various functionalities including creation, retrieval, updating, and deletion of playlists. - Added tests for handling sounds within playlists, ensuring correct behavior when adding/removing sounds and managing current playlists. - Refactored socket service tests for improved readability by adjusting function signatures. - Cleaned up unnecessary whitespace in sound normalizer and sound scanner tests for consistency. - Enhanced audio utility tests to ensure accurate hash and size calculations, including edge cases for nonexistent files. - Removed redundant blank lines in cookie utility tests for cleaner code.
23 lines
667 B
Python
23 lines
667 B
Python
"""Cookie parsing utilities for WebSocket authentication."""
|
|
|
|
|
|
def parse_cookies(cookie_header: str) -> dict[str, str]:
|
|
"""Parse HTTP cookie header into a dictionary."""
|
|
cookies = {}
|
|
if not cookie_header:
|
|
return cookies
|
|
|
|
for cookie in cookie_header.split(";"):
|
|
cookie = cookie.strip()
|
|
if "=" in cookie:
|
|
name, value = cookie.split("=", 1)
|
|
cookies[name.strip()] = value.strip()
|
|
|
|
return cookies
|
|
|
|
|
|
def extract_access_token_from_cookies(cookie_header: str) -> str | None:
|
|
"""Extract access token from HTTP cookies."""
|
|
cookies = parse_cookies(cookie_header)
|
|
return cookies.get("access_token")
|