mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-10-13 00:34:43 +00:00
test: require settings:write for ai patrol autonomy update
This commit is contained in:
parent
32426aa6ca
commit
83311cdf8c
1 changed files with 18 additions and 0 deletions
|
|
@ -846,6 +846,24 @@ func TestAIPatrolAutonomyRequiresSettingsWriteScope(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestAIPatrolAutonomyUpdateRequiresSettingsWriteScope(t *testing.T) {
|
||||
rawToken := "ai-patrol-autonomy-update-token-123.12345678"
|
||||
record := newTokenRecord(t, rawToken, []string{config.ScopeSettingsRead}, nil)
|
||||
cfg := newTestConfigWithTokens(t, record)
|
||||
router := NewRouter(cfg, nil, nil, nil, nil, "1.0.0")
|
||||
|
||||
req := httptest.NewRequest(http.MethodPut, "/api/ai/patrol/autonomy", strings.NewReader(`{}`))
|
||||
req.Header.Set("X-API-Token", rawToken)
|
||||
rec := httptest.NewRecorder()
|
||||
router.Handler().ServeHTTP(rec, req)
|
||||
if rec.Code != http.StatusForbidden {
|
||||
t.Fatalf("expected 403 for missing settings:write scope, got %d", rec.Code)
|
||||
}
|
||||
if !strings.Contains(rec.Body.String(), config.ScopeSettingsWrite) {
|
||||
t.Fatalf("expected missing scope response to mention %q, got %q", config.ScopeSettingsWrite, rec.Body.String())
|
||||
}
|
||||
}
|
||||
|
||||
func TestAIExecuteReadEndpointsRequireAIExecuteScope(t *testing.T) {
|
||||
rawToken := "ai-exec-read-token-123.12345678"
|
||||
record := newTokenRecord(t, rawToken, []string{config.ScopeAIChat}, nil)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue