mirror of
https://github.com/trufflesecurity/trufflehog.git
synced 2026-05-16 13:20:35 +00:00
f70218bad0
* updated gitlab client from v0.129.0 to v1.12.0(latest) * fixed integration test * unpinned v0.129 gitlab client and migrated code * Migrated auth code * Remove unused 'time' import Removed unused 'time' import from gitlab.go * reverted merged case statements * splitted line like before * splitted code into multiple lines * resolved bugbot comments
45 lines
1.1 KiB
Go
45 lines
1.1 KiB
Go
//go:build integration
|
|
// +build integration
|
|
|
|
package engine
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/trufflesecurity/trufflehog/v3/pkg/common"
|
|
"github.com/trufflesecurity/trufflehog/v3/pkg/context"
|
|
"github.com/trufflesecurity/trufflehog/v3/pkg/engine/defaults"
|
|
"github.com/trufflesecurity/trufflehog/v3/pkg/sources"
|
|
)
|
|
|
|
func TestGitLab(t *testing.T) {
|
|
// Run the scan.
|
|
ctx := context.Background()
|
|
e, err := NewEngine(ctx, &Config{
|
|
Detectors: defaults.DefaultDetectors(),
|
|
SourceManager: sources.NewManager(),
|
|
Verify: false,
|
|
})
|
|
assert.NoError(t, err)
|
|
e.Start(ctx)
|
|
|
|
secret, err := common.GetTestSecret(ctx)
|
|
if err != nil {
|
|
t.Fatal(fmt.Errorf("failed to access secret: %v", err))
|
|
}
|
|
_, err = e.ScanGitLab(ctx, sources.GitlabConfig{
|
|
Token: secret.MustGetField("GITLAB_TOKEN"),
|
|
})
|
|
assert.NoError(t, err)
|
|
|
|
err = e.Finish(ctx)
|
|
assert.NoError(t, err)
|
|
|
|
// Check the output provided by metrics.
|
|
metrics := e.GetMetrics()
|
|
assert.GreaterOrEqual(t, metrics.ChunksScanned, uint64(23528))
|
|
assert.GreaterOrEqual(t, metrics.BytesScanned, uint64(84982266))
|
|
}
|