fix: improve tenant access token logging and update test cases

- Enhanced the logging of the tenant access token in the Feishu client to handle variable lengths for prefix and suffix, ensuring accurate display even for shorter tokens.
- Updated the test cases in `connector_test.go` to reflect changes in the endpoint path for file downloads, improving test reliability.
- Adjusted example outputs in `example_test.go` for clarity and consistency.
- Modified image resolution tests to correct expected outcomes based on updated criteria for icon images.
- Added environment variable settings in image resolver tests to ensure localhost accessibility during testing.

These changes enhance the robustness of logging and testing mechanisms across the application.
This commit is contained in:
wizardchen
2026-04-08 22:43:17 +08:00
parent 2b495c8232
commit a81ef5fbb2
10 changed files with 81 additions and 45 deletions
@@ -80,8 +80,16 @@ func (c *Client) getTenantAccessToken(ctx context.Context) (string, error) {
}
c.tokenExpAt = time.Now().Add(ttl)
prefixLen := 8
if len(result.TenantAccessToken) < prefixLen {
prefixLen = len(result.TenantAccessToken)
}
suffixLen := 4
if len(result.TenantAccessToken) < suffixLen {
suffixLen = len(result.TenantAccessToken)
}
logger.Infof(ctx, "[Feishu] got tenant_access_token: %s...%s expire=%ds",
result.TenantAccessToken[:8], result.TenantAccessToken[len(result.TenantAccessToken)-4:], result.Expire)
result.TenantAccessToken[:prefixLen], result.TenantAccessToken[len(result.TenantAccessToken)-suffixLen:], result.Expire)
return c.tokenCache, nil
}
@@ -129,7 +129,7 @@ func fakeFeishu(nodes []wikiNode) (*httptest.Server, *Config) {
})
// --- export file download ---
mux.HandleFunc("/open-apis/drive/v1/export_tasks/file/ticket-123/download", func(w http.ResponseWriter, r *http.Request) {
mux.HandleFunc("/open-apis/drive/v1/export_tasks/file/ft-abc/download", func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/octet-stream")
w.Write([]byte("fake-docx-content"))
})