< Summary

Class:Azure.Core.AzureKeyCredentialPolicy
Assembly:Azure.Data.Tables
File(s):C:\Git\azure-sdk-for-net\sdk\core\Azure.Core\src\Shared\AzureKeyCredentialPolicy.cs
Covered lines:0
Uncovered lines:9
Coverable lines:9
Total lines:33
Line coverage:0% (0 of 9)
Covered branches:0
Total branches:0

Metrics

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

File(s)

C:\Git\azure-sdk-for-net\sdk\core\Azure.Core\src\Shared\AzureKeyCredentialPolicy.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4using Azure.Core.Pipeline;
 5
 6namespace Azure.Core
 7{
 8    internal class AzureKeyCredentialPolicy : HttpPipelineSynchronousPolicy
 9    {
 10        private readonly string _name;
 11        private readonly AzureKeyCredential _credential;
 12
 13        /// <summary>
 14        /// Initializes a new instance of the <see cref="AzureKeyCredentialPolicy"/> class.
 15        /// </summary>
 16        /// <param name="credential">The <see cref="AzureKeyCredential"/> used to authenticate requests.</param>
 17        /// <param name="name">The name of the key header used for the credential.</param>
 018        public AzureKeyCredentialPolicy(AzureKeyCredential credential, string name)
 19        {
 020            Argument.AssertNotNull(credential, nameof(credential));
 021            Argument.AssertNotNullOrEmpty(name, nameof(name));
 022            _credential = credential;
 023            _name = name;
 024        }
 25
 26        /// <inheritdoc/>
 27        public override void OnSendingRequest(HttpMessage message)
 28        {
 029            base.OnSendingRequest(message);
 030            message.Request.Headers.SetValue(_name, _credential.Key);
 031        }
 32    }
 33}

Methods/Properties

.ctor(...)
OnSendingRequest(...)