示例#1
0
        public void generate_request_with_raw_body_includes_body_hash()
        {
            var session = new OAuthSession(new OAuthConsumerContext {
                ConsumerKey = "consumer", UseHeaderForOAuthParameters = true
            }, "http://localhost/request", "http://localhost/userauth",
                                           "http://localhost/access");

            var accessToken = new TokenBase {
                ConsumerKey = "consumer", Token = "token", TokenSecret = "secret"
            };

            byte[] rawContents = Encoding.UTF8.GetBytes("Hello World!");

            IConsumerRequest content = session
                                       .EnableOAuthRequestBodyHashes()
                                       .Request(accessToken)
                                       .Post()
                                       .ForUrl("http://localhost/resource")
                                       .WithRawContent(rawContents);

            RequestDescription description = content.GetRequestDescription();

            Assert.Equal(rawContents, description.RawBody);

            Assert.Contains("oauth_body_hash=\"Lve95gjOVATpfV8EL5X4nxwjKHE%3D\"", description.Headers[Parameters.OAuth_Authorization_Header]);
        }