Microsoft.Azure.ServiceBus.Primitives.ManagedIdentityTokenProvider - Coverage Report

 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}

ncG1vNJzZmiZqqq%2Fpr%2FDpJirrJmbrqTA0meZpaeSY7CwvsRnrqKmlKTEtHrNnqtomaqqv6Z50p2iZp6fp3qvsdNoeqiclVp%2FcY%2FOr5yrmZeafI61wqumrKeWqXuCxtSrnGeLlafDqq%2FEe6ysl32Wu6KzxJ2AnZ2eqba1xbOoop6mgKe8t7XDnqlnoKSiuQ%3D%3D