Skip to content

Commit

Permalink
Add GitLab engine integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
mcastorina committed Feb 3, 2024
1 parent b5e7f68 commit cf34abf
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions pkg/engine/gitlab_integration_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
//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(36390))
assert.GreaterOrEqual(t, metrics.BytesScanned, uint64(92662889))
}

0 comments on commit cf34abf

Please sign in to comment.