66 "net/http"
77 "net/http/httptest"
88 "os"
9+ "path/filepath"
910 "strings"
1011 "sync"
1112 "testing"
@@ -29,7 +30,8 @@ func TestAddSpManagementTokenVisitor(t *testing.T) {
2930
3031func TestAddSpManagementTokenVisitor_Refreshed (t * testing.T ) {
3132 defer CleanupEnvironment ()()
32- os .Setenv ("PATH" , "testdata:/bin" )
33+ p , _ := filepath .Abs ("./testdata" )
34+ os .Setenv ("PATH" , p + ":/bin" )
3335
3436 aa := DatabricksClient {}
3537 r := httptest .NewRequest ("GET" , "/a/b/c" , http .NoBody )
@@ -45,7 +47,8 @@ func TestAddSpManagementTokenVisitor_Refreshed(t *testing.T) {
4547
4648func TestAddSpManagementTokenVisitor_RefreshedError (t * testing.T ) {
4749 defer CleanupEnvironment ()()
48- os .Setenv ("PATH" , "testdata:/bin" )
50+ p , _ := filepath .Abs ("./testdata" )
51+ os .Setenv ("PATH" , p + ":/bin" )
4952 os .Setenv ("FAIL" , "yes" )
5053
5154 aa := DatabricksClient {}
@@ -274,7 +277,8 @@ func TestMaybeExtendError(t *testing.T) {
274277
275278func TestGetJWTProperty_AzureCLI_SP (t * testing.T ) {
276279 defer CleanupEnvironment ()()
277- os .Setenv ("PATH" , "testdata:/bin" )
280+ p , _ := filepath .Abs ("./testdata" )
281+ os .Setenv ("PATH" , p + ":/bin" )
278282
279283 aa := DatabricksClient {
280284 AzureClientID : "a" ,
@@ -289,7 +293,8 @@ func TestGetJWTProperty_AzureCLI_SP(t *testing.T) {
289293
290294func TestGetJWTProperty_NonAzure (t * testing.T ) {
291295 defer CleanupEnvironment ()()
292- os .Setenv ("PATH" , "testdata:/bin" )
296+ p , _ := filepath .Abs ("./testdata" )
297+ os .Setenv ("PATH" , p + ":/bin" )
293298
294299 aa := DatabricksClient {
295300 Host : "https://abc.cloud.databricks.com" ,
@@ -301,7 +306,8 @@ func TestGetJWTProperty_NonAzure(t *testing.T) {
301306
302307func TestGetJWTProperty_AzureCli_Error (t * testing.T ) {
303308 defer CleanupEnvironment ()()
304- os .Setenv ("PATH" , "testdata:/bin" )
309+ p , _ := filepath .Abs ("./testdata" )
310+ os .Setenv ("PATH" , p + ":/bin" )
305311
306312 // token without expiry in this case
307313 client , server := singleRequestServer (t , "POST" , "/api/2.0/token/create" , `{
@@ -350,7 +356,8 @@ func newTestJwt(t *testing.T, claims jwt.MapClaims) string {
350356
351357func TestGetJWTProperty_AzureCli (t * testing.T ) {
352358 defer CleanupEnvironment ()()
353- os .Setenv ("PATH" , "testdata:/bin" )
359+ p , _ := filepath .Abs ("./testdata" )
360+ os .Setenv ("PATH" , p + ":/bin" )
354361 os .Setenv ("TF_AAD_TOKEN" , newTestJwt (t , jwt.MapClaims {
355362 "tid" : "some-tenant" ,
356363 }))
@@ -367,7 +374,8 @@ func TestGetJWTProperty_AzureCli(t *testing.T) {
367374
368375func TestGetJWTProperty_Authenticate_Fail (t * testing.T ) {
369376 defer CleanupEnvironment ()()
370- os .Setenv ("PATH" , "testdata:/bin" )
377+ p , _ := filepath .Abs ("./testdata" )
378+ os .Setenv ("PATH" , p + ":/bin" )
371379 os .Setenv ("FAIL" , "yes" )
372380
373381 client := & DatabricksClient {
@@ -383,7 +391,8 @@ func TestGetJWTProperty_Authenticate_Fail(t *testing.T) {
383391
384392func TestGetJWTProperty_makeGetRequest_Fail (t * testing.T ) {
385393 defer CleanupEnvironment ()()
386- os .Setenv ("PATH" , "testdata:/bin" )
394+ p , _ := filepath .Abs ("./testdata" )
395+ os .Setenv ("PATH" , p + ":/bin" )
387396 os .Setenv ("TF_AAD_TOKEN" , newTestJwt (t , jwt.MapClaims {
388397 "tid" : "some-tenant" ,
389398 }))
@@ -400,7 +409,8 @@ func TestGetJWTProperty_makeGetRequest_Fail(t *testing.T) {
400409
401410func TestGetJWTProperty_authVisitor_Fail (t * testing.T ) {
402411 defer CleanupEnvironment ()()
403- os .Setenv ("PATH" , "testdata:/bin" )
412+ p , _ := filepath .Abs ("./testdata" )
413+ os .Setenv ("PATH" , p + ":/bin" )
404414
405415 client := & DatabricksClient {
406416 Host : "https://adb-1232.azuredatabricks.net" ,
@@ -414,7 +424,8 @@ func TestGetJWTProperty_authVisitor_Fail(t *testing.T) {
414424
415425func TestGetJWTProperty_AzureCli_Error_DB_PAT (t * testing.T ) {
416426 defer CleanupEnvironment ()()
417- os .Setenv ("PATH" , "testdata:/bin" )
427+ p , _ := filepath .Abs ("./testdata" )
428+ os .Setenv ("PATH" , p + ":/bin" )
418429 os .Setenv ("TF_AAD_TOKEN" , "dapi123" )
419430
420431 srv , client := setupJwtTestClient ()
@@ -428,7 +439,8 @@ func TestGetJWTProperty_AzureCli_Error_DB_PAT(t *testing.T) {
428439
429440func TestGetJWTProperty_AzureCli_Error_No_TenantID (t * testing.T ) {
430441 defer CleanupEnvironment ()()
431- os .Setenv ("PATH" , "testdata:/bin" )
442+ p , _ := filepath .Abs ("./testdata" )
443+ os .Setenv ("PATH" , p + ":/bin" )
432444 os .Setenv ("TF_AAD_TOKEN" , newTestJwt (t , jwt.MapClaims {
433445 "something" : "else" ,
434446 }))
@@ -444,7 +456,8 @@ func TestGetJWTProperty_AzureCli_Error_No_TenantID(t *testing.T) {
444456
445457func TestGetJWTProperty_AzureCli_Error_EmptyToken (t * testing.T ) {
446458 defer CleanupEnvironment ()()
447- os .Setenv ("PATH" , "testdata:/bin" )
459+ p , _ := filepath .Abs ("./testdata" )
460+ os .Setenv ("PATH" , p + ":/bin" )
448461 os .Setenv ("TF_AAD_TOKEN" , " " )
449462
450463 srv , client := setupJwtTestClient ()
0 commit comments