Open-source LLM knowledge platform: turn raw documents into a queryable RAG, an autonomous reasoning agent, and a self-maintaining Wiki.
Go agentagenticaichatbotdsh-pluginembeddingsevaluationgenerative-aigolangknowledge-basellmmulti-tenantollamaopenaiquestion-answeringragrerankingsemantic-searchvector-searchwiki
test: address PR review follow-ups for OAuth and logger cleanup
wizardchenc694fcf6cd61
diff --git a/frontend/src/views/embed/EmbedChatCore.vue b/frontend/src/views/embed/EmbedChatCore.vueindex 7e64a735c..96f8d1308 100644--- a/frontend/src/views/embed/EmbedChatCore.vue+++ b/frontend/src/views/embed/EmbedChatCore.vue@@ -47,13 +47,13 @@class="msg-item-wrapper"><div v-if="session.role === 'user'">- <EmbedUserMessage- :content="String(session.content || '')"- :mentioned_items="asUnknownArray(session.mentioned_items)"- :images="asEmbedImages(session.images)"- :attachments="asEmbedAttachments(session.attachments)"- :embeddedMode="true"- :embed-channel-id="channelId"+ <EmbedUserMessage+ :content="String(session.content || '')"+ :mentioned_items="asUnknownArray(session.mentioned_items)"+ :images="asEmbedImages(session.images)"+ :attachments="asEmbedAttachments(session.attachments)"+ :embeddedMode="true"+ :embed-channel-id="channelId":embed-token="token"/></div>diff --git a/internal/datasource/connector/yuque/client_test.go b/internal/datasource/connector/yuque/client_test.goindex 008c3218c..60fb06a00 100644--- a/internal/datasource/connector/yuque/client_test.go+++ b/internal/datasource/connector/yuque/client_test.go@@ -118,7 +118,7 @@ func TestClient_Ping_403WrapsInvalidCredentials(t *testing.T) {func TestClient_TokenNeverLoggedInFull(t *testing.T) {t.Setenv("LOG_FORMAT", "")logger.ConfigureFromEnv()- defer logger.ConfigureFromEnv()+ t.Cleanup(func() { logger.ConfigureFromEnv() })// Redirect the project's internal logger to an in-memory buffer so we can// assert the raw token never appears in log output. Using stdlib `log`diff --git a/internal/im/identity_test.go b/internal/im/identity_test.goindex 43ba7a784..3ecbdb020 100644--- a/internal/im/identity_test.go+++ b/internal/im/identity_test.go@@ -44,4 +44,8 @@ func TestWithIMIdentity(t *testing.T) {if principal.Type != types.PrincipalIMUser || principal.ID != "42:channel-1:feishu:open-id-1" {t.Fatalf("Principal = %#v, want im_user for the external IM user", principal)}++ if !types.IsMCPOAuthNonInteractive(ctx) {+ t.Fatal("IM context should mark MCP OAuth as non-interactive")+ }}diff --git a/internal/im/oauth_notice_test.go b/internal/im/oauth_notice_test.gonew file mode 100644index 000000000..262c2277f--- /dev/null+++ b/internal/im/oauth_notice_test.go@@ -0,0 +1,75 @@+package im++import (+ "strings"+ "testing"+)++func TestFormatIMMCPAuthNotice(t *testing.T) {+ tests := []struct {+ name string+ input []string+ want string+ contains []string+ }{+ {+ name: "empty input",+ input: nil,+ want: "",+ },+ {+ name: "all blank names",+ input: []string{"", " ", "\t"},+ want: "",+ },+ {+ name: "single service",+ input: []string{"GitHub MCP"},+ contains: []string{"GitHub MCP", "OAuth 授权"},+ },+ {+ name: "dedupe and trim",+ input: []string{" A ", "A", " B", " ", "B"},+ contains: []string{"A、B"},+ },+ }+ for _, tt := range tests {+ t.Run(tt.name, func(t *testing.T) {+ got := formatIMMCPAuthNotice(tt.input)+ if tt.contains == nil {+ if got != tt.want {+ t.Fatalf("formatIMMCPAuthNotice() = %q, want %q", got, tt.want)+ }+ return+ }+ for _, sub := range tt.contains {+ if !strings.Contains(got, sub) {+ t.Fatalf("formatIMMCPAuthNotice() = %q, want substring %q", got, sub)+ }+ }+ })+ }+}++func TestAppendIMAuthNotice(t *testing.T) {+ notice := "⚠️ 需要授权"+ tests := []struct {+ name string+ body string+ notice string+ want string+ }{+ {"empty notice", "answer", "", "answer"},+ {"empty body", "", notice, notice},+ {"whitespace body", " \n ", notice, notice},+ {"append with blank line", "answer", notice, "answer\n\n" + notice},+ }+ for _, tt := range tests {+ t.Run(tt.name, func(t *testing.T) {+ got := appendIMAuthNotice(tt.body, tt.notice)+ if got != tt.want {+ t.Fatalf("appendIMAuthNotice(%q, %q) = %q, want %q", tt.body, tt.notice, got, tt.want)+ }+ })+ }+}diff --git a/internal/types/context_helpers_test.go b/internal/types/context_helpers_test.goindex a5457e9a5..745360b4f 100644--- a/internal/types/context_helpers_test.go+++ b/internal/types/context_helpers_test.go@@ -1,6 +1,7 @@package typesimport (+ "context""testing")@@ -98,6 +99,24 @@ func TestLanguageLocaleName(t *testing.T) {}}+func TestMCPOAuthNonInteractive(t *testing.T) {+ if IsMCPOAuthNonInteractive(nil) {+ t.Fatal("nil context should not be non-interactive")+ }+ if IsMCPOAuthNonInteractive(context.Background()) {+ t.Fatal("background context should not be non-interactive")+ }++ ctx := WithMCPOAuthNonInteractive(context.Background())+ if !IsMCPOAuthNonInteractive(ctx) {+ t.Fatal("marked context should be non-interactive")+ }+ child := context.WithValue(ctx, LanguageContextKey, "en-US")+ if !IsMCPOAuthNonInteractive(child) {+ t.Fatal("child context should inherit non-interactive flag")+ }+}+func TestLanguageFromContext(t *testing.T) {tests := []struct {name string