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)); }
public static HttpPipeline BuildHttpPipline(this ClientOptions options, ConnectionString connectionString) { var authPolicy = new HMACAuthenticationPolicy(connectionString.GetRequired("accesskey")); return(HttpPipelineBuilder.Build(options, authPolicy)); }
public static HttpPipeline BuildHttpPipeline(this ClientOptions options, AzureKeyCredential keyCredential) { var authPolicy = new HMACAuthenticationPolicy(keyCredential); return(HttpPipelineBuilder.Build(options, authPolicy)); }