< Summary

Class:Azure.Identity.MsalConfidentialClient
Assembly:Azure.Identity
File(s):C:\Git\azure-sdk-for-net\sdk\identity\Azure.Identity\src\MsalConfidentialClient.cs
Covered lines:19
Uncovered lines:0
Coverable lines:19
Total lines:65
Line coverage:100% (19 of 19)
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%
.ctor(...)-100%100%
CreateClientAsync()-100%100%
AcquireTokenForClientAsync()-100%100%

File(s)

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

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4using System;
 5using System.Security.Cryptography.X509Certificates;
 6using System.Threading;
 7using System.Threading.Tasks;
 8using Microsoft.Identity.Client;
 9using Microsoft.Identity.Client.Extensions.Msal;
 10
 11namespace Azure.Identity
 12{
 13    internal class MsalConfidentialClient : MsalClientBase<IConfidentialClientApplication>
 14    {
 15        private readonly string _clientSecret;
 16        private readonly ClientCertificateCredential.IX509Certificate2Provider _certificateProvider;
 17
 18        /// <summary>
 19        /// For mocking purposes only.
 20        /// </summary>
 21        protected MsalConfidentialClient()
 3222            : base()
 23        {
 3224        }
 25
 26        public MsalConfidentialClient(CredentialPipeline pipeline, string tenantId, string clientId, string clientSecret
 2027            : base(pipeline, tenantId, clientId, cacheOptions)
 28        {
 2029            _clientSecret = clientSecret;
 2030        }
 31
 32        public MsalConfidentialClient(CredentialPipeline pipeline, string tenantId, string clientId, ClientCertificateCr
 5633            : base(pipeline, tenantId, clientId, cacheOptions)
 34        {
 5635            _certificateProvider = certificateProvider;
 5636        }
 37
 38        protected override async Task<IConfidentialClientApplication> CreateClientAsync()
 39        {
 6840            ConfidentialClientApplicationBuilder confClientBuilder = ConfidentialClientApplicationBuilder.Create(ClientI
 41
 6842            if (_clientSecret != null)
 43            {
 1644                confClientBuilder.WithClientSecret(_clientSecret);
 45            }
 46
 6847            if (_certificateProvider != null)
 48            {
 5249                X509Certificate2 clientCertificate = await _certificateProvider.GetCertificateAsync(true, default).Confi
 50
 3651                confClientBuilder.WithCertificate(clientCertificate);
 52            }
 53
 5254            return confClientBuilder.Build();
 55
 5256        }
 57
 58        public virtual async Task<AuthenticationResult> AcquireTokenForClientAsync(string[] scopes, bool async, Cancella
 59        {
 10060            await EnsureInitializedAsync(async).ConfigureAwait(false);
 61
 6862            return await Client.AcquireTokenForClient(scopes).ExecuteAsync(async, cancellationToken).ConfigureAwait(fals
 4863        }
 64    }
 65}