public void DecryptV3_WithCorrectKey_DecryptsMessage() { // Arrange var generator = new TokenBuilder(); var key = "thisisakey"; var encrypted = "24JJvrIX--LTuT_BN4WTB_n_uNtl91zrGmMzcSiKODAh0FukUT-O0WaudZ4mVc4yJmYp8bGQzIqE6toLqn40GaK98xfDe0xmrgfB46OEQiNGCAErwzed3XAy5a45Z-RVduxvppoUvga17mG8W5mEafPsfU9RgVyH6eajPosJSssIeywFFybVDf4kRZod"; // Act var token = generator.DecryptV3(key, encrypted); // Assert Assert.NotNull(token); Assert.Equal("ec_expire=1522944645&ec_clientip=0.0.0.0&ec_country_allow=US&ec_country_deny=NA&ec_ref_allow=1234&ec_ref_deny=456", token); }
public void EncryptV3_WithDateTimeOnly_ReturnsEncryptedTokenWithOnlyDate() { // Arrange var generator = new TokenBuilder(); var expireTime = DateTime.Now.AddMilliseconds(300); var key = Faker.Name.FullName(); // Act var token = generator.EncryptV3(key, expireTime); // Assert Assert.NotNull(token); var decryptdToken = generator.DecryptV3(key, token); var expected = $"ec_expire={expireTime.FromEpoch()}"; Assert.Equal(expected, decryptdToken); }
public void EncryptV3_WithDateTimeAndClientIP_ReturnsEcnryptedTokenWithBoth() { // Arrange var generator = new TokenBuilder(); var expireTime = DateTime.Now.AddMilliseconds(300); var clientIp = Faker.Internet.DomainName(); var key = Faker.Name.FullName(); // Act var token = generator.EncryptV3(key, expireTime, clientIp); // Assert Assert.NotNull(token); var decryptdToken = generator.DecryptV3(key, token); var expected = $"ec_expire={expireTime.FromEpoch()}&ec_clientip={clientIp}"; Assert.Equal(expected, decryptdToken); }