-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* changes tests to .net core 3.1 * Adds holder-of-key support
- Loading branch information
1 parent
41a4f72
commit c610a9c
Showing
30 changed files
with
402 additions
and
760 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -349,3 +349,4 @@ MigrationBackup/ | |
|
||
# Ionide (cross platform F# VS Code tools) working folder | ||
.ionide/ | ||
*.nupkg |
158 changes: 79 additions & 79 deletions
158
src/Solid.Identity.Protocols.WsTrust.Tests/CryptoTests.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,88 +1,88 @@ | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.IdentityModel.Tokens; | ||
using Solid.Identity.Protocols.WsSecurity.Tokens; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Security.Cryptography; | ||
using System.Security.Cryptography.X509Certificates; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Xunit; | ||
//using Microsoft.Extensions.DependencyInjection; | ||
//using Microsoft.IdentityModel.Tokens; | ||
//using Solid.Identity.Protocols.WsSecurity.Tokens; | ||
//using System; | ||
//using System.Collections.Generic; | ||
//using System.Linq; | ||
//using System.Security.Cryptography; | ||
//using System.Security.Cryptography.X509Certificates; | ||
//using System.Text; | ||
//using System.Threading.Tasks; | ||
//using Xunit; | ||
|
||
namespace Solid.Identity.Protocols.WsTrust.Tests | ||
{ | ||
public class CryptoTests | ||
{ | ||
private CryptoProviderFactory _factory; | ||
//namespace Solid.Identity.Protocols.WsTrust.Tests | ||
//{ | ||
// public class CryptoTests | ||
// { | ||
// private CryptoProviderFactory _factory; | ||
|
||
public CryptoTests() | ||
{ | ||
var services = new ServiceCollection() | ||
.AddLogging() | ||
.BuildServiceProvider() | ||
; | ||
var options = new WsTrustOptions() | ||
.AddRsaSha1Support() | ||
.AddSha1Support() | ||
.AddHmacSha1Support() | ||
; | ||
CryptoProviderFactory.Default.CustomCryptoProvider = new CustomCryptoProvider(options, services); | ||
_factory = CryptoProviderFactory.Default; | ||
} | ||
// public CryptoTests() | ||
// { | ||
// var services = new ServiceCollection() | ||
// .AddLogging() | ||
// .BuildServiceProvider() | ||
// ; | ||
// var options = new WsTrustOptions() | ||
// .AddRsaSha1Support() | ||
// .AddSha1Support() | ||
// .AddHmacSha1Support() | ||
// ; | ||
// CryptoProviderFactory.Default.CustomCryptoProvider = new CustomCryptoProvider(options, services); | ||
// _factory = CryptoProviderFactory.Default; | ||
// } | ||
|
||
[Theory] | ||
[InlineData("http://www.w3.org/2000/09/xmldsig#sha1")] | ||
[InlineData("SHA1")] | ||
public void ShouldGetHashAlgorithm(string algorithm) | ||
{ | ||
Assert.True(_factory.IsSupportedAlgorithm(algorithm)); | ||
// throw exception if it can't create | ||
_ = _factory.CreateHashAlgorithm(algorithm); | ||
} | ||
// [Theory] | ||
// [InlineData("http://www.w3.org/2000/09/xmldsig#sha1")] | ||
// [InlineData("SHA1")] | ||
// public void ShouldGetHashAlgorithm(string algorithm) | ||
// { | ||
// Assert.True(_factory.IsSupportedAlgorithm(algorithm)); | ||
// // throw exception if it can't create | ||
// _ = _factory.CreateHashAlgorithm(algorithm); | ||
// } | ||
|
||
[Theory] | ||
[InlineData("http://www.w3.org/2000/09/xmldsig#rsa-sha1")] | ||
[InlineData("RS1")] | ||
public void ShouldGetAsymmetricSignatureProvider(string algorithm) | ||
{ | ||
var certificate = new X509Certificate2(Convert.FromBase64String(Certificates.SigningCertificteBase64)); | ||
var key = new X509SecurityKey(certificate); | ||
// [Theory] | ||
// [InlineData("http://www.w3.org/2000/09/xmldsig#rsa-sha1")] | ||
// [InlineData("RS1")] | ||
// public void ShouldGetAsymmetricSignatureProvider(string algorithm) | ||
// { | ||
// var certificate = new X509Certificate2(Convert.FromBase64String(Certificates.SigningCertificteBase64)); | ||
// var key = new X509SecurityKey(certificate); | ||
|
||
Assert.True(_factory.IsSupportedAlgorithm(algorithm)); | ||
// throw exception if it can't create | ||
_ = _factory.CreateForSigning(key, algorithm); | ||
_ = _factory.CreateForVerifying(key, algorithm); | ||
} | ||
// Assert.True(_factory.IsSupportedAlgorithm(algorithm)); | ||
// // throw exception if it can't create | ||
// _ = _factory.CreateForSigning(key, algorithm); | ||
// _ = _factory.CreateForVerifying(key, algorithm); | ||
// } | ||
|
||
[Theory] | ||
[InlineData("http://www.w3.org/2000/09/xmldsig#hmac-sha1")] | ||
[InlineData("H1")] | ||
public void ShouldGetSymmetricSignatureProvider(string algorithm) | ||
{ | ||
var bytes = new byte[16]; | ||
var random = RandomNumberGenerator.Create(); | ||
random.GetNonZeroBytes(bytes); | ||
var key = new SymmetricSecurityKey(bytes); | ||
// [Theory] | ||
// [InlineData("http://www.w3.org/2000/09/xmldsig#hmac-sha1")] | ||
// [InlineData("H1")] | ||
// public void ShouldGetSymmetricSignatureProvider(string algorithm) | ||
// { | ||
// var bytes = new byte[16]; | ||
// var random = RandomNumberGenerator.Create(); | ||
// random.GetNonZeroBytes(bytes); | ||
// var key = new SymmetricSecurityKey(bytes); | ||
|
||
Assert.True(_factory.IsSupportedAlgorithm(algorithm)); | ||
// throw exception if it can't create | ||
_ = _factory.CreateForSigning(key, algorithm); | ||
_ = _factory.CreateForVerifying(key, algorithm); | ||
} | ||
// Assert.True(_factory.IsSupportedAlgorithm(algorithm)); | ||
// // throw exception if it can't create | ||
// _ = _factory.CreateForSigning(key, algorithm); | ||
// _ = _factory.CreateForVerifying(key, algorithm); | ||
// } | ||
|
||
[Theory] | ||
[InlineData("http://www.w3.org/2000/09/xmldsig#hmac-sha1")] | ||
[InlineData("H1")] | ||
public void ShouldGetKeyedHashAlgorithm(string algorithm) | ||
{ | ||
var bytes = new byte[16]; | ||
var random = RandomNumberGenerator.Create(); | ||
random.GetNonZeroBytes(bytes); | ||
// [Theory] | ||
// [InlineData("http://www.w3.org/2000/09/xmldsig#hmac-sha1")] | ||
// [InlineData("H1")] | ||
// public void ShouldGetKeyedHashAlgorithm(string algorithm) | ||
// { | ||
// var bytes = new byte[16]; | ||
// var random = RandomNumberGenerator.Create(); | ||
// random.GetNonZeroBytes(bytes); | ||
|
||
Assert.True(_factory.IsSupportedAlgorithm(algorithm)); | ||
// throw exception if it can't create | ||
_ = _factory.CreateKeyedHashAlgorithm(bytes, algorithm); | ||
} | ||
} | ||
} | ||
// Assert.True(_factory.IsSupportedAlgorithm(algorithm)); | ||
// // throw exception if it can't create | ||
// _ = _factory.CreateKeyedHashAlgorithm(bytes, algorithm); | ||
// } | ||
// } | ||
//} |
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
122 changes: 0 additions & 122 deletions
122
src/Solid.Identity.Protocols.WsTrust.Tests/GodSecurityTokenHandler.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 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
Oops, something went wrong.