-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Release 1.12.0
- Loading branch information
Showing
44 changed files
with
1,500 additions
and
85 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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 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,86 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using Bunq.Sdk.Context; | ||
using Bunq.Sdk.Json; | ||
using Bunq.Sdk.Model.Generated.Endpoint; | ||
using Bunq.Sdk.Security; | ||
using Bunq.Sdk.Tests.Util; | ||
using Xunit; | ||
using Assert = Xunit.Assert; | ||
|
||
namespace Bunq.Sdk.Tests.Context | ||
{ | ||
[TestCaseOrderer("Bunq.Sdk.Tests.Util.TestPriorityOrderer", "Psd2ApiContextTest")] | ||
public class Psd2ApiContextTest: IClassFixture<Psd2ApiContextTest> | ||
{ | ||
/// <summary> | ||
/// File constants. | ||
/// </summary> | ||
private const string FILE_TEST_CONFIGURATION = "../../../Resources/bunq-psd2-test.conf"; | ||
private const string FILE_TEST_OAUTH = "../../../Resources/bunq-oauth-test.conf"; | ||
|
||
private const string FILE_TEST_CREDENTIALS = "../../../Resources/credentials.pfx"; | ||
private const string FILE_TEST_CERTIFICATE_CHAIN = "../../../Resources/chain.cert"; | ||
|
||
/// <summary> | ||
/// Test constants. | ||
/// </summary> | ||
private const string TEST_DEVICE_DESCRIPTION = "PSD2TestDevice"; | ||
private const string TEST_PASSPHRASE_CREDENTIALS = "secret"; | ||
|
||
[Fact, TestPriority(1)] | ||
public void TestCreatePsd2Context() | ||
{ | ||
ApiContext apiContext = null; | ||
if (File.Exists(FILE_TEST_CONFIGURATION)) | ||
{ | ||
apiContext = ApiContext.Restore(FILE_TEST_CONFIGURATION); | ||
Assert.NotNull(apiContext); | ||
|
||
BunqContext.LoadApiContext(apiContext); | ||
return; | ||
} | ||
|
||
apiContext = CreateApiContext(); | ||
BunqContext.LoadApiContext(apiContext); | ||
|
||
Assert.True(File.Exists(FILE_TEST_CONFIGURATION)); | ||
} | ||
|
||
[Fact, TestPriority(0)] | ||
public void TestCreateOauthClient() | ||
{ | ||
if (File.Exists(FILE_TEST_OAUTH)) | ||
{ | ||
return; | ||
} | ||
|
||
int clientId = OauthClient.Create().Value; | ||
OauthClient oauthClient = OauthClient.Get(clientId).Value; | ||
Assert.NotNull(oauthClient); | ||
|
||
File.WriteAllText( | ||
FILE_TEST_OAUTH, | ||
BunqJsonConvert.SerializeObject(oauthClient) | ||
); | ||
Assert.True(File.Exists(FILE_TEST_OAUTH)); | ||
} | ||
|
||
private ApiContext CreateApiContext() | ||
{ | ||
ApiContext apiContext = ApiContext.CreateForPsd2( | ||
ApiEnvironmentType.SANDBOX, | ||
SecurityUtils.GetCertificateFromFile(FILE_TEST_CREDENTIALS, TEST_PASSPHRASE_CREDENTIALS), | ||
SecurityUtils.GetCertificateCollectionFromAllPath( | ||
new[] { FILE_TEST_CERTIFICATE_CHAIN } | ||
), | ||
TEST_DEVICE_DESCRIPTION, | ||
new List<string>() | ||
); | ||
apiContext.Save(FILE_TEST_CONFIGURATION); | ||
|
||
return apiContext; | ||
} | ||
} | ||
} |
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,111 @@ | ||
using System.Collections.Generic; | ||
using Bunq.Sdk.Context; | ||
using Bunq.Sdk.Model.Core; | ||
using Bunq.Sdk.Model.Generated.Endpoint; | ||
using Bunq.Sdk.Model.Generated.Object; | ||
using Xunit; | ||
|
||
namespace Bunq.Sdk.Tests.Model.Core | ||
{ | ||
/// <summary> | ||
/// Tests: | ||
/// NotificationFilterUrlMonetaryAccountInternal | ||
/// NotificationFilterUrlUserInternal | ||
/// NotificationFilterPushUserInternal | ||
/// </summary> | ||
public class NotificationFilterTest: BunqSdkTestBase, IClassFixture<NotificationFilterTest> | ||
{ | ||
/// <summary> | ||
/// Filter constants. | ||
/// </summary> | ||
private const string FILTER_CATEGORY_MUTATION = "MUTATION"; | ||
private const string FILTER_CALLBACK_URL = "https://test.com/callback"; | ||
|
||
/// <summary> | ||
/// Test NotificationFilterUrlMonetaryAccount creation. | ||
/// </summary> | ||
[Fact] | ||
public void TestNotificationFilterUrlMonetaryAccount() | ||
{ | ||
SetUpApiContext(); | ||
|
||
NotificationFilterUrl notificationFilter = GetNotificationFilterUrl(); | ||
List<NotificationFilterUrl> allCreatedNotificationFilter = NotificationFilterUrlMonetaryAccountInternal.CreateWithListResponse( | ||
GetPrimaryMonetaryAccount().Id.Value, | ||
new List<NotificationFilterUrl>() {notificationFilter} | ||
).Value; | ||
|
||
Assert.True(allCreatedNotificationFilter.Count == 1); | ||
} | ||
|
||
/// <summary> | ||
/// Test NotificationFilterUrlUser creation. | ||
/// </summary> | ||
[Fact] | ||
public void TestNotificationFilterUrlUser() | ||
{ | ||
SetUpApiContext(); | ||
|
||
NotificationFilterUrl notificationFilter = GetNotificationFilterUrl(); | ||
List<NotificationFilterUrl> allCreatedNotificationFilter = NotificationFilterUrlUserInternal.CreateWithListResponse( | ||
new List<NotificationFilterUrl>() {notificationFilter} | ||
).Value; | ||
|
||
Assert.True(allCreatedNotificationFilter.Count == 1); | ||
} | ||
/// <summary> | ||
/// Test NotificationFilterPushUser creation. | ||
/// </summary> | ||
[Fact] | ||
public void TestNotificationFilterPushUser() | ||
{ | ||
SetUpApiContext(); | ||
|
||
NotificationFilterPush notificationFilter = GetNotificationFilterPush(); | ||
List<NotificationFilterPush> allCreatedNotificationFilter = NotificationFilterPushUserInternal.CreateWithListResponse( | ||
new List<NotificationFilterPush>() {notificationFilter} | ||
).Value; | ||
|
||
Assert.True(allCreatedNotificationFilter.Count == 1); | ||
} | ||
|
||
/// <summary> | ||
/// Test clear all filters. | ||
/// </summary> | ||
[Fact] | ||
public void TestNotificationFilterClear() | ||
{ | ||
SetUpApiContext(); | ||
|
||
List<NotificationFilterPush> allCreatedNotificationFilterPushUser = | ||
NotificationFilterPushUserInternal.CreateWithListResponse().Value; | ||
List<NotificationFilterUrl> allCreatedNotificationFilterUrlUser = | ||
NotificationFilterUrlUserInternal.CreateWithListResponse().Value; | ||
List<NotificationFilterUrl> allCreatedNotificationFilterUrlMonetaryAccount = | ||
NotificationFilterUrlMonetaryAccountInternal.CreateWithListResponse().Value; | ||
|
||
Assert.Empty(allCreatedNotificationFilterPushUser); | ||
Assert.Empty(allCreatedNotificationFilterUrlUser); | ||
Assert.Empty(allCreatedNotificationFilterUrlMonetaryAccount); | ||
|
||
Assert.StrictEqual(0, NotificationFilterPushUserInternal.List().Value.Count); | ||
Assert.StrictEqual(0, NotificationFilterUrlUserInternal.List().Value.Count); | ||
Assert.StrictEqual(0, NotificationFilterUrlMonetaryAccountInternal.List().Value.Count); | ||
} | ||
|
||
private NotificationFilterUrl GetNotificationFilterUrl() | ||
{ | ||
return new NotificationFilterUrl(FILTER_CATEGORY_MUTATION, FILTER_CALLBACK_URL); | ||
} | ||
|
||
private NotificationFilterPush GetNotificationFilterPush() | ||
{ | ||
return new NotificationFilterPush(FILTER_CATEGORY_MUTATION); | ||
} | ||
|
||
private MonetaryAccountBank GetPrimaryMonetaryAccount() | ||
{ | ||
return BunqContext.UserContext.PrimaryMonetaryAccountBank; | ||
} | ||
} | ||
} |
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.