Skip to content

Commit f58d585

Browse files
authored
Add supported algorithm tests (#3296)
* Add tests * Add all none cases
1 parent 0df5711 commit f58d585

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

test/Microsoft.IdentityModel.Tokens.Tests/SupportedAlgorithmTests.cs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Licensed under the MIT License.
33

44
using System;
5+
using System.Collections.Generic;
56
using Microsoft.IdentityModel.TestUtils;
67
using Xunit;
78

@@ -170,6 +171,47 @@ public static TheoryData<SupportedAlgorithmTheoryData> IsSupportedAlgorithmAndKe
170171
"X509_CustomCryptoProviderFactory",
171172
theoryData);
172173

174+
// Add "none" and "noNe" test cases for all key types
175+
var keyTypes = new Dictionary<string, SecurityKey>
176+
{
177+
{ "JsonWebKey_Ecdsa", KeyingMaterial.JsonWebKeyP256 },
178+
{ "JsonWebKey_Rsa", KeyingMaterial.JsonWebKeyRsa_2048 },
179+
{ "JsonWebKey_Symmetric", KeyingMaterial.JsonWebKeySymmetric256 },
180+
{ "Rsa", KeyingMaterial.RsaSecurityKey_2048 },
181+
{ "Symmetric", KeyingMaterial.DefaultSymmetricSecurityKey_256 },
182+
{ "X509", KeyingMaterial.X509SecurityKeySelfSigned2048_SHA256 },
183+
{ "Ecdsa", KeyingMaterial.Ecdsa384Key }
184+
};
185+
186+
// All permutations of "none" with different capitalizations
187+
var nonePermutations = new[]
188+
{
189+
"none",
190+
"None",
191+
"nOne",
192+
"noNe",
193+
"nonE",
194+
"NOne",
195+
"NONe",
196+
"NOnE",
197+
"noNE",
198+
"nONE",
199+
"NoNe",
200+
"NoNE",
201+
"NOnE",
202+
"nONe",
203+
"nonE",
204+
"NONE"
205+
};
206+
207+
foreach (var keyType in keyTypes)
208+
{
209+
foreach (var permutation in nonePermutations)
210+
{
211+
SupportedAlgorithmTheoryData.AddTestCase(permutation, keyType.Value, false, $"{keyType.Key}_{permutation}", theoryData);
212+
}
213+
}
214+
173215
return theoryData;
174216
}
175217
}

0 commit comments

Comments
 (0)