-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Make the client using streams the default. Using strings is not sustainable (#359) * bump gh upload action * Update to .NET 6 (#361) * refactor loggerhandler (#273) * refactor loggerhandler * support multipe loglevel for exceptions * better logger format in CI * add test for logging * add test for default logging output * set defaultrequestversion in DependencyInjectionSetup * use SocketsHttpHandler * add NotFoundMiddleware add ClientBuilder * remove ClientFactory uses * refactor errorhandler * remove HttpVersion from clientbuilder invocations --------- Co-authored-by: Henrik <[email protected]>
- Loading branch information
Showing
36 changed files
with
640 additions
and
131 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
66 changes: 66 additions & 0 deletions
66
commercetools.Sdk/IntegrationTests/commercetools.Api.IntegrationTests/MiddlewareTest.cs
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,66 @@ | ||
using System.Collections.Generic; | ||
using commercetools.Base.Client; | ||
using commercetools.Base.Client.Middlewares; | ||
using commercetools.Sdk.Api; | ||
using commercetools.Sdk.Api.Client; | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Xunit; | ||
|
||
namespace commercetools.Api.IntegrationTests; | ||
|
||
public class MiddlewareTest | ||
{ | ||
[Fact] | ||
public async void not_found_middleware_stream_client() | ||
{ | ||
var configuration = new ConfigurationBuilder(). | ||
AddJsonFile("appsettings.test.Development.json", true). | ||
AddEnvironmentVariables(). | ||
AddUserSecrets<ServiceProviderFixture>(). | ||
AddEnvironmentVariables("CTP_"). | ||
Build(); | ||
|
||
var s = new ServiceCollection(); | ||
s.UseCommercetoolsApi(configuration, "Client", options: new ClientOptions() { ReadResponseAsStream = true},middlewares: new List<DelegatingMiddleware>() | ||
{ | ||
new NotFoundMiddleware() | ||
}); | ||
var p = s.BuildServiceProvider(); | ||
|
||
var apiConfig = configuration.GetSection("Client").Get<ClientConfiguration>(); | ||
var apiRoot = p.GetService<ProjectApiRoot>(); | ||
|
||
Assert.Equal("Client", apiRoot.ClientName); | ||
var category = await apiRoot.Categories().WithKey("unknown-key").Get().ExecuteAsync().ConfigureAwait(false); | ||
|
||
Assert.Null(category); | ||
} | ||
|
||
[Fact] | ||
public async void not_found_middleware_string_client() | ||
{ | ||
var configuration = new ConfigurationBuilder(). | ||
AddJsonFile("appsettings.test.Development.json", true). | ||
AddEnvironmentVariables(). | ||
AddUserSecrets<ServiceProviderFixture>(). | ||
AddEnvironmentVariables("CTP_"). | ||
Build(); | ||
|
||
var s = new ServiceCollection(); | ||
s.UseCommercetoolsApi(configuration, "Client", options: new ClientOptions() { ReadResponseAsStream = false},middlewares: new List<DelegatingMiddleware>() | ||
{ | ||
new NotFoundMiddleware() | ||
}); | ||
var p = s.BuildServiceProvider(); | ||
|
||
var apiConfig = configuration.GetSection("Client").Get<ClientConfiguration>(); | ||
var apiRoot = p.GetService<ProjectApiRoot>(); | ||
|
||
Assert.Equal("Client", apiRoot.ClientName); | ||
var category = await apiRoot.Categories().WithKey("unknown-key").Get().ExecuteAsync().ConfigureAwait(false); | ||
|
||
Assert.Null(category); | ||
} | ||
|
||
} |
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
Oops, something went wrong.