public void JwtSecurityToken_EncodedStringConstruction() { Console.WriteLine("Entering: " + MethodBase.GetCurrentMethod()); JwtSecurityToken jwt = null; foreach (JwtSecurityTokenTestVariation variation in JwtEncodedStringVariations()) { Console.WriteLine(string.Format("Variation: {0}", variation.Name)); try { jwt = new JwtSecurityToken(variation.EncodedString); ExpectedException.ProcessNoException(variation.ExpectedException); } catch (Exception ex) { ExpectedException.ProcessException(variation.ExpectedException, ex); } // ensure we can get to every property if (jwt != null && (variation.ExpectedException == null || variation.ExpectedException.Thrown == null)) { JwtTestUtilities.CallAllPublicInstanceAndStaticPropertyGets(jwt, variation.Name); } if (null != variation.ExpectedJwtSecurityToken) { Assert.IsTrue( IdentityComparer.AreEqual(variation.ExpectedJwtSecurityToken, jwt), string.Format("Testcase: {0}. JWTSecurityTokens are not equal.", variation.Name)); } } }
public void JwtSecurityToken_ConstructionParams() { Console.WriteLine(string.Format("Entering: '{0}'", MethodBase.GetCurrentMethod())); JwtSecurityToken jwt = null; foreach (JwtSecurityTokenTestVariation param in JwtConstructionParamsVariations()) { Console.WriteLine(string.Format("Testcase: {0}", param.Name)); try { //jwt = new JWTSecurityToken( issuer: param.Issuer, audience: param.Audience, claims: param.Claims, signingCredentials: param.SigningCredentials, lifetime: param.Lifetime, actor: param.Actor); jwt = new JwtSecurityToken(param.Issuer, param.Audience, param.Claims, new Lifetime(param.ValidFrom, param.ValidTo)); ExpectedException.ProcessNoException(param.ExpectedException); } catch (Exception ex) { ExpectedException.ProcessException(param.ExpectedException, ex); } try { // ensure we can get to every property if (jwt != null && (param.ExpectedException == null || param.ExpectedException.Thrown == null)) { JwtTestUtilities.CallAllPublicInstanceAndStaticPropertyGets(jwt, param.Name); } if (null != param.ExpectedJwtSecurityToken) { Assert.IsFalse(!IdentityComparer.AreEqual(param.ExpectedJwtSecurityToken, jwt), string.Format("Testcase: {0}. JWTSecurityTokens are not equal.", param.Name)); } } catch (Exception ex) { Assert.Fail(string.Format("Testcase: {0}. UnExpected when getting a properties: '{1}'", param.Name, ex.ToString())); } } }