@@ -5,10 +5,10 @@ package azservicebus
5
5
6
6
import (
7
7
"context"
8
- "fmt"
9
8
"net"
10
9
"net/http"
11
10
"os"
11
+ "strings"
12
12
"testing"
13
13
"time"
14
14
@@ -38,7 +38,7 @@ func TestNewClientWithAzureIdentity(t *testing.T) {
38
38
envCred , err := azidentity .NewEnvironmentCredential (nil )
39
39
40
40
if err == nil {
41
- fmt . Printf ("Env cred works, being added to our chained token credential" )
41
+ t . Logf ("Env cred works, being added to our chained token credential" )
42
42
credsToAdd = append (credsToAdd , envCred )
43
43
}
44
44
@@ -58,6 +58,19 @@ func TestNewClientWithAzureIdentity(t *testing.T) {
58
58
require .NoError (t , err )
59
59
60
60
err = sender .SendMessage (context .TODO (), & Message {Body : []byte ("hello - authenticating with a TokenCredential" )}, nil )
61
+
62
+ if err != nil && strings .Contains (err .Error (), "'Send' claim(s) are required to perform this operation" ) {
63
+ const sleepDuration = time .Minute
64
+ // it's possible we're just dealing with a propagation delay for our
65
+ // configured identity and the newly created resource. We'll sleep
66
+ // a bit to give it some time and try again.
67
+ t .Logf ("Enacting CI workaround to deal with RBAC propagation delays. Sleeping for %s..." , sleepDuration )
68
+ time .Sleep (sleepDuration )
69
+ t .Logf ("Done sleeping for %s" , sleepDuration )
70
+
71
+ err = sender .SendMessage (context .TODO (), & Message {Body : []byte ("hello - authenticating with a TokenCredential" )}, nil )
72
+ }
73
+
61
74
require .NoError (t , err )
62
75
63
76
receiver , err := client .NewReceiverForQueue (queue , nil )
0 commit comments