Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed tests, build on Arch Linux #416

Merged
merged 4 commits into from
Jun 20, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions tests/JWT.Tests.Common/Algorithms/RSAlgorithmFactoryTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Security.Cryptography;
using AutoFixture;
using FluentAssertions;
using JWT.Algorithms;
using JWT.Builder;
Expand All @@ -10,12 +9,10 @@ namespace JWT.Tests.Algorithms
[TestClass]
public class RSAlgorithmFactoryTests
{
private static readonly Fixture _fixture = new Fixture();

[TestMethod]
public void Create_Should_Return_Instance_Of_RS256Algorithm_When_Algorithm_Specified_In_Jwt_Header_Is_RS256()
{
var publicKey = _fixture.Create<RSACryptoServiceProvider>();
var publicKey = new RSACryptoServiceProvider();
var factory = new RSAlgorithmFactory(publicKey);
var context = new JwtDecoderContext
{
Expand All @@ -33,7 +30,7 @@ public void Create_Should_Return_Instance_Of_RS256Algorithm_When_Algorithm_Speci
[TestMethod]
public void Create_Should_Return_Instance_Of_RS384Algorithm_When_Algorithm_Specified_In_Jwt_Header_Is_RS384()
{
var publicKey = _fixture.Create<RSACryptoServiceProvider>();
var publicKey = RSACryptoServiceProvider;
var factory = new RSAlgorithmFactory(publicKey);
var context = new JwtDecoderContext
{
Expand All @@ -51,7 +48,7 @@ public void Create_Should_Return_Instance_Of_RS384Algorithm_When_Algorithm_Speci
[TestMethod]
public void Create_Should_Return_Instance_Of_RS512Algorithm_When_Algorithm_Specified_In_Jwt_Header_Is_RS512()
{
var publicKey = _fixture.Create<RSACryptoServiceProvider>();
var publicKey = new RSACryptoServiceProvider();
var factory = new RSAlgorithmFactory(publicKey);
var context = new JwtDecoderContext
{
Expand All @@ -69,7 +66,8 @@ public void Create_Should_Return_Instance_Of_RS512Algorithm_When_Algorithm_Speci
[TestMethod]
public void Create_Should_Return_Instance_Of_RS1024Algorithm_When_Algorithm_Specified_In_Jwt_Header_Is_RS1024()
{
var publicKey = _fixture.Create<RSACryptoServiceProvider>();
var publicKey = RSACryptoServiceProvider;

var factory = new RSAlgorithmFactory(publicKey);
var context = new JwtDecoderContext
{
Expand All @@ -87,7 +85,7 @@ public void Create_Should_Return_Instance_Of_RS1024Algorithm_When_Algorithm_Spec
[TestMethod]
public void Create_Should_Return_Instance_Of_RS2048Algorithm_When_Algorithm_Specified_In_Jwt_Header_Is_RS2048()
{
var publicKey = _fixture.Create<RSACryptoServiceProvider>();
var publicKey = new RSACryptoServiceProvider();
var factory = new RSAlgorithmFactory(publicKey);
var context = new JwtDecoderContext
{
Expand All @@ -105,7 +103,7 @@ public void Create_Should_Return_Instance_Of_RS2048Algorithm_When_Algorithm_Spec
[TestMethod]
public void Create_Should_Return_Instance_Of_RS4096Algorithm_When_Algorithm_Specified_In_Jwt_Header_Is_RS4096()
{
var publicKey = _fixture.Create<RSACryptoServiceProvider>();
var publicKey = new RSACryptoServiceProvider();
var factory = new RSAlgorithmFactory(publicKey);
var context = new JwtDecoderContext
{
Expand Down
9 changes: 3 additions & 6 deletions tests/JWT.Tests.Common/Algorithms/RSAlgorithmTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
using AutoFixture;
using FluentAssertions;
using JWT.Algorithms;
using JWT.Tests.Models;
Expand All @@ -13,13 +12,11 @@ namespace JWT.Tests.Algorithms
[TestClass]
public class RSAlgorithmTests
{
private static readonly Fixture _fixture = new Fixture();

[DynamicData(nameof(GetFactoryWithPublicPrivateKey), DynamicDataSourceType.Method)]
[DataTestMethod]
public void Ctor_Should_Throw_Exception_When_PublicKey_Is_Null(Func<RSA, RSA, RSAlgorithm> algFactory)
{
var privateKey = _fixture.Create<RSACryptoServiceProvider>();
var privateKey = new RSACryptoServiceProvider();

Action action = () => algFactory(null, privateKey);

Expand All @@ -31,7 +28,7 @@ public void Ctor_Should_Throw_Exception_When_PublicKey_Is_Null(Func<RSA, RSA, RS
[DataTestMethod]
public void Ctor_Should_Throw_Exception_When_PrivateKey_Is_Null(Func<RSA, RSA, RSAlgorithm> algFactory)
{
var publicKey = _fixture.Create<RSACryptoServiceProvider>();
var publicKey = new RSACryptoServiceProvider();

Action action = () => algFactory(publicKey, null);

Expand All @@ -43,7 +40,7 @@ public void Ctor_Should_Throw_Exception_When_PrivateKey_Is_Null(Func<RSA, RSA, R
[DataTestMethod]
public void Sign_Should_Throw_Exception_When_PrivateKey_Is_Null(Func<RSA, RSAlgorithm> algFactory)
{
var publicKey = _fixture.Create<RSACryptoServiceProvider>();
var publicKey = new RSACryptoServiceProvider();
var alg = algFactory(publicKey);

var bytesToSign = Array.Empty<byte>();
Expand Down