< Summary

Class:Microsoft.Azure.ServiceBus.Primitives.TokenProviderAdapter
Assembly:Microsoft.Azure.ServiceBus
File(s):C:\Git\azure-sdk-for-net\sdk\servicebus\Microsoft.Azure.ServiceBus\src\Primitives\TokenProviderAdapter.cs
Covered lines:4
Uncovered lines:4
Coverable lines:8
Total lines:34
Line coverage:50% (4 of 8)
Covered branches:0
Total branches:2
Branch coverage:0% (0 of 2)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-100%100%
GetTokenAsync()-0%0%

File(s)

C:\Git\azure-sdk-for-net\sdk\servicebus\Microsoft.Azure.ServiceBus\src\Primitives\TokenProviderAdapter.cs

#LineLine coverage
 1// Copyright (c) Microsoft. All rights reserved.
 2// Licensed under the MIT license. See LICENSE file in the project root for full license information.
 3
 4namespace Microsoft.Azure.ServiceBus.Primitives
 5{
 6    using System.Diagnostics;
 7    using System;
 8    using System.Linq;
 9    using System.Threading.Tasks;
 10    using Microsoft.Azure.Amqp;
 11
 12    /// <summary>
 13    /// Provides an adapter from TokenProvider to ICbsTokenProvider for AMQP CBS usage.
 14    /// </summary>
 15    sealed class TokenProviderAdapter : ICbsTokenProvider
 16    {
 17        readonly ITokenProvider tokenProvider;
 18        readonly TimeSpan operationTimeout;
 19
 1220        public TokenProviderAdapter(ITokenProvider tokenProvider, TimeSpan operationTimeout)
 21        {
 22            Debug.Assert(tokenProvider != null, "tokenProvider cannot be null");
 1223            this.tokenProvider = tokenProvider;
 1224            this.operationTimeout = operationTimeout;
 1225        }
 26
 27        public async Task<CbsToken> GetTokenAsync(Uri namespaceAddress, string appliesTo, string[] requiredClaims)
 28        {
 029            var claim = requiredClaims?.FirstOrDefault();
 030            var securityToken = await this.tokenProvider.GetTokenAsync(appliesTo, this.operationTimeout).ConfigureAwait(
 031            return new CbsToken(securityToken.TokenValue, CbsConstants.ServiceBusSasTokenType, securityToken.ExpiresAtUt
 032        }
 33    }
 34}

Methods/Properties

.ctor(...)
GetTokenAsync()