Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

fix: align ChatChannel permission tests (#22107)

buua43661c46bf6223a
diff --git a/internal/service/chat_channel_agent_test.go b/internal/service/chat_channel_agent_test.go
index d14a202e46..21dfe42cfc 100644
--- a/internal/service/chat_channel_agent_test.go
+++ b/internal/service/chat_channel_agent_test.go
@@ -71,7 +71,7 @@ func TestChatChannelRejectsCrossTenantBindingAndExecution(t *testing.T) {
createServiceTestChannel(t, db, &entity.ChatChannel{
ID: "historical", TenantID: "other", Channel: "telegram", Config: entity.JSONMap{}, ChatID: new("private"), Status: 1,
})
- if _, err := svc.HandleIncomingMessage(t.Context(), ChatChannelIncomingMessage{AccountID: "historical", ChatID: "external", Text: "hello"}, nil); !errors.Is(err, permission.ErrPermissionDenied) {
+ if _, err := svc.HandleIncomingMessage(t.Context(), ChatChannelIncomingMessage{AccountID: "historical", ChatID: "external", Text: "hello"}, nil); !isAccessDeniedOrHidden(err) {
t.Fatalf("historical unauthorized binding: %v", err)
}
}
@@ -83,6 +83,7 @@ func TestChatChannelAgentRevokedAccess(t *testing.T) {
if err := db.Create(agent).Error; err != nil {
t.Fatal(err)
}
+ grantServiceTestResource(t, "owner", "canvas", "shared", "owner", testResourcePermissionRead)
svc := NewChatChannelService()
channel, err := svc.CreateChatChannel(ctx, "channel", "telegram", entity.JSONMap{}, nil, new("shared"))
if err != nil {
@@ -91,6 +92,7 @@ func TestChatChannelAgentRevokedAccess(t *testing.T) {
if err := db.Model(agent).Update("permission", string(entity.TenantPermissionMe)).Error; err != nil {
t.Fatal(err)
}
+ revokeServiceTestResource(t, "owner", "canvas", "shared", "owner")
svc.agentRunner = channelAgentRunnerFunc(func(context.Context, string, string, string, any, []map[string]any) (<-chan canvas.RunEvent, error) {
t.Fatal("revoked workflow must not execute")
return nil, nil
diff --git a/internal/service/test_helpers_stub_test.go b/internal/service/test_helpers_stub_test.go
index 1298f7a54e..6c3785d960 100644
--- a/internal/service/test_helpers_stub_test.go
+++ b/internal/service/test_helpers_stub_test.go
@@ -26,6 +26,8 @@ import "testing"
func grantServiceTestResource(_ *testing.T, _ string, _ string, _ string, _ string, _ int32) {
}
+func revokeServiceTestResource(_ *testing.T, _ string, _ string, _ string, _ string) {}
+
// permissionChangeLogTestModels adds no tables: the community edition has no
// permission audit log. It lives here for the same reason as the helper above.
func permissionChangeLogTestModels() []interface{} { return nil }