@@ -15,6 +15,7 @@ import (
1515
1616 "github.com/golang-jwt/jwt/v5"
1717 "github.com/google/uuid"
18+
1819 "github.com/stackitcloud/stackit-sdk-go/core/clients"
1920 "github.com/stackitcloud/stackit-sdk-go/core/config"
2021)
@@ -367,6 +368,18 @@ func TestReadCredentials(t *testing.T) {
367368 }
368369}
369370
371+ func TestReadCredentialsFileErrorMessage (t * testing.T ) {
372+ setTemporaryHome (t )
373+
374+ _ , err := readCredentialsFile ("test_resources/test_invalid_structure.json" )
375+ if err == nil {
376+ t .Fatalf ("error expected" )
377+ }
378+ if ! strings .Contains (err .Error (), "unmarshalling credentials" ) {
379+ t .Fatalf ("expected unmarshalling credentials error, got %s" , err )
380+ }
381+ }
382+
370383func TestDefaultAuth (t * testing.T ) {
371384 privateKey , err := generatePrivateKey ()
372385 if err != nil {
@@ -768,6 +781,23 @@ func TestKeyAuthPemInsteadOfJsonKeyErrorHandling(t *testing.T) {
768781 }
769782}
770783
784+ func TestSetupAuthWorkloadIdentityErrorMessage (t * testing.T ) {
785+ setTemporaryHome (t )
786+ t .Setenv ("STACKIT_SERVICE_ACCOUNT_EMAIL" , "" )
787+ t .Setenv ("STACKIT_FEDERATED_TOKEN_FILE" , "" )
788+
789+ _ , err := SetupAuth (& config.Configuration {WorkloadIdentityFederation : true })
790+ if err == nil {
791+ t .Fatalf ("error expected" )
792+ }
793+ if ! strings .Contains (err .Error (), "configuring workload identity federation client" ) {
794+ t .Fatalf ("expected workload identity federation error, got %s" , err )
795+ }
796+ if strings .Contains (err .Error (), "configuring no auth client" ) {
797+ t .Fatalf ("unexpected no auth error message: %s" , err )
798+ }
799+ }
800+
771801func TestNoAuth (t * testing.T ) {
772802 for _ , test := range []struct {
773803 desc string
0 commit comments