< Summary

Class:Microsoft.Azure.ServiceBus.Primitives.ManagedIdentityTokenProvider
Assembly:Microsoft.Azure.ServiceBus
File(s):C:\Git\azure-sdk-for-net\sdk\servicebus\Microsoft.Azure.ServiceBus\src\Primitives\ManagedIdentityTokenProvider.cs
Covered lines:4
Uncovered lines:3
Coverable lines:7
Total lines:39
Line coverage:57.1% (4 of 7)
Covered branches:0
Total branches:0

Metrics

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

File(s)

C:\Git\azure-sdk-for-net\sdk\servicebus\Microsoft.Azure.ServiceBus\src\Primitives\ManagedIdentityTokenProvider.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;
 7    using System.Threading.Tasks;
 8    using Azure.Services.AppAuthentication;
 9
 10    /// <summary>
 11    /// Represents the Azure Active Directory token provider for Azure Managed Identity integration.
 12    /// </summary>
 13    public class ManagedIdentityTokenProvider : TokenProvider
 14    {
 15        private readonly AzureServiceTokenProvider azureServiceTokenProvider;
 16
 17        /// <summary>Initializes new instance of <see cref="ManagedIdentityTokenProvider"/> class with default <see cref
 2418        public ManagedIdentityTokenProvider() : this(new AzureServiceTokenProvider()){}
 19
 20        /// <summary>Initializes new instance of <see cref="ManagedIdentityTokenProvider"/> class with <see cref="AzureS
 21        /// <remarks>Call that constructore to set <see cref="AzureServiceTokenProvider"/> with required Managed Identit
 1222        public ManagedIdentityTokenProvider(AzureServiceTokenProvider azureServiceTokenProvider)
 23        {
 1224            this.azureServiceTokenProvider = azureServiceTokenProvider;
 1225        }
 26
 27        /// <summary>
 28        /// Gets a <see cref="SecurityToken"/> for the given audience and duration.
 29        /// </summary>
 30        /// <param name="appliesTo">The URI which the access token applies to</param>
 31        /// <param name="timeout">The time span that specifies the timeout value for the message that gets the security 
 32        /// <returns><see cref="SecurityToken"/></returns>
 33        public async override Task<SecurityToken> GetTokenAsync(string appliesTo, TimeSpan timeout)
 34        {
 035            string accessToken = await azureServiceTokenProvider.GetAccessTokenAsync(Constants.AadServiceBusAudience).Co
 036            return new JsonSecurityToken(accessToken, appliesTo);
 037        }
 38    }
 39}

Methods/Properties

.ctor()
.ctor(...)
GetTokenAsync()