-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add support for PATCH in HttpConnection.ConvertHttpMethod Signed-off-by: Assaf Tirangel <[email protected]> * Fix test Signed-off-by: Thomas Farr <[email protected]> --------- Signed-off-by: Assaf Tirangel <[email protected]> Signed-off-by: Thomas Farr <[email protected]> Co-authored-by: Assaf Tirangel <[email protected]> Co-authored-by: Thomas Farr <[email protected]>
- Loading branch information
1 parent
4e38cb6
commit 4e721ee
Showing
8 changed files
with
91 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
using System; | ||
using System.Net.Http; | ||
using FluentAssertions; | ||
using OpenSearch.Net; | ||
using OpenSearch.OpenSearch.Xunit.XunitPlumbing; | ||
using Tests.Core.Connection.Http; | ||
using Xunit; | ||
using HttpMethod = OpenSearch.Net.HttpMethod; | ||
|
||
namespace Tests.Connection.Http; | ||
|
||
public class HttpConnectionTests | ||
{ | ||
public static TheoryData<HttpMethod> HttpMethods() | ||
{ | ||
var data = new TheoryData<HttpMethod>(); | ||
foreach (var httpMethod in Enum.GetValues<HttpMethod>()) data.Add(httpMethod); | ||
return data; | ||
} | ||
|
||
[TU] | ||
[MemberData(nameof(HttpMethods))] | ||
public void UsesCorrectHttpMethod(HttpMethod method) | ||
{ | ||
HttpRequestMessage sentRequest = null; | ||
var connection = new MockableHttpConnection(r => | ||
{ | ||
sentRequest = r; | ||
return new HttpResponseMessage(); | ||
}); | ||
var client = new OpenSearchLowLevelClient(new ConnectionConfiguration(connection: connection)); | ||
|
||
client.DoRequest<VoidResponse>(method, "/"); | ||
|
||
sentRequest.ShouldHaveMethod(method.ToString()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
using System.Net.Http; | ||
using OpenSearch.Net; | ||
using Tests.Core.Connection.Http; | ||
|
||
namespace Tests.Connection.Http; | ||
|
||
public class MockableHttpConnection : HttpConnection | ||
{ | ||
private readonly MockHttpMessageHandler _handler; | ||
|
||
public MockableHttpConnection(MockHttpMessageHandler.Handler handler) => | ||
_handler = new MockHttpMessageHandler(handler); | ||
|
||
protected override HttpMessageHandler CreateHttpClientHandler(RequestData requestData) => _handler; | ||
} |