コード例 #1
0
            public void Success()
            {
                var token = SessionDataSerializer.Serialize(this.Crypto, this.sessionData);
                var request = this.CreateMockRequest(this.sessionData.IpAddress, this.sessionData.UserAgent, token);
                HttpRequestSessionDataVerifier verifier = new HttpRequestSessionDataVerifier(this.Crypto, this.userReader.Object, this.ipReader.Object);

                SessionData session = verifier.VerifySession(request.Object);
                Assert.AreEqual(this.sessionData.UserId, session.UserId);
            }
コード例 #2
0
            public void SessionUserNotExistsFails()
            {
                this.sessionData.UserId = "null";
                var token = SessionDataSerializer.Serialize(this.Crypto, this.sessionData);
                var request = this.CreateMockRequest(this.sessionData.IpAddress, this.sessionData.UserAgent, token);
                Mock<ISessionUserReader> userReader = this.CreateMockUserReader(this.sessionData.UserId);

                HttpRequestSessionDataVerifier verifier = new HttpRequestSessionDataVerifier(this.Crypto, userReader.Object, this.ipReader.Object);
                verifier.VerifySession(request.Object);
            }
コード例 #3
0
            public void RemoteIpNotMatchingSessionIpFails()
            {
                this.sessionData.IpAddress = "200.100.20.2";
                var token = SessionDataSerializer.Serialize(this.Crypto, this.sessionData);
                var request = this.CreateMockRequest("192.168.77.254", "Google Chrome", token);
                HttpRequestSessionDataVerifier verifier = new HttpRequestSessionDataVerifier(this.Crypto, this.userReader.Object, this.ipReader.Object);

                verifier.VerifySession(request.Object);
            }
コード例 #4
0
            public void NonMatchingUserAgentFails()
            {
                this.sessionData.UserAgent = "Mozilla Firefox";
                var token = SessionDataSerializer.Serialize(this.Crypto, this.sessionData);
                var request = this.CreateMockRequest(this.sessionData.IpAddress, "Google Chrome", token);
                HttpRequestSessionDataVerifier verifier = new HttpRequestSessionDataVerifier(this.Crypto, this.userReader.Object, this.ipReader.Object);

                verifier.VerifySession(request.Object);
            }
コード例 #5
0
            public void EmptyUserAgentFails()
            {
                var token = SessionDataSerializer.Serialize(this.Crypto, this.sessionData);
                var request = this.CreateMockRequest("127.0.0.1", string.Empty, token);
                HttpRequestSessionDataVerifier verifier = new HttpRequestSessionDataVerifier(this.Crypto, this.userReader.Object, this.ipReader.Object);

                verifier.VerifySession(request.Object);
            }
コード例 #6
0
            public void EmptySessionIdFails()
            {
                this.sessionData.SessionId = null;
                var token = SessionDataSerializer.Serialize(this.Crypto, this.sessionData);
                var request = this.CreateMockRequest(this.sessionData.IpAddress, this.sessionData.UserAgent, token);
                HttpRequestSessionDataVerifier verifier = new HttpRequestSessionDataVerifier(this.Crypto, this.userReader.Object, this.ipReader.Object);

                verifier.VerifySession(request.Object);
            }