@@ -14,6 +14,7 @@ import (
1414 "encoding/binary"
1515 "fmt"
1616 "github.com/Azure/azure-sdk-for-go/sdk/azcore/log"
17+ "github.com/Azure/azure-sdk-for-go/sdk/azidentity"
1718 "github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/lease"
1819 "github.com/Azure/azure-sdk-for-go/sdk/storage/azdatalake/internal/path"
1920 "hash/crc64"
@@ -5683,3 +5684,31 @@ func (s *UnrecordedTestSuite) TestGetPropertiesWithInvalidSAS() {
56835684 _ , err = fClientWithInvalidSAS .GetProperties (context .Background (), nil )
56845685 _require .Error (err )
56855686}
5687+
5688+ // TestFileClientAuthenticationFailure tests that GetProperties and DownloadStream handle authentication failures gracefully
5689+ func (s * UnrecordedTestSuite ) TestFileClientAuthenticationFailure () {
5690+ _require := require .New (s .T ())
5691+ tenantID := "invalid-tenant-id"
5692+ clientID := "invalid-client-id"
5693+ clientSecret := "invalid-secret"
5694+
5695+ cred , err := azidentity .NewClientSecretCredential (tenantID , clientID , clientSecret , nil )
5696+ _require .NoError (err )
5697+ accountName , _ := testcommon .GetGenericAccountInfo (testcommon .TestAccountDatalake )
5698+ url := "https://" + accountName + ".dfs.core.windows.net/"
5699+
5700+ srvClient , err := service .NewClient (url , cred , nil )
5701+ _require .NoError (err )
5702+
5703+ fsClient := srvClient .NewFileSystemClient ("testfs" )
5704+ fileClient := fsClient .NewFileClient ("testfile" )
5705+
5706+ _ , err = fileClient .GetProperties (context .Background (), nil )
5707+ _require .Error (err , "Expected authentication error" )
5708+ _require .Contains (err .Error (), "ClientSecretCredential" )
5709+
5710+ // Test DownloadStream - should return an error, not panic
5711+ _ , err = fileClient .DownloadStream (context .Background (), nil )
5712+ _require .Error (err , "Expected authentication error" )
5713+ _require .Contains (err .Error (), "ClientSecretCredential" )
5714+ }
0 commit comments