Skip to content

Commit a27d92a

Browse files
committed
Make sure to use a non-existent token in tests
When the "should fail when no token is passed and SA token cannot be read" test is run within a pod on a Kubernetes cluster, the test will fail because the service account token file is present. This change provides a path to a file that should not conflict with any others on the system Signed-off-by: Nolan Brubaker <[email protected]>
1 parent 9f3b1d0 commit a27d92a

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

pkg/common/vclib/vc_session_manager_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,10 @@ func TestGetSharedToken(t *testing.T) {
7878

7979
t.Run("should fail when no token is passed and SA token cannot be read", func(t *testing.T) {
8080
_, err := vclib.GetSharedToken(ctx, vclib.SharedTokenOptions{
81-
URL: "http://something.tld/lala",
81+
URL: "http://something.tld/lala",
82+
TokenFile: "/var/run/secrets/test-token",
8283
})
83-
assert.ErrorContains(t, err, "failed reading token from service account: open /var/run/secrets/kubernetes.io/serviceaccount/token: no such file or directory")
84+
assert.ErrorContains(t, err, "failed reading token from service account: open /var/run/secrets/test-token: no such file or directory")
8485
})
8586

8687
t.Run("should fail when passed URL is invalid", func(t *testing.T) {

0 commit comments

Comments
 (0)