Files
ai_site/platform/internal/handler/agent_online_acl_test.go
whm bb59bb5efd fix: allow agent JWT to use attached online_db_id (Z14c)
Agent tokens use agent_id as user_id while Binding is under the human member; authorize schema/push/ensure against the agent's mounted OnlineDBID.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-05 18:22:57 +08:00

21 lines
525 B
Go

package handler
import (
"context"
"net/http"
"net/http/httptest"
"testing"
"aijianzhan/platform/internal/authx"
)
func TestAgentOwnsOnlineDBUsesContextAgent(t *testing.T) {
// 无 Agents store 时必须安全返回 false
r := httptest.NewRequest(http.MethodPost, "/", nil)
ctx := authx.WithFullClaims(context.Background(), 2, 99, authx.Role智能体, 99, 0, []string{authx.Perm数据同步})
r = r.WithContext(ctx)
if agentOwnsOnlineDB(nil, r, 2, "ch1", "ch1_u3") {
t.Fatal("expected false without svc")
}
}