< Summary

Class:Azure.Identity.MsalPublicClient
Assembly:Azure.Identity
File(s):C:\Git\azure-sdk-for-net\sdk\identity\Azure.Identity\src\MsalPublicClient.cs
Covered lines:20
Uncovered lines:9
Coverable lines:29
Total lines:87
Line coverage:68.9% (20 of 29)
Covered branches:4
Total branches:4
Branch coverage:100% (4 of 4)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor()-100%100%
.ctor(...)-100%100%
CreateClientAsync()-100%100%
GetAccountsAsync()-0%100%
AcquireTokenSilentAsync()-0%100%
AcquireTokenInteractiveAsync()-0%100%
AcquireTokenByUsernamePasswordAsync()-100%100%
AcquireTokenWithDeviceCodeAsync()-100%100%
AcquireTokenByRefreshToken()-100%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\identity\Azure.Identity\src\MsalPublicClient.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4using System;
 5using System.Collections.Generic;
 6using System.Security;
 7using System.Threading;
 8using System.Threading.Tasks;
 9using Azure.Core.Pipeline;
 10using Microsoft.Identity.Client;
 11using Microsoft.Identity.Client.Extensions.Msal;
 12
 13namespace Azure.Identity
 14{
 15    internal class MsalPublicClient : MsalClientBase<IPublicClientApplication>
 16    {
 17        private readonly string _redirectUrl;
 18
 10019        protected MsalPublicClient()
 20        {
 10021        }
 22
 23        public MsalPublicClient(CredentialPipeline pipeline, string tenantId, string clientId, string redirectUrl, IToke
 24824            : base(pipeline, tenantId, clientId, cacheOptions)
 25        {
 24826            _redirectUrl = redirectUrl;
 24827        }
 28
 29        protected override Task<IPublicClientApplication> CreateClientAsync()
 30        {
 6431            var authorityHost = Pipeline.AuthorityHost;
 32
 6433            var authorityUri = new UriBuilder(authorityHost.Scheme, authorityHost.Host, authorityHost.Port, TenantId ?? 
 34
 6435            PublicClientApplicationBuilder pubAppBuilder = PublicClientApplicationBuilder.Create(ClientId).WithAuthority
 36
 6437            if (!string.IsNullOrEmpty(_redirectUrl))
 38            {
 2039                pubAppBuilder = pubAppBuilder.WithRedirectUri(_redirectUrl);
 40            }
 41
 6442            return Task.FromResult(pubAppBuilder.Build());
 43        }
 44
 45        public virtual async Task<IEnumerable<IAccount>> GetAccountsAsync()
 46        {
 047            await EnsureInitializedAsync(true).ConfigureAwait(false);
 48
 049            return await Client.GetAccountsAsync().ConfigureAwait(false);
 050        }
 51
 52        public virtual async Task<AuthenticationResult> AcquireTokenSilentAsync(string[] scopes, IAccount account, bool 
 53        {
 054            await EnsureInitializedAsync(async).ConfigureAwait(false);
 55
 056            return await Client.AcquireTokenSilent(scopes, account).ExecuteAsync(async, cancellationToken).ConfigureAwai
 057        }
 58
 59        public virtual async Task<AuthenticationResult> AcquireTokenInteractiveAsync(string[] scopes, Prompt prompt, boo
 60        {
 061            await EnsureInitializedAsync(async).ConfigureAwait(false);
 62
 063            return await Client.AcquireTokenInteractive(scopes).WithPrompt(prompt).ExecuteAsync(async, cancellationToken
 064        }
 65
 66        public virtual async Task<AuthenticationResult> AcquireTokenByUsernamePasswordAsync(string[] scopes, string user
 67        {
 1268            await EnsureInitializedAsync(async).ConfigureAwait(false);
 69
 1270            return await Client.AcquireTokenByUsernamePassword(scopes, username, password).ExecuteAsync(async, cancellat
 1271        }
 72
 73        public virtual async Task<AuthenticationResult> AcquireTokenWithDeviceCodeAsync(string[] scopes, Func<DeviceCode
 74        {
 2075            await EnsureInitializedAsync(async).ConfigureAwait(false);
 76
 2077            return await Client.AcquireTokenWithDeviceCode(scopes, deviceCodeCallback).ExecuteAsync(async, cancellationT
 878        }
 79
 80        public virtual async Task<AuthenticationResult> AcquireTokenByRefreshToken(string[] scopes, string refreshToken,
 81        {
 6482            await EnsureInitializedAsync(async).ConfigureAwait(false);
 83
 6484            return await ((IByRefreshToken)Client).AcquireTokenByRefreshToken(scopes, refreshToken).WithAuthority(azureC
 6085        }
 86    }
 87}