コード例 #1
0
        public async Task TestHMACPolicyProcess()
        {
            var expectedShaValue = "47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=";
            var authPolicy       = new HMACAuthenticationPolicy(SecretKey);
            var transport        = new MockTransport(new MockResponse(200));

            await SendGetRequest(transport, authPolicy);

            var headers = transport.SingleRequest.Headers;

            Assert.True(headers.Contains("Date"));
            Assert.True(headers.Contains("Authorization"));

            Assert.True(headers.TryGetValue("x-ms-content-sha256", out var shaValue));
            Assert.AreEqual(expectedShaValue, shaValue);

            var expectedAuthHeader = "HMAC-SHA256 SignedHeaders=date;host;x-ms-content-sha256";

            Assert.True(headers.TryGetValue("Authorization", out var authValue));
            Assert.NotNull(authValue);
            Assert.True(authValue !.Contains(expectedAuthHeader));
        }
コード例 #2
0
        public static HttpPipeline BuildHttpPipline(this ClientOptions options, ConnectionString connectionString)
        {
            var authPolicy = new HMACAuthenticationPolicy(connectionString.GetRequired("accesskey"));

            return(HttpPipelineBuilder.Build(options, authPolicy));
        }
コード例 #3
0
        public static HttpPipeline BuildHttpPipeline(this ClientOptions options, AzureKeyCredential keyCredential)
        {
            var authPolicy = new HMACAuthenticationPolicy(keyCredential);

            return(HttpPipelineBuilder.Build(options, authPolicy));
        }