package origin import ( "context" "errors" "fmt" "testing" "time" "github.com/stretchr/testify/assert" tunnelpogs "github.com/cloudflare/cloudflared/tunnelrpc/pogs" ) func TestRefreshAuthBackoff(t *testing.T) { rcm := newReconnectCredentialManager(t.Name(), t.Name(), 4) var wait time.Duration timeAfter = func(d time.Duration) <-chan time.Time { wait = d return time.After(d) } backoff := &BackoffHandler{MaxRetries: 3} auth := func(ctx context.Context, n int) (tunnelpogs.AuthOutcome, error) { return nil, fmt.Errorf("authentication failure") } // authentication failures should consume the backoff for i := uint(0); i < backoff.MaxRetries; i++ { retryChan, err := rcm.RefreshAuth(context.Background(), backoff, auth) assert.NoError(t, err) assert.NotNil(t, retryChan) assert.Equal(t, (1<