mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-11-14 05:20:21 +00:00
Fix mypy issues in store, utils and all other source files (#5957)
* Fix mypy issues in store module * Fix mypy issues in utils module * Fix mypy issues in all remaining source files * Fix ingress user typeddict * Fixes from feedback * Fix mypy issues after installing docker-types
This commit is contained in:
@@ -119,16 +119,45 @@ async def test_list_users(
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("api_client", [TEST_ADDON_SLUG], indirect=True)
|
||||
@pytest.mark.parametrize(
|
||||
("field", "api_client"),
|
||||
[("username", TEST_ADDON_SLUG), ("user", TEST_ADDON_SLUG)],
|
||||
indirect=["api_client"],
|
||||
)
|
||||
async def test_auth_json_success(
|
||||
api_client: TestClient, mock_check_login: AsyncMock, install_addon_ssh: Addon
|
||||
api_client: TestClient,
|
||||
mock_check_login: AsyncMock,
|
||||
install_addon_ssh: Addon,
|
||||
field: str,
|
||||
):
|
||||
"""Test successful JSON auth."""
|
||||
mock_check_login.return_value = True
|
||||
resp = await api_client.post("/auth", json={"username": "test", "password": "pass"})
|
||||
resp = await api_client.post("/auth", json={field: "test", "password": "pass"})
|
||||
assert resp.status == 200
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("user", "password", "message", "api_client"),
|
||||
[
|
||||
(None, "password", "None as username is not supported!", TEST_ADDON_SLUG),
|
||||
("user", None, "None as password is not supported!", TEST_ADDON_SLUG),
|
||||
],
|
||||
indirect=["api_client"],
|
||||
)
|
||||
async def test_auth_json_failure_none(
|
||||
api_client: TestClient,
|
||||
install_addon_ssh: Addon,
|
||||
user: str | None,
|
||||
password: str | None,
|
||||
message: str,
|
||||
):
|
||||
"""Test failed JSON auth with none user or password."""
|
||||
resp = await api_client.post("/auth", json={"username": user, "password": password})
|
||||
assert resp.status == 400
|
||||
body = await resp.json()
|
||||
assert body["message"] == message
|
||||
|
||||
|
||||
@pytest.mark.parametrize("api_client", [TEST_ADDON_SLUG], indirect=True)
|
||||
async def test_auth_json_invalid_credentials(
|
||||
api_client: TestClient, mock_check_login: AsyncMock, install_addon_ssh: Addon
|
||||
|
||||
Reference in New Issue
Block a user