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:
@@ -39,6 +39,9 @@ func (m *mockFileService) GetFileURL(ctx context.Context, filePath string) (stri
|
||||
func (m *mockFileService) DeleteFile(ctx context.Context, filePath string) error { return nil }
|
||||
|
||||
func TestResolveRemoteImages_NormalDownload(t *testing.T) {
|
||||
// Whitelist localhost for this test so the test server is reachable
|
||||
t.Setenv("SSRF_WHITELIST", "127.0.0.1,localhost")
|
||||
|
||||
// Create a test HTTP server that serves a real PNG image.
|
||||
pngData := createTestPNG(200, 200)
|
||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -101,6 +104,9 @@ func TestResolveRemoteImages_SSRFBlocked(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestResolveRemoteImages_NonImageContentType(t *testing.T) {
|
||||
// Whitelist localhost for this test so the test server is reachable
|
||||
t.Setenv("SSRF_WHITELIST", "127.0.0.1,localhost")
|
||||
|
||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "text/html")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
@@ -147,6 +153,9 @@ func TestResolveRemoteImages_ProviderSchemeSkipped(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestResolveRemoteImages_MultipleImages(t *testing.T) {
|
||||
// Whitelist localhost for this test so the test server is reachable
|
||||
t.Setenv("SSRF_WHITELIST", "127.0.0.1,localhost")
|
||||
|
||||
pngData := createTestPNG(256, 256)
|
||||
callCount := 0
|
||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -199,6 +208,9 @@ func TestResolveRemoteImages_NoImages(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestResolveRemoteImages_Server404(t *testing.T) {
|
||||
// Whitelist localhost for this test so the test server is reachable
|
||||
t.Setenv("SSRF_WHITELIST", "127.0.0.1,localhost")
|
||||
|
||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
w.WriteHeader(http.StatusNotFound)
|
||||
}))
|
||||
|
||||
Reference in New Issue
Block a user