Skip to content

Commit

Permalink
Merge pull request #13 from RobinTTY/v8.0.0
Browse files Browse the repository at this point in the history
Library version v8.0.0
  • Loading branch information
RobinTTY authored Apr 27, 2024
2 parents c6aff43 + a5834d0 commit 644038d
Show file tree
Hide file tree
Showing 57 changed files with 2,977 additions and 721 deletions.
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
using Microsoft.IdentityModel.JsonWebTokens;
using RobinTTY.NordigenApiClient.Models;
using RobinTTY.NordigenApiClient.Models.Jwt;
using RobinTTY.NordigenApiClient.Utility;

namespace RobinTTY.NordigenApiClient.Tests;

internal class JsonWebTokenPairTests
/// <summary>
/// Tests aspects of authentication related to the <see cref="NordigenClientCredentials"/> and <see cref="JsonWebTokenPair"/> classes.
/// </summary>
internal class AuthenticationTests
{
private NordigenClient _apiClient = null!;

[OneTimeSetUp]
public void Setup()
/// <summary>
/// Tests creating <see cref="NordigenClientCredentials"/>, passing null as an argument.
/// </summary>
[Test]
public void CreateCredentialsWithNull()
{
_apiClient = TestExtensions.GetConfiguredClient();
Assert.Throws<ArgumentNullException>(() => { _ = new NordigenClientCredentials(null!, null!); });
}

/// <summary>
Expand Down Expand Up @@ -48,22 +53,6 @@ public void CreateInvalidJsonWebTokenPair()
Assert.Throws<ArgumentException>(() => new JsonWebTokenPair(exampleToken, exampleToken));
}

/// <summary>
/// Tests that <see cref="NordigenClient.JsonWebTokenPair" /> is populated after the first authenticated request is made.
/// </summary>
[Test]
public async Task CheckValidTokensAfterRequest()
{
Assert.That(_apiClient.JsonWebTokenPair, Is.Null);
await _apiClient.RequisitionsEndpoint.GetRequisitions(5, 0, CancellationToken.None);
Assert.Multiple(() =>
{
Assert.That(_apiClient.JsonWebTokenPair, Is.Not.Null);
Assert.That(_apiClient.JsonWebTokenPair!.AccessToken.EncodedToken, Has.Length.GreaterThan(0));
Assert.That(_apiClient.JsonWebTokenPair!.RefreshToken.EncodedToken, Has.Length.GreaterThan(0));
});
}

/// <summary>
/// Tests the token expiry extension method for correct behavior respecting time zones.
/// </summary>
Expand Down
85 changes: 0 additions & 85 deletions src/RobinTTY.NordigenApiClient.Tests/CredentialTests.cs

This file was deleted.

Loading

0 comments on commit 644038d

Please sign in to comment.