mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-12-05 06:09:57 -05:00
Controller: hide Root CA download until drive is ready
During onboarding the media drive is not mounted and ca.crt does not exist yet (or still holds only a throwaway pre-drive state). The cert banner still offered Download WROLPi Root CA, which 404'd. Gate the button and HTTPS cert-setup banner on drive mounted, ca.crt present, and repair not running so an existing CA on the drive can be served after mount/repair.
This commit is contained in:
parent
a3a712ead1
commit
46ba804a1b
5 changed files with 161 additions and 7 deletions
|
|
@ -7,8 +7,10 @@ import pytest
|
|||
import yaml
|
||||
|
||||
from controller.lib.config import (
|
||||
get_ca_certificate_path,
|
||||
get_config,
|
||||
get_config_value,
|
||||
is_ca_certificate_available,
|
||||
is_docker_mode,
|
||||
is_primary_drive_mounted,
|
||||
reload_config_from_drive,
|
||||
|
|
@ -100,6 +102,41 @@ class TestIsPrimaryDriveMounted:
|
|||
assert is_primary_drive_mounted() is False
|
||||
|
||||
|
||||
class TestCaCertificateAvailable:
|
||||
"""Tests for is_ca_certificate_available / get_ca_certificate_path."""
|
||||
|
||||
def test_false_when_drive_not_mounted(self, mock_drive_not_mounted, tmp_path, monkeypatch):
|
||||
"""Native mode without drive mounted should not advertise a CA."""
|
||||
monkeypatch.setenv("MEDIA_DIRECTORY", str(tmp_path))
|
||||
ca = tmp_path / "config" / "ssl" / "ca.crt"
|
||||
ca.parent.mkdir(parents=True)
|
||||
ca.write_text("fake-cert")
|
||||
assert is_ca_certificate_available() is False
|
||||
|
||||
def test_false_when_drive_mounted_but_ca_missing(self, mock_drive_mounted, tmp_path, monkeypatch):
|
||||
"""Mounted drive without ca.crt is not ready."""
|
||||
monkeypatch.setenv("MEDIA_DIRECTORY", str(tmp_path))
|
||||
assert is_ca_certificate_available() is False
|
||||
|
||||
def test_true_when_drive_mounted_and_ca_exists(self, mock_drive_mounted, tmp_path, monkeypatch):
|
||||
"""Mounted drive with ca.crt is ready."""
|
||||
monkeypatch.setenv("MEDIA_DIRECTORY", str(tmp_path))
|
||||
ca = get_ca_certificate_path()
|
||||
ca.parent.mkdir(parents=True)
|
||||
ca.write_text("fake-cert")
|
||||
assert is_ca_certificate_available() is True
|
||||
|
||||
def test_true_in_docker_when_ca_exists_without_drive_mount(
|
||||
self, mock_docker_mode_enabled, mock_drive_not_mounted, tmp_path, monkeypatch
|
||||
):
|
||||
"""Docker media volume can serve CA without native drive-mount check."""
|
||||
monkeypatch.setenv("MEDIA_DIRECTORY", str(tmp_path))
|
||||
ca = get_ca_certificate_path()
|
||||
ca.parent.mkdir(parents=True)
|
||||
ca.write_text("fake-cert")
|
||||
assert is_ca_certificate_available() is True
|
||||
|
||||
|
||||
class TestReloadConfigFromDrive:
|
||||
"""Tests for reload_config_from_drive function."""
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue