public async Task Can_ask_for_new_credentials()
        {
            SetAuth(DateTime.UtcNow.AddMinutes(-90));
            var client = new FakeClient(_cache);
            await client.SetupClientCredentials(GetConfiguredTokenCLient);

            Assert.Equal("Bearer", client.DefaultRequestHeaders.Authorization.Scheme);
            var handler = new JwtSecurityTokenHandler();
            var token   = handler.ReadJwtToken(client.DefaultRequestHeaders.Authorization.Parameter);

            Assert.Equal("core_api", token.Audiences.First());
        }
        public async Task Can_use_cached_credentials()
        {
            SetAuth(DateTime.UtcNow.AddHours(2));
            var client = new FakeClient(_cache);
            await client.SetupClientCredentials(GetConfiguredTokenCLient);

            Assert.Equal("Bearer", client.DefaultRequestHeaders.Authorization.Scheme);
            var handler = new JwtSecurityTokenHandler();
            var token   = handler.ReadJwtToken(client.DefaultRequestHeaders.Authorization.Parameter);

            Assert.Equal(token.Subject, _intendedToken.Subject);
            Assert.Equal(token.ValidTo, _intendedToken.ValidTo);
            Assert.Equal(token.Audiences.First(), _intendedToken.Audiences.First());
        }