Skip to content

Open-source LLM knowledge platform: turn raw documents into a queryable RAG, an autonomous reasoning agent, and a self-maintaining Wiki.

test(datasource): keep yuque and ima config tests off live DNS

po-et90e3977714a0
diff --git a/internal/datasource/connector/ima/fake_ima_test.go b/internal/datasource/connector/ima/fake_ima_test.go
index f0026c62e..1b503ab6c 100644
--- a/internal/datasource/connector/ima/fake_ima_test.go
+++ b/internal/datasource/connector/ima/fake_ima_test.go
@@ -15,9 +15,11 @@ import (
)
// TestMain whitelists loopback for SSRF so the httptest servers (127.0.0.1)
-// are reachable. Production keeps the default strict SSRF policy.
+// are reachable, and the default base host so parseIMAConfig does not resolve
+// ima.qq.com over live DNS during a unit test. Production keeps the default
+// strict SSRF policy.
func TestMain(m *testing.M) {
- _ = os.Setenv("SSRF_WHITELIST", "127.0.0.1,localhost")
+ _ = os.Setenv("SSRF_WHITELIST", "127.0.0.1,localhost,ima.qq.com")
secutils.ResetSSRFWhitelistForTest()
os.Exit(m.Run())
}
diff --git a/internal/datasource/connector/yuque/connector_test.go b/internal/datasource/connector/yuque/connector_test.go
index 35118e971..44f3ca049 100644
--- a/internal/datasource/connector/yuque/connector_test.go
+++ b/internal/datasource/connector/yuque/connector_test.go
@@ -11,8 +11,11 @@ import (
secutils "github.com/Tencent/WeKnora/internal/utils"
)
+// TestMain whitelists loopback for the httptest servers and the default base
+// host so parseYuqueConfig does not resolve www.yuque.com over live DNS during
+// a unit test. Production keeps the default strict SSRF policy.
func TestMain(m *testing.M) {
- os.Setenv("SSRF_WHITELIST", "127.0.0.1,localhost")
+ _ = os.Setenv("SSRF_WHITELIST", "127.0.0.1,localhost,www.yuque.com")
secutils.ResetSSRFWhitelistForTest()
os.Exit(m.Run())
}