Skip to content

Commit

Permalink
test: add coverage for api-key
Browse files Browse the repository at this point in the history
  • Loading branch information
gotbadger committed Sep 20, 2023
1 parent 210630b commit 29a0a1a
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
4 changes: 4 additions & 0 deletions e2e/flags/.snapshots/TestApiKeyFlags-bad-api-key
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{}

--

11 changes: 11 additions & 0 deletions e2e/flags/.snapshots/TestApiKeyFlags-bad-api-key-with-stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{}

--
Loading rules
Scanning target e2e/flags/testdata/simple
└ 100% [===============] (1/1, 1 files/s) [0s]
Running Detectors
Generating dataflow
Evaluating rules
Failed to send data to Bearer Cloud. API key does not appear to be valid for my.bearer.sh.

Expand Down
28 changes: 28 additions & 0 deletions e2e/flags/api_key_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package flags_test

import (
"path/filepath"
"testing"

"github.com/bearer/bearer/e2e/internal/testhelper"
)

func TestApiKeyFlags(t *testing.T) {
t.Parallel()
arguments := []string{
"scan",
filepath.Join("e2e", "flags", "testdata", "simple"),
"--disable-version-check",
"--disable-default-rules",
"--api-key",
"123",
"--format",
"json",
}
tests := []testhelper.TestCase{
testhelper.NewTestCase("bad-api-key-with-stderr", arguments, testhelper.TestCaseOptions{DisplayStdErr: true, IgnoreForce: true}),
testhelper.NewTestCase("bad-api-key", arguments, testhelper.TestCaseOptions{DisplayStdErr: false, IgnoreForce: true}),
}

testhelper.RunTests(t, tests)
}

0 comments on commit 29a0a1a

Please sign in to comment.