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:
@@ -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)
|
||||||
|
|||||||
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Reference in New Issue
Block a user