From 1d307bfc52864683a5c8ec7eb5d9ba8a532b7d7c Mon Sep 17 00:00:00 2001 From: Cody Oss <6331106+codyoss@users.noreply.github.com> Date: Mon, 15 Mar 2021 09:08:02 -0600 Subject: [PATCH] test: refactor idtoken test (#921) - move them into the idtoken package - use ADC var name as some tests require the fallback - remove my locally sourced creds - remove build tag restricting run --- .../idtoken_test.go => idtoken/integration_test.go | 8 ++------ internal/kokoro/test.sh | 2 +- 2 files changed, 3 insertions(+), 7 deletions(-) rename integration-tests/idtoken/idtoken_test.go => idtoken/integration_test.go (90%) diff --git a/integration-tests/idtoken/idtoken_test.go b/idtoken/integration_test.go similarity index 90% rename from integration-tests/idtoken/idtoken_test.go rename to idtoken/integration_test.go index cf32a3f8677..32281fa8507 100644 --- a/integration-tests/idtoken/idtoken_test.go +++ b/idtoken/integration_test.go @@ -2,9 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build integration - -package idtoken +package idtoken_test import ( "context" @@ -20,7 +18,7 @@ import ( ) const ( - envCredentialFile = "GCLOUD_TESTS_GOLANG_KEY" + envCredentialFile = "GOOGLE_APPLICATION_CREDENTIALS" aud = "http://example.com" ) @@ -29,7 +27,6 @@ func TestNewTokenSource(t *testing.T) { if testing.Short() { t.Skip("skipping integration test") } - os.Setenv(envCredentialFile, "/Users/codyoss/creds/codyoss-workspace-2b1fb7cd40c0.json") ts, err := idtoken.NewTokenSource(context.Background(), "http://example.com", option.WithCredentialsFile(os.Getenv(envCredentialFile))) if err != nil { t.Fatalf("unable to create TokenSource: %v", err) @@ -56,7 +53,6 @@ func TestNewClient_WithCredentialFile(t *testing.T) { if testing.Short() { t.Skip("skipping integration test") } - os.Setenv(envCredentialFile, "/Users/codyoss/creds/codyoss-workspace-2b1fb7cd40c0.json") client, err := idtoken.NewClient(context.Background(), aud, option.WithCredentialsFile(os.Getenv(envCredentialFile))) if err != nil { t.Fatalf("unable to create Client: %v", err) diff --git a/internal/kokoro/test.sh b/internal/kokoro/test.sh index 5fa58294a5c..9c6dfea580d 100755 --- a/internal/kokoro/test.sh +++ b/internal/kokoro/test.sh @@ -7,7 +7,7 @@ # Fail on any error set -eo pipefail -export GCLOUD_TESTS_GOLANG_KEY="${KOKORO_GFILE_DIR}/secret_manager/go-cloud-integration-service-account" +export GOOGLE_APPLICATION_CREDENTIALS="${KOKORO_GFILE_DIR}/secret_manager/go-cloud-integration-service-account" # Display commands being run set -x