Added tests for new .msg and .doc file types to skipArchiverMimeTypes (#4546)

* Added Test for new .msg and .doc file types to skipArchiverMimeTypes

* changed tests to align with code review
This commit is contained in:
Jordan Tunstill
2025-11-10 14:17:12 -08:00
committed by GitHub
parent f1ccb39797
commit bb3464ea81
3 changed files with 25 additions and 0 deletions
+25
View File
@@ -17,6 +17,7 @@ import (
"time" "time"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
diskbufferreader "github.com/trufflesecurity/disk-buffer-reader" diskbufferreader "github.com/trufflesecurity/disk-buffer-reader"
"github.com/trufflesecurity/trufflehog/v3/pkg/context" "github.com/trufflesecurity/trufflehog/v3/pkg/context"
@@ -294,6 +295,30 @@ func TestHandleFileAR(t *testing.T) {
assert.Equal(t, wantChunkCount, len(reporter.Ch)) assert.Equal(t, wantChunkCount, len(reporter.Ch))
} }
func TestHandleFileMSG(t *testing.T) {
wantChunkCount := 5
reporter := sources.ChanReporter{Ch: make(chan *sources.Chunk, wantChunkCount)}
file, err := os.Open("testdata/test.msg")
require.NoError(t, err)
assert.Empty(t, reporter.Ch)
assert.NoError(t, HandleFile(context.Background(), file, &sources.Chunk{}, reporter))
assert.Equal(t, wantChunkCount, len(reporter.Ch))
}
func TestHandleFileDOC(t *testing.T) {
wantChunkCount := 3
reporter := sources.ChanReporter{Ch: make(chan *sources.Chunk, wantChunkCount)}
file, err := os.Open("testdata/test.doc")
require.NoError(t, err)
assert.Empty(t, reporter.Ch)
assert.NoError(t, HandleFile(context.Background(), file, &sources.Chunk{}, reporter))
assert.Equal(t, wantChunkCount, len(reporter.Ch))
}
func BenchmarkHandleAR(b *testing.B) { func BenchmarkHandleAR(b *testing.B) {
file, err := os.Open("testdata/test.deb") file, err := os.Open("testdata/test.deb")
assert.Nil(b, err) assert.Nil(b, err)
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.