Skip to content

Commit

Permalink
Update confidential_test.go
Browse files Browse the repository at this point in the history
  • Loading branch information
4gust committed Feb 13, 2025
1 parent c5393f5 commit 2700b64
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions apps/confidential/confidential_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -828,25 +828,22 @@ func TestRefreshInMultipleRequests(t *testing.T) {
firstTenantChecker := false
secondTenantChecker := false

ch := make(chan tokenResult, 14)
ch := make(chan tokenResult, 10000)
var mu sync.Mutex // Mutex to protect access to expectedResponse
gotResponse := []tokenResult{}
mockClient.AppendResponse(
mock.WithBody([]byte(fmt.Sprintf(`{"access_token":%q,"expires_in":%d,"refresh_in":%d,"token_type":"Bearer"}`, secondToken+"firstTenant", expiresIn, refreshIn))), mock.WithCallback(func(req *http.Request) {
time.Sleep(150 * time.Millisecond)
}),
)
mockClient.AppendResponse(
mock.WithBody([]byte(fmt.Sprintf(`{"access_token":%q,"expires_in":%d,"refresh_in":%d,"token_type":"Bearer"}`, secondToken+"secondTenant", expiresIn, refreshIn))), mock.WithCallback(func(req *http.Request) {
time.Sleep(100 * time.Millisecond)
mu.Lock()
base.GetCurrentTime = originalTime
mu.Unlock()
}),
)
for i := 0; i < 7; i++ {
for i := 0; i < 10000; i++ {
wg.Add(2)
time.Sleep(50 * time.Millisecond)
go func() {
defer wg.Done()
ar, err := client.AcquireTokenSilent(context.Background(), tokenScope, WithTenantID("firstTenant"))
Expand All @@ -864,7 +861,6 @@ func TestRefreshInMultipleRequests(t *testing.T) {
ch <- tokenResult{Token: ar.AccessToken, Tenant: "firstTentant"} // Send result to channel
}()
go func() {
time.Sleep(50 * time.Millisecond)
defer wg.Done()
ar, err := client.AcquireTokenSilent(context.Background(), tokenScope, WithTenantID("secondTenant"))
if err != nil {
Expand Down

0 comments on commit 2700b64

Please sign in to comment.