Exemple #1
0
        public void InterceptorDoesNothingForEmptyAccessTokens()
        {
            AsyncAuthInterceptor asyncAuthInterceptor = LedgerCallCredentials.MakeAsyncAuthInterceptor(new List <string>());

            Metadata metaData = new Metadata();

            Task task = asyncAuthInterceptor(new AuthInterceptorContext("url", "method"), metaData);

            Assert.IsTrue(task.IsCompleted);
            Assert.AreEqual(0, metaData.Count);
        }
        public void InterceptorDoesNothingForEmptyAccessTokens()
        {
            AsyncAuthInterceptor asyncAuthInterceptor = LedgerCallCredentials.MakeAsyncAuthInterceptor(new List <string>());

            Metadata metaData = new Metadata();

            Task task = asyncAuthInterceptor(new AuthInterceptorContext("url", "method"), metaData);

            task.IsCompleted.Should().BeTrue();
            metaData.Should().BeEmpty();
        }
Exemple #3
0
        public void CanCreateAuthInterceptorForAccessToken()
        {
            AsyncAuthInterceptor asyncAuthInterceptor = LedgerCallCredentials.MakeAsyncAuthInterceptor("myAccessToken");

            Metadata metaData = new Metadata();

            Task task = asyncAuthInterceptor(new AuthInterceptorContext("url", "method"), metaData);

            Assert.IsTrue(task.IsCompleted);
            Assert.AreEqual(1, metaData.Count);
            var entry = metaData.First();

            Assert.AreEqual("authorization", entry.Key);
            Assert.AreEqual("myAccessToken", entry.Value);
        }
        public void CanCreateAuthInterceptorForAccessToken()
        {
            AsyncAuthInterceptor asyncAuthInterceptor = LedgerCallCredentials.MakeAsyncAuthInterceptor("myAccessToken");

            Metadata metaData = new Metadata();

            Task task = asyncAuthInterceptor(new AuthInterceptorContext("url", "method"), metaData);

            task.IsCompleted.Should().BeTrue();
            metaData.Should().ContainSingle();
            var entry = metaData.First();

            entry.Key.Should().Be("authorization");
            entry.Value.Should().Be("myAccessToken");
        }
Exemple #5
0
        public void InterceptorCopesWithSparseAccessTokens()
        {
            AsyncAuthInterceptor asyncAuthInterceptor = LedgerCallCredentials.MakeAsyncAuthInterceptor(new[] { "accessToken1", null, "accessToken2", string.Empty, "accessToken3" });

            Metadata metaData = new Metadata();

            Task task = asyncAuthInterceptor(new AuthInterceptorContext("url", "method"), metaData);

            Assert.IsTrue(task.IsCompleted);
            int i = 1;

            foreach (var entry in metaData)
            {
                Assert.AreEqual("authorization", entry.Key);
                Assert.AreEqual($"accessToken{i++}", entry.Value);
            }
        }
        public void CanCreateAuthInterceptorForAccessTokens()
        {
            AsyncAuthInterceptor asyncAuthInterceptor = LedgerCallCredentials.MakeAsyncAuthInterceptor(new [] { "accessToken1", "accessToken2", "accessToken3" });

            Metadata metaData = new Metadata();

            Task task = asyncAuthInterceptor(new AuthInterceptorContext("url", "method"), metaData);

            task.IsCompleted.Should().BeTrue();
            metaData.Should().HaveCount(3);
            int i = 1;

            foreach (var entry in metaData)
            {
                entry.Key.Should().Be("authorization");
                entry.Value.Should().Be($"accessToken{i++}");
            }
        }