@@ -367,6 +367,18 @@ func TestReadCredentials(t *testing.T) {
367367 }
368368}
369369
370+ func TestReadCredentialsFileErrorMessage (t * testing.T ) {
371+ setTemporaryHome (t )
372+
373+ _ , err := readCredentialsFile ("test_resources/test_invalid_structure.json" )
374+ if err == nil {
375+ t .Fatalf ("error expected" )
376+ }
377+ if ! strings .Contains (err .Error (), "unmarshalling credentials" ) {
378+ t .Fatalf ("expected unmarshalling credentials error, got %s" , err )
379+ }
380+ }
381+
370382func TestDefaultAuth (t * testing.T ) {
371383 privateKey , err := generatePrivateKey ()
372384 if err != nil {
@@ -768,6 +780,23 @@ func TestKeyAuthPemInsteadOfJsonKeyErrorHandling(t *testing.T) {
768780 }
769781}
770782
783+ func TestSetupAuthWorkloadIdentityErrorMessage (t * testing.T ) {
784+ setTemporaryHome (t )
785+ t .Setenv ("STACKIT_SERVICE_ACCOUNT_EMAIL" , "" )
786+ t .Setenv ("STACKIT_FEDERATED_TOKEN_FILE" , "" )
787+
788+ _ , err := SetupAuth (& config.Configuration {WorkloadIdentityFederation : true })
789+ if err == nil {
790+ t .Fatalf ("error expected" )
791+ }
792+ if ! strings .Contains (err .Error (), "configuring workload identity federation client" ) {
793+ t .Fatalf ("expected workload identity federation error, got %s" , err )
794+ }
795+ if strings .Contains (err .Error (), "configuring no auth client" ) {
796+ t .Fatalf ("unexpected no auth error message: %s" , err )
797+ }
798+ }
799+
771800func TestNoAuth (t * testing.T ) {
772801 for _ , test := range []struct {
773802 desc string
0 commit comments