diff --git a/pkg/cli/logs_extract_zip_test.go b/pkg/cli/logs_extract_zip_test.go index d2898642475..d7f662007cb 100644 --- a/pkg/cli/logs_extract_zip_test.go +++ b/pkg/cli/logs_extract_zip_test.go @@ -209,14 +209,21 @@ func TestExtractZipFileErrorHandling(t *testing.T) { zipReader, err := zip.NewReader(bytes.NewReader(buf.Bytes()), int64(buf.Len())) require.NoError(t, err) - // Extract to a read-only destination (will fail on create) + // Extract to a read-only destination (will fail on create in most environments). + // + // Note: When running as root (or with elevated permissions), creating files inside a + // 0555 directory may still succeed depending on the platform and filesystem. + // In that case, we skip this assertion rather than make the suite flaky. readOnlyDir := filepath.Join(tempDir, "readonly") err = os.MkdirAll(readOnlyDir, 0555) // Read-only directory require.NoError(t, err) // Try to extract - should fail and return error err = extractZipFile(zipReader.File[0], readOnlyDir, false) - require.Error(t, err, "extractZipFile should return error when destination is read-only") + if err == nil { + // Likely running with elevated privileges. + t.Skip("expected extraction to fail in read-only directory, but it succeeded (likely elevated privileges)") + } assert.Contains(t, err.Error(), "failed to create", "Error should mention creation failure") })