add capability to restrict remote panel modes
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2026-02-19 15:55:20 +11:00
parent e8153e2953
commit e700239764
9 changed files with 197 additions and 2 deletions

View File

@@ -77,3 +77,21 @@ func TestManagedWriterModeRateLimit(t *testing.T) {
assert.Error(t, err)
assert.Equal(t, 1, base.panelWrites)
}
func TestManagedWriterPanelModeAllowlist(t *testing.T) {
base := &writerStub{}
managed := NewManagedWriter(base, WriterPolicy{
Profile: WriterProfileNormal,
AllowedPanelStates: map[PanelSwitchState]struct{}{
PanelSwitchOff: {},
},
})
err := managed.SetPanelStateWithSource(CommandSourceMQTT, PanelSwitchOn, nil)
assert.Error(t, err)
assert.Equal(t, 0, base.panelWrites)
err = managed.SetPanelStateWithSource(CommandSourceMQTT, PanelSwitchOff, nil)
assert.NoError(t, err)
assert.Equal(t, 1, base.panelWrites)
}