Exemplo n.º 1
0
		public void VerifyAuthenticationThrowsIfContextIsNull() {
			// Arrange
			var client = new MockOAuth2Client();

			// Act && Assert
			Assert.Throws<ArgumentNullException>(() => client.VerifyAuthentication(null));
		}
Exemplo n.º 2
0
		public void VerifyAuthenticationWithoutReturnUrlThrows() {
			// Arrange
			var client = new MockOAuth2Client();

			// Act && Assert
			Assert.Throws<InvalidOperationException>(() => client.VerifyAuthentication(new Mock<HttpContextBase>().Object));
		}
Exemplo n.º 3
0
        public void VerifyAuthenticationWithoutReturnUrlThrows()
        {
            // Arrange
            var client = new MockOAuth2Client();

            // Act && Assert
            Assert.Throws <InvalidOperationException>(() => client.VerifyAuthentication(new Mock <HttpContextBase>().Object));
        }
Exemplo n.º 4
0
        public void VerifyAuthenticationThrowsIfContextIsNull()
        {
            // Arrange
            var client = new MockOAuth2Client();

            // Act && Assert
            Assert.Throws <ArgumentNullException>(() => client.VerifyAuthentication(null, new Uri("http://me.com")));
        }
Exemplo n.º 5
0
		public void VerifyAuthenticationFailsIfCodeIsNotPresent() {
			// Arrange
			var client = new MockOAuth2Client();
			var context = new Mock<HttpContextBase>(MockBehavior.Strict);
			var queryStrings = new NameValueCollection();
			context.Setup(c => c.Request.QueryString).Returns(queryStrings);

			// Act 
			AuthenticationResult result = client.VerifyAuthentication(context.Object);

			// Assert
			Assert.IsFalse(result.IsSuccessful);
		}
Exemplo n.º 6
0
        public void VerifyAuthenticationFailsIfCodeIsNotPresent()
        {
            // Arrange
            var client       = new MockOAuth2Client();
            var context      = new Mock <HttpContextBase>(MockBehavior.Strict);
            var queryStrings = new NameValueCollection();

            context.Setup(c => c.Request.QueryString).Returns(queryStrings);

            // Act
            AuthenticationResult result = client.VerifyAuthentication(context.Object, new Uri("http://me.com"));

            // Assert
            Assert.IsFalse(result.IsSuccessful);
        }
Exemplo n.º 7
0
        public void VerifyAuthenticationFailsIfAccessTokenIsNull()
        {
            // Arrange
            var client       = new MockOAuth2Client();
            var context      = new Mock <HttpContextBase>(MockBehavior.Strict);
            var queryStrings = new NameValueCollection();

            queryStrings.Add("code", "random");
            context.Setup(c => c.Request.QueryString).Returns(queryStrings);

            // Act
            AuthenticationResult result = client.VerifyAuthentication(context.Object);

            // Assert
            Assert.IsFalse(result.IsSuccessful);
        }
Exemplo n.º 8
0
        public void VerifyAuthenticationSucceeds()
        {
            // Arrange
            var client       = new MockOAuth2Client();
            var context      = new Mock <HttpContextBase>(MockBehavior.Strict);
            var queryStrings = new NameValueCollection();

            queryStrings.Add("code", "secret");
            context.Setup(c => c.Request.QueryString).Returns(queryStrings);

            // Act
            AuthenticationResult result = client.VerifyAuthentication(context.Object, new Uri("http://me.com"));

            // Assert
            Assert.True(result.IsSuccessful);
            Assert.AreEqual("mockprovider", result.Provider);
            Assert.AreEqual("12345", result.ProviderUserId);
            Assert.AreEqual("John Doe", result.UserName);
            Assert.NotNull(result.ExtraData);
            Assert.AreEqual("abcde", result.ExtraData["accesstoken"]);
        }
Exemplo n.º 9
0
		public void VerifyAuthenticationSucceeds() {
			// Arrange
			var client = new MockOAuth2Client();
			var context = new Mock<HttpContextBase>(MockBehavior.Strict);
			var queryStrings = new NameValueCollection();
			queryStrings.Add("code", "secret");
			context.Setup(c => c.Request.QueryString).Returns(queryStrings);

			// Act 
			AuthenticationResult result = client.VerifyAuthentication(context.Object);

			// Assert
			Assert.True(result.IsSuccessful);
			Assert.AreEqual("mockprovider", result.Provider);
			Assert.AreEqual("12345", result.ProviderUserId);
			Assert.AreEqual("John Doe", result.UserName);
			Assert.NotNull(result.ExtraData);
			Assert.AreEqual("abcde", result.ExtraData["accesstoken"]);
		}
Exemplo n.º 10
0
		public void VerifyAuthenticationFailsIfAccessTokenIsNull() {
			// Arrange
			var client = new MockOAuth2Client();
			var context = new Mock<HttpContextBase>(MockBehavior.Strict);
			var queryStrings = new NameValueCollection();
			queryStrings.Add("code", "random");
			context.Setup(c => c.Request.QueryString).Returns(queryStrings);

			// Act 
			AuthenticationResult result = client.VerifyAuthentication(context.Object, new Uri("http://me.com"));

			// Assert
			Assert.IsFalse(result.IsSuccessful);
		}