Skip to content

Commit

Permalink
Merge branch 'release/1.12.0'
Browse files Browse the repository at this point in the history
Release 1.12.0
  • Loading branch information
nickvandegroes committed Sep 10, 2019
2 parents d532d15 + eede8dd commit 5b21242
Show file tree
Hide file tree
Showing 44 changed files with 1,500 additions and 85 deletions.
46 changes: 33 additions & 13 deletions .idea/.idea.BunqSdk/.idea/contentModel.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/.idea.BunqSdk/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions .idea/.idea.BunqSdk/riderModule.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions BunqSdk.Tests/BunqSdk.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework>
<RootNamespace>Bunq.Sdk.Tests</RootNamespace>
<LangVersion>default</LangVersion>
<AssemblyName>BunqSdk.Tests.xunit.runner.json</AssemblyName>
<TargetFramework>netcoreapp2.2</TargetFramework>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\BunqSdk\BunqSdk.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0-*" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0-*" />
<PackageReference Include="xunit" Version="2.2.0-*" />
<DotNetCliToolReference Include="dotnet-xunit" Version="2.2.0-*" />
<PackageReference Include="MSTest.TestAdapter" Version="1.4.0" />
<PackageReference Include="MSTest.TestFramework" Version="2.0.0-beta4" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" />
<PackageReference Include="xunit.runners" Version="2.0.0" />
</ItemGroup>
<ItemGroup>
<Content Include="xunit.runner.json">
Expand Down
86 changes: 86 additions & 0 deletions BunqSdk.Tests/Context/Psd2ApiContextTest.cs
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;
}
}
}
111 changes: 111 additions & 0 deletions BunqSdk.Tests/Model/Core/NotificationFilterTest.cs
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;
}
}
}
2 changes: 1 addition & 1 deletion BunqSdk.Tests/Model/Generated/Endpoint/CardDebitTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ public void TestOrderNewMaestroCard()
var cardDebit = CardDebit.Create(
GenerateRandomSecondLine(),
GetAnAllowedName(),
GetAlias(),
CardTypeMaestro,
GetAlias(),
allCardPinAssignments
).Value;

Expand Down
Loading

0 comments on commit 5b21242

Please sign in to comment.