From 3753b5ccce9cfaadfc990712a01a605de1de8166 Mon Sep 17 00:00:00 2001 From: Ignacio Inglese Date: Fri, 28 Jun 2024 15:29:55 +0100 Subject: [PATCH] Updated test names to match other validator tests. Sorted Valid above Invalid test cases. --- .../SigningKeyValidationResultTests.cs | 124 +++++++++--------- 1 file changed, 62 insertions(+), 62 deletions(-) diff --git a/test/Microsoft.IdentityModel.Tokens.Tests/Validation/SigningKeyValidationResultTests.cs b/test/Microsoft.IdentityModel.Tokens.Tests/Validation/SigningKeyValidationResultTests.cs index fbba587543..43a6d3e313 100644 --- a/test/Microsoft.IdentityModel.Tokens.Tests/Validation/SigningKeyValidationResultTests.cs +++ b/test/Microsoft.IdentityModel.Tokens.Tests/Validation/SigningKeyValidationResultTests.cs @@ -50,56 +50,7 @@ public static TheoryData SigningKeyValidationTes { new SigningKeyValidationTheoryData { - TestId = "Invalid_SecurityKeyIsNull", - ExpectedException = ExpectedException.ArgumentNullException(substringExpected: "IDX10253:"), - SecurityKey = null, - SecurityToken = new JwtSecurityToken(), - ValidationParameters = new TokenValidationParameters { ValidateIssuerSigningKey = true }, - SigningKeyValidationResult = new SigningKeyValidationResult( - null, // SecurityKey - ValidationFailureType.NullArgument, - new ExceptionDetail( - new MessageDetail(LogMessages.IDX10253), - typeof(ArgumentNullException), - new StackFrame(true))) - }, - new SigningKeyValidationTheoryData - { - TestId = "Invalid_SecurityTokenIsNullAndValidateIssuerSigningKeyTrue", - ExpectedException = ExpectedException.ArgumentNullException(), - SecurityKey = KeyingMaterial.SymmetricSecurityKey2_256, - SecurityToken = null, - ValidationParameters = new TokenValidationParameters { ValidateIssuerSigningKey = true }, - SigningKeyValidationResult = new SigningKeyValidationResult( - KeyingMaterial.SymmetricSecurityKey2_256, - ValidationFailureType.NullArgument, - new ExceptionDetail( - new MessageDetail( - LogMessages.IDX10000, - LogHelper.MarkAsNonPII("securityToken")), - typeof(ArgumentNullException), - new StackFrame(true))) - }, - new SigningKeyValidationTheoryData - { - TestId = "Invalid_ValidationParametersIsNull", - ExpectedException = ExpectedException.ArgumentNullException(), - SecurityKey = KeyingMaterial.SymmetricSecurityKey2_256, - SecurityToken = new JwtSecurityToken(), - ValidationParameters = null, - SigningKeyValidationResult = new SigningKeyValidationResult( - KeyingMaterial.SymmetricSecurityKey2_256, - ValidationFailureType.NullArgument, - new ExceptionDetail( - new MessageDetail( - LogMessages.IDX10000, - LogHelper.MarkAsNonPII("validationParameters")), - typeof(ArgumentNullException), - new StackFrame(true))) - }, - new SigningKeyValidationTheoryData - { - TestId = "Valid_SecurityTokenIsPresentAndValidateIssuerSigningKeyTrue", + TestId = "Valid_SecurityTokenIsPresent_ValidateIssuerSigningKeyIsTrue", ExpectedException = ExpectedException.NoExceptionExpected, SecurityKey = KeyingMaterial.SymmetricSecurityKey2_256, SecurityToken = new JwtSecurityToken(), @@ -108,7 +59,7 @@ public static TheoryData SigningKeyValidationTes }, new SigningKeyValidationTheoryData { - TestId = "Valid_SecurityKeyIsNullAndValidateIssuerSigningKeyFalse", + TestId = "Valid_SecurityKeyIsNull_ValidateIssuerSigningKeyIsFalse", ExpectedException = ExpectedException.NoExceptionExpected, SecurityKey = null, SecurityToken = new JwtSecurityToken(), @@ -117,7 +68,7 @@ public static TheoryData SigningKeyValidationTes }, new SigningKeyValidationTheoryData { - TestId = "Valid_SecurityTokenIsNullAndValidateIssuerSigningKeyFalse", + TestId = "Valid_SecurityTokenIsNull_ValidateIssuerSigningKeyIsFalse", ExpectedException = ExpectedException.NoExceptionExpected, SecurityKey = KeyingMaterial.SymmetricSecurityKey2_256, SecurityToken = null, @@ -126,7 +77,7 @@ public static TheoryData SigningKeyValidationTes }, new SigningKeyValidationTheoryData { - TestId = "Valid_SecurityKeyIsNullAndRequireSignedTokensFalse", + TestId = "Valid_SecurityKeyIsNull_RequireSignedTokensIsFalse", ExpectedException = ExpectedException.NoExceptionExpected, SecurityKey = null, SecurityToken = new JwtSecurityToken(), @@ -135,7 +86,7 @@ public static TheoryData SigningKeyValidationTes }, new SigningKeyValidationTheoryData { - TestId = "Valid_SecurityKeyIsPresentAndRequireSignedTokensTrue", + TestId = "Valid_SecurityKeyIsPresent_RequireSignedTokensIsTrue", ExpectedException = ExpectedException.NoExceptionExpected, SecurityKey = KeyingMaterial.SymmetricSecurityKey2_256, SecurityToken = new JwtSecurityToken(), @@ -144,7 +95,7 @@ public static TheoryData SigningKeyValidationTes }, new SigningKeyValidationTheoryData { - TestId = "Valid_SecurityKeyIsPresentAndRequireSignedTokensFalse", + TestId = "Valid_SecurityKeyIsPresent_RequireSignedTokensIsFalse", ExpectedException = ExpectedException.NoExceptionExpected, SecurityKey = KeyingMaterial.SymmetricSecurityKey2_256, SecurityToken = new JwtSecurityToken(), @@ -153,7 +104,7 @@ public static TheoryData SigningKeyValidationTes }, new SigningKeyValidationTheoryData { - TestId = "Valid_DelegateSetAndReturnsTrue", + TestId = "Valid_DelegateSet_ReturnsTrue", ExpectedException = ExpectedException.NoExceptionExpected, SecurityKey = KeyingMaterial.SymmetricSecurityKey2_256, SecurityToken = new JwtSecurityToken(), @@ -166,7 +117,7 @@ public static TheoryData SigningKeyValidationTes }, new SigningKeyValidationTheoryData { - TestId = "Valid_DelegateUsingConfigurationSetConfigurationAndReturnsTrue", + TestId = "Valid_DelegateUsingConfigurationSet_ReturnsTrue", ExpectedException = ExpectedException.NoExceptionExpected, SecurityKey = KeyingMaterial.SymmetricSecurityKey2_256, SecurityToken = new JwtSecurityToken(), @@ -179,6 +130,55 @@ public static TheoryData SigningKeyValidationTes SigningKeyValidationResult = new SigningKeyValidationResult(KeyingMaterial.SymmetricSecurityKey2_256) }, new SigningKeyValidationTheoryData + { + TestId = "Invalid_SecurityKeyIsNull", + ExpectedException = ExpectedException.ArgumentNullException(substringExpected: "IDX10253:"), + SecurityKey = null, + SecurityToken = new JwtSecurityToken(), + ValidationParameters = new TokenValidationParameters { ValidateIssuerSigningKey = true }, + SigningKeyValidationResult = new SigningKeyValidationResult( + null, // SecurityKey + ValidationFailureType.NullArgument, + new ExceptionDetail( + new MessageDetail(LogMessages.IDX10253), + typeof(ArgumentNullException), + new StackFrame(true))) + }, + new SigningKeyValidationTheoryData + { + TestId = "Invalid_SecurityTokenIsNullAndValidateIssuerSigningKeyTrue", + ExpectedException = ExpectedException.ArgumentNullException(), + SecurityKey = KeyingMaterial.SymmetricSecurityKey2_256, + SecurityToken = null, + ValidationParameters = new TokenValidationParameters { ValidateIssuerSigningKey = true }, + SigningKeyValidationResult = new SigningKeyValidationResult( + KeyingMaterial.SymmetricSecurityKey2_256, + ValidationFailureType.NullArgument, + new ExceptionDetail( + new MessageDetail( + LogMessages.IDX10000, + LogHelper.MarkAsNonPII("securityToken")), + typeof(ArgumentNullException), + new StackFrame(true))) + }, + new SigningKeyValidationTheoryData + { + TestId = "Invalid_ValidationParametersIsNull", + ExpectedException = ExpectedException.ArgumentNullException(), + SecurityKey = KeyingMaterial.SymmetricSecurityKey2_256, + SecurityToken = new JwtSecurityToken(), + ValidationParameters = null, + SigningKeyValidationResult = new SigningKeyValidationResult( + KeyingMaterial.SymmetricSecurityKey2_256, + ValidationFailureType.NullArgument, + new ExceptionDetail( + new MessageDetail( + LogMessages.IDX10000, + LogHelper.MarkAsNonPII("validationParameters")), + typeof(ArgumentNullException), + new StackFrame(true))) + }, + new SigningKeyValidationTheoryData { TestId = "Invalid_SecurityKeyIsExpired", ExpectedException = ExpectedException.SecurityTokenInvalidSigningKeyException(substringExpected: "IDX10249:"), @@ -216,7 +216,7 @@ public static TheoryData SigningKeyValidationTes }, new SigningKeyValidationTheoryData { - TestId = "Invalid_SecurityKeyIsNullAndRequireSignedTokensTrue", + TestId = "Invalid_SecurityKeyIsNull_RequireSignedTokensIsTrue", ExpectedException = ExpectedException.ArgumentNullException(substringExpected: "IDX10253:"), SecurityKey = null, SecurityToken = new JwtSecurityToken(), @@ -231,7 +231,7 @@ public static TheoryData SigningKeyValidationTes }, new SigningKeyValidationTheoryData { - TestId = "Invalid_DelegateIsSetAndReturnsFalse", + TestId = "Invalid_DelegateIsSet_ReturnsFalse", ExpectedException = ExpectedException.SecurityTokenInvalidSigningKeyException(substringExpected: "IDX10232:"), SecurityKey = KeyingMaterial.SymmetricSecurityKey2_256, SecurityToken = new JwtSecurityToken(), @@ -252,7 +252,7 @@ public static TheoryData SigningKeyValidationTes }, new SigningKeyValidationTheoryData { - TestId = "Invalid_DelegateUsingConfigurationSetConfigurationAndReturnsFalse", + TestId = "Invalid_DelegateUsingConfigurationSet_ReturnsFalse", ExpectedException = ExpectedException.SecurityTokenInvalidSigningKeyException(substringExpected: "IDX10232:"), SecurityKey = KeyingMaterial.SymmetricSecurityKey2_256, SecurityToken = new JwtSecurityToken(), @@ -274,7 +274,7 @@ public static TheoryData SigningKeyValidationTes }, new SigningKeyValidationTheoryData { - TestId = "Invalid_DelegateIsSetAndThrows", + TestId = "Invalid_DelegateIsSet_Throws", ExpectedException = ExpectedException.SecurityTokenInvalidSigningKeyException(substringExpected: "IDX10232:", innerTypeExpected: typeof(SecurityTokenInvalidSigningKeyException)), SecurityKey = KeyingMaterial.SymmetricSecurityKey2_256, SecurityToken = new JwtSecurityToken(), @@ -296,7 +296,7 @@ public static TheoryData SigningKeyValidationTes }, new SigningKeyValidationTheoryData { - TestId = "Invalid_DelegateUsingConfigurationSetConfigurationAndThrows", + TestId = "Invalid_DelegateUsingConfigurationSet_Throws", ExpectedException = ExpectedException.SecurityTokenInvalidSigningKeyException(substringExpected: "IDX10232:", innerTypeExpected: typeof(SecurityTokenInvalidSigningKeyException)), SecurityKey = KeyingMaterial.SymmetricSecurityKey2_256, SecurityToken = new JwtSecurityToken(),