diff --git a/pkg/iac/terraform/state/backend/gs_reader_test.go b/pkg/iac/terraform/state/backend/gs_reader_test.go index 49780fe2..ff5ccf44 100644 --- a/pkg/iac/terraform/state/backend/gs_reader_test.go +++ b/pkg/iac/terraform/state/backend/gs_reader_test.go @@ -5,6 +5,7 @@ import ( "fmt" "io" "net/http" + "os" "reflect" "testing" @@ -34,6 +35,8 @@ func TestGSBackendInvalid(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { + _ = os.Setenv("GOOGLE_APPLICATION_CREDENTIALS", "testdata/gcp_application_default_credentials.json") + got, err := NewGSReader(tt.args.path) if err.Error() != tt.wantErr.Error() { t.Errorf("NewGSReader() error = '%s', wantErr '%s'", err, tt.wantErr) diff --git a/pkg/iac/terraform/state/backend/testdata/gcp_application_default_credentials.json b/pkg/iac/terraform/state/backend/testdata/gcp_application_default_credentials.json new file mode 100644 index 00000000..a66562e0 --- /dev/null +++ b/pkg/iac/terraform/state/backend/testdata/gcp_application_default_credentials.json @@ -0,0 +1,7 @@ +{ + "client_id": "testdata.driftctl.apps.googleusercontent.com", + "client_secret": "fake-secret", + "quota_project_id": "fake-project-id", + "refresh_token": "fake-token", + "type": "authorized_user" +} \ No newline at end of file