예제 #1
0
        public void InvalidateOldTokens()
        {
            Assert.IsTrue(manager.VerifyToken(node, token), "#1");

            manager.RefreshTokens();
            Assert.IsTrue(manager.VerifyToken(node, token), "#2");

            manager.RefreshTokens();
            Assert.IsFalse(manager.VerifyToken(node, token), "#3");
        }
예제 #2
0
        public void CheckTokenGenerator()
        {
            TokenManager m = new TokenManager();
            m.Timeout = TimeSpan.FromMilliseconds(75); // 1 second timeout for testing purposes
            Node n = new Node(NodeId.Create(),new IPEndPoint(IPAddress.Parse("127.0.0.1"), 25));
            Node n2 = new Node(NodeId.Create(),new IPEndPoint(IPAddress.Parse("127.0.0.2"), 25));
            BEncodedString s = m.GenerateToken(n);
            BEncodedString s2 = m.GenerateToken(n);

            Assert.AreEqual(s, s2, "#1");

            Assert.IsTrue(m.VerifyToken(n, s),"#2");
            Assert.IsFalse(m.VerifyToken(n2, s),"#3");

            System.Threading.Thread.Sleep(100);
            Assert.IsTrue(m.VerifyToken(n, s), "#4");

            System.Threading.Thread.Sleep(100);
            Assert.IsFalse(m.VerifyToken(n, s), "#5");
        }
예제 #3
0
        public void CheckTokenGenerator()
        {
            var m = new TokenManager();
            m.Timeout = TimeSpan.FromMilliseconds(75); // 1 second timeout for testing purposes
            var n = new Node(NodeId.Create(), new IPEndPoint(IPAddress.Parse("127.0.0.1"), 25));
            var n2 = new Node(NodeId.Create(), new IPEndPoint(IPAddress.Parse("127.0.0.2"), 25));
            var s = m.GenerateToken(n);
            var s2 = m.GenerateToken(n);

            Assert.Equal(s, s2);

            Assert.True(m.VerifyToken(n, s), "#2");
            Assert.False(m.VerifyToken(n2, s), "#3");

            Thread.Sleep(100);
            Assert.True(m.VerifyToken(n, s));

            Thread.Sleep(100);
            Assert.False(m.VerifyToken(n, s));
        }
예제 #4
0
        public void CheckTokenGenerator()
        {
            TokenManager m = new TokenManager();

            m.Timeout = TimeSpan.FromMilliseconds(75); // 1 second timeout for testing purposes
            Node           n  = new Node(NodeId.Create(), new IPEndPoint(IPAddress.Parse("127.0.0.1"), 25));
            Node           n2 = new Node(NodeId.Create(), new IPEndPoint(IPAddress.Parse("127.0.0.2"), 25));
            BEncodedString s  = m.GenerateToken(n);
            BEncodedString s2 = m.GenerateToken(n);

            Assert.AreEqual(s, s2, "#1");

            Assert.IsTrue(m.VerifyToken(n, s), "#2");
            Assert.IsFalse(m.VerifyToken(n2, s), "#3");

            System.Threading.Thread.Sleep(100);
            Assert.IsTrue(m.VerifyToken(n, s), "#4");

            System.Threading.Thread.Sleep(100);
            Assert.IsFalse(m.VerifyToken(n, s), "#5");
        }