示例#1
0
        public async Task GetParameter_UriQueryTest()
        {
            var requestUri = new Uri("http://example.com/api?aaa=1&bbb=2");

            var actual = await OAuthHandler.GetParameters(requestUri, content : null)
                         .ConfigureAwait(false);

            var expected = new[]
            {
                new KeyValuePair <string, string>("aaa", "1"),
                new KeyValuePair <string, string>("bbb", "2"),
            };

            Assert.Equal(expected, actual);
        }
示例#2
0
        public async Task GetParameter_MultipartTest()
        {
            var requestUri = new Uri("http://example.com/api");

            using var content = new MultipartFormDataContent();
            using var paramA  = new StringContent("1");
            using var paramB  = new StringContent("2");
            content.Add(paramA, "aaa");
            content.Add(paramB, "bbb");

            var actual = await OAuthHandler.GetParameters(requestUri, content)
                         .ConfigureAwait(false);

            // multipart/form-data のリクエストではパラメータを署名対象にしない
            Assert.Empty(actual);
        }
示例#3
0
        public async Task GetParameter_FormUrlEncodedTest()
        {
            var requestUri = new Uri("http://example.com/api");
            var formParams = new[]
            {
                new KeyValuePair <string, string>("aaa", "1"),
                new KeyValuePair <string, string>("bbb", "2"),
            };

            using var content = new FormUrlEncodedContent(formParams);
            var actual = await OAuthHandler.GetParameters(requestUri, content)
                         .ConfigureAwait(false);

            var expected = new[]
            {
                new KeyValuePair <string, string>("aaa", "1"),
                new KeyValuePair <string, string>("bbb", "2"),
            };

            Assert.Equal(expected, actual);
        }