public async void FetchKeySet_Throws_OnHttpClientException()
        {
            // arrange
            var tkr = new CloudFoundryTokenKeyResolver(networkFailOptions, GetMockHttpClient());

            // act
            var exception = await Assert.ThrowsAsync <HttpRequestException>(() => tkr.FetchKeySet());
        }
        public async void FetchKeySet_ReturnsNull_OnFailure()
        {
            // arrange
            var tkr = new CloudFoundryTokenKeyResolver(serviceUnavailableOptions, GetMockHttpClient());

            // act
            var expected = await tkr.FetchKeySet();

            // assert
            Assert.Null(expected);
        }
        public async void FetchKeySet_ReturnsKeySet_OnSuccess()
        {
            // arrange
            var tkr = new CloudFoundryTokenKeyResolver(happyPathOptions, GetMockHttpClient());

            // act
            var expected = await tkr.FetchKeySet();

            // assert
            Assert.Contains(expected.Keys, key => key.Kid == "key-1");
            var tokenKey = expected.Keys.First();

            Assert.Equal("RS256", tokenKey.Alg);
            Assert.Equal("sig", tokenKey.Use);
            Assert.Equal("AQAB", tokenKey.E);
        }
        public async Task FetchKeySet_IssuesHttpRequest_ReturnsKeyset()
        {
            var keyset   = "{ 'keys':[{'kid':'legacy-token-key','alg':'SHA256withRSA','value':'-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAk+7xH35bYBppsn54cBW+\nFlrveTe+3L4xl7ix13XK8eBcCmNOyBhNzhks6toDiRjrgw5QW76cFirVRFIVQkiZ\nsUwDyGOax3q8NOJyBFXiplIUScrx8aI0jkY/Yd6ixAc5yBSBfXThy4EF9T0xCyt4\nxWLYNXMRwe88Y+i+MEoLNXWRbhjJm76LN7rsdIxALbS0vJNWUDALWjtE6FeYX6uU\nL9msAzlCQkdnSvwMmr8Ij2O3IVMxHDJXOZinFqt9zVfXwO11o7ZmiskZnRz1/V0f\nvbUQAadkcDEUt1gk9cbrAhiipg8VWDMsC7VUXuekJZjme5f8oWTwpsgP6cTUzwSS\n6wIDAQAB\n-----END PUBLIC KEY-----','kty':'RSA','use':'sig','n':'AJPu8R9+W2AaabJ+eHAVvhZa73k3vty+MZe4sdd1yvHgXApjTsgYTc4ZLOraA4kY64MOUFu+nBYq1URSFUJImbFMA8hjmsd6vDTicgRV4qZSFEnK8fGiNI5GP2HeosQHOcgUgX104cuBBfU9MQsreMVi2DVzEcHvPGPovjBKCzV1kW4YyZu+ize67HSMQC20tLyTVlAwC1o7ROhXmF+rlC/ZrAM5QkJHZ0r8DJq/CI9jtyFTMRwyVzmYpxarfc1X18DtdaO2ZorJGZ0c9f1dH721EAGnZHAxFLdYJPXG6wIYoqYPFVgzLAu1VF7npCWY5nuX/KFk8KbID+nE1M8Ekus=','e':'AQAB'}]}";
            var handler  = new TestMessageHandler();
            var response = new HttpResponseMessage(System.Net.HttpStatusCode.OK)
            {
                Content = new StringContent(keyset)
            };

            handler.Response = response;

            CloudFoundryTokenKeyResolver.Resolved.Clear();

            var resolver = new CloudFoundryTokenKeyResolver("https://foo.bar", handler, true);
            var result   = await resolver.FetchKeySet();

            Assert.NotNull(result);
        }