-
Notifications
You must be signed in to change notification settings - Fork 419
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove old 6x tests used that are not needed anymore (#2742)
Co-authored-by: id4s <[email protected]>
- Loading branch information
1 parent
e67b25b
commit 2cde86c
Showing
15 changed files
with
7 additions
and
4,427 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 |
---|---|---|
|
@@ -1469,20 +1469,8 @@ public static TheoryData<CreateTokenTheoryData> CreateJWSWithSecurityTokenDescri | |
public void CreateJWSWithAdditionalHeaderClaims(CreateTokenTheoryData theoryData) | ||
{ | ||
var context = TestUtilities.WriteHeader($"{this}.CreateJWSWithAdditionalHeaderClaims", theoryData); | ||
|
||
var jwtToken = new JsonWebTokenHandler().CreateToken(theoryData.TokenDescriptor); | ||
var jwtToken6x = new JsonWebTokenHandler6x().CreateToken(theoryData.TokenDescriptor); | ||
|
||
JsonWebToken jsonWebToken = new JsonWebToken(jwtToken); | ||
JsonWebToken jsonWebToken6x = new JsonWebToken(jwtToken6x); | ||
|
||
if (!IdentityComparer.AreEqual(jsonWebToken.Header, jsonWebToken6x.Header, context)) | ||
{ | ||
context.AddDiff("jsonWebToken.Header != jsonWebToken6x.Header"); | ||
context.AddDiff("********************************************"); | ||
} | ||
|
||
IdentityComparer.AreEqual(jwtToken6x, theoryData.JwtToken, context); | ||
TestUtilities.AssertFailIfErrors(context); | ||
} | ||
|
||
|
@@ -1924,14 +1912,12 @@ public void CreateJWSUsingSecurityTokenDescriptor(CreateTokenTheoryData theoryDa | |
theoryData.ValidationParameters.ValidateLifetime = false; | ||
try | ||
{ | ||
JsonWebTokenHandler6x jsonWebTokenHandler6x = new JsonWebTokenHandler6x(); | ||
if (theoryData.TokenDescriptor != null && !theoryData.AudiencesForSecurityTokenDescriptor.IsNullOrEmpty()) | ||
{ | ||
foreach (var audience in theoryData.AudiencesForSecurityTokenDescriptor) | ||
theoryData.TokenDescriptor.Audiences.Add(audience); | ||
} | ||
|
||
string jwtFromSecurityTokenDescriptor6x = jwtFromSecurityTokenDescriptor6x = jsonWebTokenHandler6x.CreateToken(theoryData.TokenDescriptor6x ?? theoryData.TokenDescriptor); | ||
string jwtFromSecurityTokenDescriptor = theoryData.JsonWebTokenHandler.CreateToken(theoryData.TokenDescriptor); | ||
string jwtPayloadAsString; | ||
|
||
|
@@ -1943,7 +1929,6 @@ public void CreateJWSUsingSecurityTokenDescriptor(CreateTokenTheoryData theoryDa | |
jwtPayloadAsString = theoryData.JsonWebTokenHandler.CreateToken(theoryData.Payload, theoryData.TokenDescriptor.SigningCredentials); | ||
|
||
var jwsTokenFromSecurityTokenDescriptor = new JsonWebToken(jwtFromSecurityTokenDescriptor); | ||
var jwsTokenFromSecurityTokenDescriptor6x = new JsonWebToken(jwtFromSecurityTokenDescriptor6x); | ||
var jwsTokenFromString = new JsonWebToken(jwtPayloadAsString); | ||
|
||
var tokenValidationResultFromSecurityTokenDescriptor = theoryData.JsonWebTokenHandler.ValidateTokenAsync(jwtFromSecurityTokenDescriptor, theoryData.ValidationParameters).Result; | ||
|
@@ -1963,64 +1948,13 @@ public void CreateJWSUsingSecurityTokenDescriptor(CreateTokenTheoryData theoryDa | |
} | ||
|
||
context.PropertiesToIgnoreWhenComparing = theoryData.PropertiesToIgnoreWhenComparing; | ||
|
||
if (!IdentityComparer.AreEqual(jwsTokenFromSecurityTokenDescriptor.Header, jwsTokenFromSecurityTokenDescriptor6x.Header, context)) | ||
{ | ||
context.AddDiff("jwsTokenFromSecurityTokenDescriptor.Header != jwsTokenFromSecurityTokenDescriptor6x.Header"); | ||
context.AddDiff("******************************************************************************************"); | ||
context.AddDiff(" "); | ||
} | ||
|
||
bool claimsEqual; | ||
if (!IdentityComparer.AreEqual(jwsTokenFromSecurityTokenDescriptor.Claims, jwsTokenFromSecurityTokenDescriptor6x.Claims, context)) | ||
{ | ||
context.AddDiff("jwsTokenFromSecurityTokenDescriptor.Claims != jwsTokenFromSecurityTokenDescriptor6x.Claims"); | ||
context.AddDiff("****************************************************************************"); | ||
context.AddDiff(" "); | ||
claimsEqual = false; | ||
} | ||
else | ||
{ | ||
claimsEqual = true; | ||
} | ||
|
||
if (!IdentityComparer.AreEqual(jwsTokenFromSecurityTokenDescriptor.Header, jwsTokenFromSecurityTokenDescriptor6x.Header)) | ||
{ | ||
context.AddDiff("jwsTokenFromSecurityTokenDescriptor.Header != jwsTokenFromSecurityTokenDescriptor6x.Header"); | ||
context.AddDiff("****************************************************************************"); | ||
context.AddDiff(" "); | ||
} | ||
|
||
// if the claims are the same some properties could be different because of ordering | ||
CompareContext localContext = new CompareContext(context); | ||
if (claimsEqual) | ||
localContext.PropertiesToIgnoreWhenComparing = new Dictionary<Type, List<string>> | ||
{ | ||
{typeof(JsonWebToken), new List<string> {"EncodedHeader", "EncodedToken", "EncodedPayload", "EncodedSignature"}}, | ||
}; | ||
|
||
if (!IdentityComparer.AreEqual(jwsTokenFromSecurityTokenDescriptor, jwsTokenFromSecurityTokenDescriptor6x, localContext)) | ||
localContext.PropertiesToIgnoreWhenComparing = new Dictionary<Type, List<string>> | ||
{ | ||
context.AddDiff("jwsTokenFromSecurityTokenDescriptor != jwsTokenFromSecurityTokenDescriptor6x"); | ||
context.AddDiff("****************************************************************************"); | ||
context.AddDiff(" "); | ||
} | ||
|
||
context.Merge(localContext); | ||
|
||
if (!IdentityComparer.AreEqual(jwsTokenFromSecurityTokenDescriptor.Claims, jwsTokenFromString.Claims, context)) | ||
{ | ||
context.AddDiff("jwsTokenFromSecurityTokenDescriptor.Claims != jwsTokenFromString.Claims"); | ||
context.AddDiff("****************************************************************************"); | ||
context.AddDiff(" "); | ||
claimsEqual = false; | ||
} | ||
else | ||
{ | ||
claimsEqual = true; | ||
} | ||
{typeof(JsonWebToken), new List<string> {"EncodedHeader", "EncodedToken", "EncodedPayload", "EncodedSignature"}}, | ||
}; | ||
|
||
localContext.Diffs.Clear(); | ||
// if the claims are the same some properties could be different because of ordering | ||
if (!IdentityComparer.AreEqual(jwsTokenFromSecurityTokenDescriptor, jwsTokenFromString, localContext)) | ||
{ | ||
|
@@ -2889,7 +2823,6 @@ public void SetDefaultTimesOnTokenCreation() | |
var context = new CompareContext(); | ||
|
||
var tokenHandler7 = new JsonWebTokenHandler(); | ||
var tokenHandler6 = new JsonWebTokenHandler6x(); | ||
var payloadWithoutTimeValues = new JObject() | ||
{ | ||
{ JwtRegisteredClaimNames.Email, "[email protected]" }, | ||
|
@@ -2901,15 +2834,6 @@ public void SetDefaultTimesOnTokenCreation() | |
var jwtString7 = tokenHandler7.CreateToken(payloadWithoutTimeValues, KeyingMaterial.JsonWebKeyRsa256SigningCredentials); | ||
var jwt7 = new JsonWebToken(jwtString7); | ||
|
||
var jwtString6 = tokenHandler6.CreateToken(payloadWithoutTimeValues, KeyingMaterial.JsonWebKeyRsa256SigningCredentials); | ||
var jwt6 = new JsonWebToken(jwtString6); | ||
|
||
if (!IdentityComparer.AreEqual(jwt7, jwt6, context)) | ||
{ | ||
context.AddDiff("jwt7 != jwt6"); | ||
context.AddDiff("********************************************"); | ||
} | ||
|
||
// DateTime.MinValue is returned if the value of a DateTime claim is not found in the payload | ||
if (DateTime.MinValue.Equals(jwt7.IssuedAt)) | ||
context.AddDiff("DateTime.MinValue.Equals(jwt.IssuedAt). Value for the 'iat' claim not found in the payload."); | ||
|
Oops, something went wrong.