Encrypt and decrypt supervisor.tar in backup rewrites (#182220)

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
Stefan Agner
2026-09-18 10:26:15 +00:00
committed by Franck Nijhof
co-authored by Claude Fable 5.1
parent 7d87c2b459
commit 15042a8cb6
4 changed files with 32 additions and 7 deletions
+2 -1
View File
@@ -213,7 +213,8 @@ def validate_password_stream(
def _get_expected_archives(backup: AgentBackup) -> set[str]:
"""Get the expected archives in the backup."""
expected_archives = set()
# Supervisor specific config, not in the metadata (since Supervisor 2026.03.3)
expected_archives = {"supervisor"}
if backup.homeassistant_included:
expected_archives.add("homeassistant")
for addon in backup.addons:
+30 -6
View File
@@ -307,7 +307,7 @@ def test_validate_password_no_homeassistant(caplog: pytest.LogCaptureFixture) ->
@pytest.mark.parametrize(
("addons", "padding_size", "decrypted_backup"),
("addons", "padding_size", "encrypted_backup", "decrypted_backup"),
[
(
[
@@ -315,6 +315,7 @@ def test_validate_password_no_homeassistant(caplog: pytest.LogCaptureFixture) ->
AddonInfo(name="Core 2", slug="core2", version="1.0.0"),
],
51200, # 5 x 10240 byte of padding
"test_backups/c0cb53bd.tar",
"test_backups/c0cb53bd.tar.decrypted",
),
(
@@ -322,19 +323,31 @@ def test_validate_password_no_homeassistant(caplog: pytest.LogCaptureFixture) ->
AddonInfo(name="Core 1", slug="core1", version="1.0.0"),
],
40960, # 4 x 10240 byte of padding
"test_backups/c0cb53bd.tar",
"test_backups/c0cb53bd.tar.decrypted_skip_core2",
),
# supervisor.tar.gz is not in the backup metadata but must be decrypted
(
[
AddonInfo(name="Core 1", slug="core1", version="1.0.0"),
AddonInfo(name="Core 2", slug="core2", version="1.0.0"),
],
51200, # 5 x 10240 byte of padding
"test_backups/c0cb53bd_supervisor.tar.encrypted_v3",
"test_backups/c0cb53bd_supervisor.tar.decrypted",
),
],
)
async def test_decrypted_backup_streamer(
hass: HomeAssistant,
addons: list[AddonInfo],
padding_size: int,
encrypted_backup: str,
decrypted_backup: str,
) -> None:
"""Test the decrypted backup streamer."""
decrypted_backup_path = get_fixture_path(decrypted_backup, DOMAIN)
encrypted_backup_path = get_fixture_path("test_backups/c0cb53bd.tar", DOMAIN)
encrypted_backup_path = get_fixture_path(encrypted_backup, DOMAIN)
backup = AgentBackup(
addons=addons,
backup_id="1234",
@@ -485,7 +498,7 @@ async def test_decrypted_backup_streamer_wrong_password(hass: HomeAssistant) ->
@pytest.mark.parametrize(
("addons", "padding_size", "encrypted_backup"),
("addons", "padding_size", "decrypted_backup", "encrypted_backup"),
[
(
[
@@ -493,6 +506,7 @@ async def test_decrypted_backup_streamer_wrong_password(hass: HomeAssistant) ->
AddonInfo(name="Core 2", slug="core2", version="1.0.0"),
],
51200, # 5 x 10240 byte of padding
"test_backups/c0cb53bd.tar.decrypted",
"test_backups/c0cb53bd.tar.encrypted_v3",
),
(
@@ -500,20 +514,30 @@ async def test_decrypted_backup_streamer_wrong_password(hass: HomeAssistant) ->
AddonInfo(name="Core 1", slug="core1", version="1.0.0"),
],
40960, # 4 x 10240 byte of padding
"test_backups/c0cb53bd.tar.decrypted",
"test_backups/c0cb53bd.tar.encrypted_v3_skip_core2",
),
# supervisor.tar.gz is not in the backup metadata but must be encrypted
(
[
AddonInfo(name="Core 1", slug="core1", version="1.0.0"),
AddonInfo(name="Core 2", slug="core2", version="1.0.0"),
],
51200, # 5 x 10240 byte of padding
"test_backups/c0cb53bd_supervisor.tar.decrypted",
"test_backups/c0cb53bd_supervisor.tar.encrypted_v3",
),
],
)
async def test_encrypted_backup_streamer(
hass: HomeAssistant,
addons: list[AddonInfo],
padding_size: int,
decrypted_backup: str,
encrypted_backup: str,
) -> None:
"""Test the encrypted backup streamer."""
decrypted_backup_path = get_fixture_path(
"test_backups/c0cb53bd.tar.decrypted", DOMAIN
)
decrypted_backup_path = get_fixture_path(decrypted_backup, DOMAIN)
encrypted_backup_path = get_fixture_path(encrypted_backup, DOMAIN)
backup = AgentBackup(
addons=addons,