public async void authorization_header_is_set_with_correct_schema() { using (InspectionMessageHandler inspector = new InspectionMessageHandler()) using (HmacClientHandler hmacHandler = new HmacClientHandler(inspector, appId, secret, new HmacSigningAlgorithm(sb => new HMACSHA256(sb)))) using (HttpClient client = new HttpClient(hmacHandler)) { await client.SendAsync(new HttpRequestMessage(HttpMethod.Get, "http://localhost/foo")); var req = inspector.LastRequest; Assert.Equal(Schemas.HMAC, req.Headers.Authorization.Scheme); } }
public async void authorization_header_parameter_is_not_null() { using (InspectionMessageHandler inspector = new InspectionMessageHandler()) using (HmacClientHandler hmacHandler = new HmacClientHandler(inspector, appId, secret, new HmacSigningAlgorithm(sb => new HMACSHA256(sb)))) using (HttpClient client = new HttpClient(hmacHandler)) { await client.SendAsync(new HttpRequestMessage(HttpMethod.Get, "http://localhost/foo")); var req = inspector.LastRequest; Assert.False(string.IsNullOrWhiteSpace(req.Headers.Authorization.Parameter)); } }
public async void custom_headers_are_added_to_request() { using (InspectionMessageHandler inspector = new InspectionMessageHandler()) using (HmacClientHandler hmacHandler = new HmacClientHandler(inspector, appId, secret, new HmacSigningAlgorithm(sb => new HMACSHA256(sb)))) using (HttpClient client = new HttpClient(hmacHandler)) { await client.SendAsync(new HttpRequestMessage(HttpMethod.Get, "http://localhost/foo")); var req = inspector.LastRequest; Assert.Equal(appId, req.Headers.GetValues(Headers.XAppId).First()); Assert.False(string.IsNullOrWhiteSpace(req.Headers.GetValues(Headers.XNonce).FirstOrDefault())); } }