feat: add read-only mode to API and UI, disable write actions

This commit is contained in:
Sergey Krashevich
2026-02-01 04:13:43 +03:00
parent 6085c8aabe
commit cc453dd9ed
24 changed files with 438 additions and 8 deletions
+29
View File
@@ -0,0 +1,29 @@
package app
import (
"os"
"path/filepath"
"testing"
"github.com/stretchr/testify/require"
)
func TestPatchConfigReadOnly(t *testing.T) {
prevPath := ConfigPath
prevReadOnly := ConfigReadOnly
t.Cleanup(func() {
ConfigPath = prevPath
ConfigReadOnly = prevReadOnly
})
dir := t.TempDir()
path := filepath.Join(dir, "config.yaml")
require.NoError(t, os.WriteFile(path, []byte(""), 0644))
ConfigPath = path
ConfigReadOnly = true
err := PatchConfig([]string{"streams", "cam"}, "rtsp://example.com")
require.Error(t, err)
require.EqualError(t, err, "config is read-only")
}