Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,7 @@ public async Task BearerTokenAuthenticationPolicy_BackgroundRefreshCancelledAndL
}

[Test]
[Retry(3)] //https://github.com/Azure/azure-sdk-for-net/issues/21005
public async Task BearerTokenAuthenticationPolicy_BackgroundRefreshFailsAndLogs()
{
var requestMre = new ManualResetEventSlim(true);
Expand All @@ -740,6 +741,7 @@ public async Task BearerTokenAuthenticationPolicy_BackgroundRefreshFailsAndLogs(
string msg = "fail to refresh";
var credential = new BearerTokenAuthenticationPolicyTests.TokenCredentialStub((r, c) =>
{
TestContext.WriteLine($"Start TokenCredentialStub: callCount: {callCount}");
if (callCount > 0)
{
throw new Exception(msg);
Expand All @@ -749,12 +751,14 @@ public async Task BearerTokenAuthenticationPolicy_BackgroundRefreshFailsAndLogs(
requestMre.Reset();
callCount++;

TestContext.WriteLine($"End TokenCredentialStub: callCount: {callCount}");
return new AccessToken(Guid.NewGuid().ToString(), expires.Dequeue());
},
IsAsync);

AzureEventSourceListener listener = new((args, text) =>
{
TestContext.WriteLine(text);
if (args.EventName == "BackgroundRefreshFailed" && text.Contains(msg))
{
logged = true;
Expand All @@ -768,7 +772,6 @@ public async Task BearerTokenAuthenticationPolicy_BackgroundRefreshFailsAndLogs(
responseMre.Reset();

Task requestTask = SendGetRequest(transport, policy, uri: new Uri("https://example.com/3/Refresh"));
// requestMre.Wait();

await SendGetRequest(transport, policy, uri: new Uri("https://example.com/2/AlmostExpired"));
await requestTask;
Expand Down