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>
21 lines
525 B
Go
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")
|
|
}
|
|
}
|