示例#1
0
        public void TokenSerializer_HashStillValid()
        {
            var serialized   = TokenSerializer.Serialize(token);
            var deserialized = TokenSerializer.Deserialize(serialized);

            //must reapply the IP - comes from the request header, not saved
            deserialized.IpAddress = "123.45.678.90";

            Assert.AreNotSame(token, deserialized);
            Assert.IsTrue(TokenHasher.IsValid(deserialized));
        }
示例#2
0
        public void TokenSerializer_DifferentIp_NotValid()
        {
            var serialized   = TokenSerializer.Serialize(token);
            var deserialized = TokenSerializer.Deserialize(serialized);

            //must reapply the IP - comes from the request header, not saved
            deserialized.IpAddress = "213.54.678.90";

            Assert.AreNotSame(token, deserialized);
            Assert.IsFalse(TokenHasher.IsValid(deserialized));
        }
示例#3
0
        public void TokenSerializer_BeforeEqualsAfter()
        {
            var serialized   = TokenSerializer.Serialize(token);
            var deserialized = TokenSerializer.Deserialize(serialized);

            //must reapply the IP - comes from the request header, not saved
            deserialized.IpAddress = "123.45.678.90";

            Assert.AreNotSame(token, deserialized);
            Assert.AreEqual(token.CreateDate, deserialized.CreateDate);
            Assert.AreEqual(token.Role, deserialized.Role);
            Assert.AreEqual(token.IpAddress, deserialized.IpAddress);
            Assert.AreEqual(token.LocationId, deserialized.LocationId);
            Assert.AreEqual(token.UserId, deserialized.UserId);
        }