Esempio n. 1
0
        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);
                    }
        }
Esempio n. 2
0
        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));
                    }
        }
Esempio n. 3
0
        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()));
                    }
        }