-
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.
Merge pull request #64 from commercetools/Fix-ValidateClientConfig
Validate Client Configuration Model
- Loading branch information
Showing
4 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
commercetools.Sdk/Tests/commercetools.Api.Tests/ClientsFactoryTests.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,49 @@ | ||
using System; | ||
using System.ComponentModel.DataAnnotations; | ||
using commercetools.Base.Client; | ||
using commercetools.Sdk.Api; | ||
using commercetools.Sdk.Api.Serialization; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Xunit; | ||
|
||
namespace commercetools.Api.Tests | ||
{ | ||
public class ClientsFactoryTests | ||
{ | ||
[Fact] | ||
public void TestClientConfigValidation() | ||
{ | ||
//arrange | ||
var s = new ServiceCollection(); | ||
s.UseCommercetoolsApiSerialization(); | ||
var p = s.BuildServiceProvider(); | ||
var serializerService = p.GetService<SerializerService>(); | ||
var clientConfig = new ClientConfiguration | ||
{ | ||
ClientId = "ClientId", | ||
ClientSecret = "ClientSecret", | ||
ProjectKey = "test", | ||
ApiBaseAddress = "https://api.europe-west1.gcp.commercetools.com", | ||
AuthorizationBaseAddress = "https://auth.europe-west1.gcp.commercetools.com/" | ||
}; | ||
|
||
//act | ||
Exception validationEx = null; | ||
try | ||
{ | ||
var tokenProvider = TokenProviderFactory | ||
.CreateClientCredentialsTokenProvider(clientConfig, null); | ||
|
||
ClientFactory.Create("test", clientConfig, null, serializerService, tokenProvider); | ||
} | ||
catch (Exception e) | ||
{ | ||
validationEx = e; | ||
} | ||
|
||
//assert | ||
Assert.NotNull(validationEx); | ||
Assert.IsType<ValidationException>(validationEx); | ||
} | ||
} | ||
} |
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