public void VerifyAuthenticationWithoutReturnUrlThrows() { // Arrange var client = new MockOAuth2Client(); // Act && Assert Assert.Throws<InvalidOperationException>(() => client.VerifyAuthenticationAsync(new Mock<HttpContextBase>().Object).GetAwaiter().GetResult()); }
public void VerifyAuthenticationThrowsIfContextIsNull() { // Arrange var client = new MockOAuth2Client(); // Act && Assert Assert.Throws<ArgumentNullException>(() => client.VerifyAuthenticationAsync(null, new Uri("http://me.com")).GetAwaiter().GetResult()); }
public void VerifyAuthenticationWithoutReturnUrlThrows() { // Arrange var client = new MockOAuth2Client(); // Act && Assert Assert.Throws <InvalidOperationException>(() => client.VerifyAuthenticationAsync(new Mock <HttpContextBase>().Object).GetAwaiter().GetResult()); }
public void VerifyAuthenticationThrowsIfContextIsNull() { // Arrange var client = new MockOAuth2Client(); // Act && Assert Assert.Throws <ArgumentNullException>(() => client.VerifyAuthenticationAsync(null, new Uri("http://me.com")).GetAwaiter().GetResult()); }
public async Task 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 = await client.VerifyAuthenticationAsync(context.Object, new Uri("http://me.com")); // Assert Assert.IsFalse(result.IsSuccessful); }
public async Task 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 = await client.VerifyAuthenticationAsync(context.Object, new Uri("http://me.com")); // Assert Assert.IsFalse(result.IsSuccessful); }
public async Task 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 = await client.VerifyAuthenticationAsync(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"]); }
public async Task 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 = await client.VerifyAuthenticationAsync(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"]); }