-
-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add unit tests for permissionclient * Add unit tests for ConnectClient * Bugfix use correct links for capture * Add more assert statements to verify the settlement and capture response classes * add unit tests for verify that balance links are deserialized correctly * Add missing Dashboard link in ProfileResponse * Add unit tests for GetProfileListAsync * Add unit tests for QR code deserialisation and Credit card specific response parameters * Add missing ShippingAddress to PayPalPaymentResponse class * Add more payment method specific unit tests * Remove unused code * Add unit tests for DictionaryExtensions.AddValueIfTrue * Bugfix where banktransfer specific links were not deserialized * Add unit tests for retrieving banktransfer specific details * Add unit tests for retrieving gift card specific details * Add unit test for CreateOrderRefundAsync method * Expand unit test to retrieve a payment by testing alot more additional properties * Add more unit tests to verify deserializing various payment specific details are deserialized correctly * Add more tests to cover payment specific requests
- Loading branch information
1 parent
010c27c
commit a18de0f
Showing
20 changed files
with
1,959 additions
and
535 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
19 changes: 0 additions & 19 deletions
19
src/Mollie.Api/ContractResolvers/DeliminatorSeparatedPropertyNamesContractResolver.cs
This file was deleted.
Oops, something went wrong.
6 changes: 0 additions & 6 deletions
6
src/Mollie.Api/ContractResolvers/SnakeCasePropertyNamesContractResolver.cs
This file was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
src/Mollie.Api/JsonConverters/BalanceReportResponseJsonConverter.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
22 changes: 17 additions & 5 deletions
22
src/Mollie.Api/Models/Capture/Response/CaptureResponseLinks.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
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,91 @@ | ||
using System.Collections.Generic; | ||
using System.Net; | ||
using System.Net.Http; | ||
using System.Threading.Tasks; | ||
using FluentAssertions; | ||
using Mollie.Api.Client; | ||
using Mollie.Api.Models.Connect; | ||
using RichardSzalay.MockHttp; | ||
using Xunit; | ||
|
||
namespace Mollie.Tests.Unit.Client; | ||
|
||
public class ConnectClientTests : BaseClientTests | ||
{ | ||
private const string ClientId = "client-id"; | ||
private const string ClientSecret = "client-secret"; | ||
|
||
[Fact] | ||
public void GetAuthorizationUrl_WithSingleScope_GeneratesAuthorizationUrl() | ||
{ | ||
// Arrange | ||
HttpClient httpClient = new HttpClient(); | ||
ConnectClient connectClient = new ConnectClient(ClientId, ClientSecret, httpClient); | ||
var scopes = new List<string> {AppPermissions.PaymentsRead}; | ||
|
||
// Act | ||
string authorizationUrl = connectClient.GetAuthorizationUrl("abcde", scopes); | ||
|
||
// Assert | ||
string expectedUrl = $"https://www.mollie.com/oauth2/authorize?client_id={ClientId}&state=abcde&scope=payments.read&response_type=code&approval_prompt=auto"; | ||
authorizationUrl.Should().Be(expectedUrl); | ||
} | ||
|
||
[Theory] | ||
[InlineData("refresh_abcde", "refresh_token")] | ||
[InlineData("abcde", "authorization_code")] | ||
public async Task GetAccessTokenAsync_WithRefreshToken_ResponseIsDeserializedInExpectedFormat(string refreshToken, string expectedGrantType) | ||
{ | ||
// Arrange | ||
var mockHttp = new MockHttpMessageHandler(); | ||
mockHttp.Expect(HttpMethod.Post, "https://api.mollie.nl/oauth2/tokens") | ||
.Respond("application/json", defaultGetTokenResponse); | ||
HttpClient httpClient = mockHttp.ToHttpClient(); | ||
ConnectClient connectClient = new ConnectClient(ClientId, ClientSecret, httpClient); | ||
var tokenRequest = new TokenRequest(refreshToken, DefaultRedirectUrl); | ||
|
||
// Act | ||
TokenResponse tokenResponse = await connectClient.GetAccessTokenAsync(tokenRequest); | ||
|
||
// Assert | ||
mockHttp.VerifyNoOutstandingExpectation(); | ||
tokenRequest.GrantType.Should().Be(expectedGrantType); | ||
tokenResponse.Should().NotBeNull(); | ||
tokenResponse.AccessToken.Should().Be("access_46EUJ6x8jFJZZeAvhNH4JVey6qVpqR"); | ||
tokenResponse.RefreshToken.Should().Be("refresh_FS4xc3Mgci2xQ5s5DzaLXh3HhaTZOP"); | ||
tokenResponse.ExpiresIn.Should().Be(3600); | ||
tokenResponse.TokenType.Should().Be("bearer"); | ||
tokenResponse.Scope.Should().Be("payments.read organizations.read"); | ||
} | ||
|
||
[Fact] | ||
public async Task RevokeTokenAsync_SendsRequest() | ||
{ | ||
// Arrange | ||
var mockHttp = new MockHttpMessageHandler(); | ||
mockHttp.Expect(HttpMethod.Delete, "https://api.mollie.nl/oauth2/tokens") | ||
.Respond(HttpStatusCode.NoContent); | ||
HttpClient httpClient = mockHttp.ToHttpClient(); | ||
ConnectClient connectClient = new ConnectClient(ClientId, ClientSecret, httpClient); | ||
var revokeTokenRequest = new RevokeTokenRequest | ||
{ | ||
Token = "access_46EUJ6x8jFJZZeAvhNH4JVey6qVpqR", | ||
TokenTypeHint = "refresh_token" | ||
}; | ||
|
||
// Act | ||
await connectClient.RevokeTokenAsync(revokeTokenRequest); | ||
|
||
// Assert | ||
mockHttp.VerifyNoOutstandingExpectation(); | ||
} | ||
|
||
private const string defaultGetTokenResponse = @" | ||
{ | ||
""access_token"": ""access_46EUJ6x8jFJZZeAvhNH4JVey6qVpqR"", | ||
""refresh_token"": ""refresh_FS4xc3Mgci2xQ5s5DzaLXh3HhaTZOP"", | ||
""expires_in"": 3600, | ||
""token_type"": ""bearer"", | ||
""scope"": ""payments.read organizations.read"" | ||
}"; | ||
} |
Oops, something went wrong.