From c828ffb063b67cc126fe7164ae11c2c483f06cbb Mon Sep 17 00:00:00 2001 From: Nate Barbettini Date: Fri, 14 Apr 2017 06:39:26 -0700 Subject: [PATCH] Manually fix some conflits after rebase --- tests/JWT.Tests.Core/JwtDecoderTest.cs | 25 ++++++++++++++++--------- tests/JWT.Tests.Core/JwtEncoderTest.cs | 6 ++++-- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/tests/JWT.Tests.Core/JwtDecoderTest.cs b/tests/JWT.Tests.Core/JwtDecoderTest.cs index 3fe145013..9765c3f88 100644 --- a/tests/JWT.Tests.Core/JwtDecoderTest.cs +++ b/tests/JWT.Tests.Core/JwtDecoderTest.cs @@ -13,7 +13,8 @@ public class JwtDecoderTest public void Decode_Should_Decode_Token_To_Json_Encoded_String() { var serializer = new JsonNetSerializer(); - var decoder = new JwtDecoder(serializer, null); + var urlEncoder = new JwtBase64UrlEncoder(); + var decoder = new JwtDecoder(serializer, null, urlEncoder); var expectedPayload = serializer.Serialize(TestData.Customer); @@ -26,7 +27,8 @@ public void Decode_Should_Decode_Token_To_Json_Encoded_String() public void DecodeToObject_Should_Decode_Token_To_Dictionary() { var serializer = new JsonNetSerializer(); - var decoder = new JwtDecoder(serializer, null); + var urlEncoder = new JwtBase64UrlEncoder(); + var decoder = new JwtDecoder(serializer, null, urlEncoder); var actualPayload = decoder.DecodeToObject(TestData.Token, "ABC", verify: false); @@ -37,7 +39,8 @@ public void DecodeToObject_Should_Decode_Token_To_Dictionary() public void DecodeToObject_Should_Decode_Token_To_Generic_Type() { var serializer = new JsonNetSerializer(); - var decoder = new JwtDecoder(serializer, null); + var urlEncoder = new JwtBase64UrlEncoder(); + var decoder = new JwtDecoder(serializer, null, urlEncoder); var actualPayload = decoder.DecodeToObject(TestData.Token, "ABC", verify: false); @@ -48,7 +51,8 @@ public void DecodeToObject_Should_Decode_Token_To_Generic_Type() public void DecodeToObject_Should_Throw_Exception_On_Malformed_Token() { var serializer = new JsonNetSerializer(); - var decoder = new JwtDecoder(serializer, null); + var urlEncoder = new JwtBase64UrlEncoder(); + var decoder = new JwtDecoder(serializer, null, urlEncoder); Action action = () => decoder.DecodeToObject(TestData.MalformedToken, "ABC", verify: false); @@ -60,7 +64,8 @@ public void DecodeToObject_Should_Throw_Exception_On_Invalid_Key() { var serializer = new JsonNetSerializer(); var validator = new JwtValidator(serializer, new UtcDateTimeProvider()); - var decoder = new JwtDecoder(serializer, validator); + var urlEncoder = new JwtBase64UrlEncoder(); + var decoder = new JwtDecoder(serializer, validator, urlEncoder); Action action = () => decoder.DecodeToObject(TestData.Token, "XYZ", verify: true); @@ -72,9 +77,10 @@ public void DecodeToObject_Should_Throw_Exception_On_Invalid_Expiration_Claim() { var serializer = new JsonNetSerializer(); var validator = new JwtValidator(serializer, new UtcDateTimeProvider()); - var decoder = new JwtDecoder(serializer, validator); + var urlEncoder = new JwtBase64UrlEncoder(); + var decoder = new JwtDecoder(serializer, validator, urlEncoder); - var encoder = new JwtEncoder(new HMACSHA256Algorithm(), serializer); + var encoder = new JwtEncoder(new HMACSHA256Algorithm(), serializer, urlEncoder); var invalidtoken = encoder.Encode(new { exp = "asdsad" }, "ABC"); Action action = () => decoder.DecodeToObject(invalidtoken, "ABC", verify: true); @@ -88,13 +94,14 @@ public void DecodeToObject_Should_Throw_Exception_On_Expired_Claim() var serializer = new JsonNetSerializer(); var dateTimeProvider = new UtcDateTimeProvider(); var validator = new JwtValidator(serializer, dateTimeProvider); - var decoder = new JwtDecoder(serializer, validator); + var urlEncoder = new JwtBase64UrlEncoder(); + var decoder = new JwtDecoder(serializer, validator, urlEncoder); var now = dateTimeProvider.GetNow(); var hourAgo = now.Subtract(new TimeSpan(1, 0, 0)); var unixTimestamp = (int)(hourAgo - new DateTime(1970, 1, 1)).TotalSeconds; - var encoder = new JwtEncoder(new HMACSHA256Algorithm(), serializer); + var encoder = new JwtEncoder(new HMACSHA256Algorithm(), serializer, urlEncoder); var expiredtoken = encoder.Encode(new { exp = unixTimestamp }, "ABC"); Action action = () => decoder.DecodeToObject(expiredtoken, "ABC", verify: true); diff --git a/tests/JWT.Tests.Core/JwtEncoderTest.cs b/tests/JWT.Tests.Core/JwtEncoderTest.cs index a1327dea3..2cf6f4f64 100644 --- a/tests/JWT.Tests.Core/JwtEncoderTest.cs +++ b/tests/JWT.Tests.Core/JwtEncoderTest.cs @@ -13,7 +13,8 @@ public class JwtEncoderTest public void Encode_Should_Encode_To_Token() { var serializer = new JsonNetSerializer(); - var encoder = new JwtEncoder(new HMACSHA256Algorithm(), serializer); + var urlEncoder = new JwtBase64UrlEncoder(); + var encoder = new JwtEncoder(new HMACSHA256Algorithm(), serializer, urlEncoder); var actual = encoder.Encode(TestData.Customer, "ABC"); @@ -24,7 +25,8 @@ public void Encode_Should_Encode_To_Token() public void Encode_Should_Encode_To_Token_With_Extra_Headers() { var serializer = new JsonNetSerializer(); - var encoder = new JwtEncoder(new HMACSHA256Algorithm(), serializer); + var urlEncoder = new JwtBase64UrlEncoder(); + var encoder = new JwtEncoder(new HMACSHA256Algorithm(), serializer, urlEncoder); var extraheaders = new Dictionary { { "foo", "bar" } }; var actual = encoder.Encode(extraheaders, TestData.Customer, "ABC");