Files
trufflehog/pkg/engine/gitlab_integration_test.go
Miccah aace92b64d Implement SourceUnitEnumChunker for GitLab (#2367)
* Implement SourceUnitEnumChunker for GitLab

* Add GitLab engine integration test

* Use a SliceReporter instead of checking for nil reporters

* Use more generic VisitorReporter

* Merge logic from getReposFromGitlab into getAllProjectRepos

* Update integration test to have a lower bound

Unfortunately, the GitLab integration test does not appear to be
deterministic. Sometimes 36390 chunks are found, sometimes 36312, or
even lower.
2024-02-09 11:06:31 -08:00

42 lines
977 B
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/sources"
)
func TestGitLab(t *testing.T) {
// Run the scan.
ctx := context.Background()
e, err := Start(ctx,
WithDetectors(DefaultDetectors()...),
WithVerify(false),
)
assert.NoError(t, err)
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(36312))
assert.GreaterOrEqual(t, metrics.BytesScanned, uint64(91618854))
}