Exemple #1
0
            /// <summary>Constructs a new initializer using the given token server URL.</summary>
            public Initializer(string tokenServerUrl)
            {
                TokenServerUrl = tokenServerUrl;

                AccessMethod = new BearerToken.AuthorizationHeaderAccessMethod();
                Clock        = SystemClock.Default;
                DefaultExponentialBackOffPolicy = ExponentialBackOffPolicy.UnsuccessfulResponse503;
            }
            /// <summary>Constructs a new initializer using the given token server URL.</summary>
            public Initializer(string tokenServerUrl)
            {
                TokenServerUrl = tokenServerUrl;

                AccessMethod = new BearerToken.AuthorizationHeaderAccessMethod();
                Clock = SystemClock.Default;
                DefaultExponentialBackOffPolicy = ExponentialBackOffPolicy.UnsuccessfulResponse503;
            }
        public void AuthorizationHeaderAccessMethod_GetAccessToken()
        {
            var request = new HttpRequestMessage();
            request.Headers.Authorization = new AuthenticationHeaderValue("a", "1");
            var accessToken = new BearerToken.AuthorizationHeaderAccessMethod().GetAccessToken(request);
            Assert.IsNullOrEmpty(accessToken);

            request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", "abc");
            accessToken = new BearerToken.AuthorizationHeaderAccessMethod().GetAccessToken(request);
            Assert.That(accessToken, Is.EqualTo("abc"));
        }
Exemple #4
0
        public void AuthorizationHeaderAccessMethod_GetAccessToken()
        {
            var request = new HttpRequestMessage();

            request.Headers.Authorization = new AuthenticationHeaderValue("a", "1");
            var accessToken = new BearerToken.AuthorizationHeaderAccessMethod().GetAccessToken(request);

            Assert.That(accessToken, Is.Null.Or.Empty);

            request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", "abc");
            accessToken = new BearerToken.AuthorizationHeaderAccessMethod().GetAccessToken(request);
            Assert.That(accessToken, Is.EqualTo("abc"));
        }