public void WillRedirectToTheReturnUrlIfLocal() { var authUser = new AuthenticatedUser( new User("theUsername") { UnconfirmedEmailAddress = "*****@*****.**" }, new Credential() { Type = "Foo" }); GetMock <AuthenticationService>() .Setup(x => x.Authenticate("*****@*****.**", "thePassword")) .Returns(authUser); GetMock <AuthenticationService>() .Setup(x => x.CreateSession(It.IsAny <IOwinContext>(), authUser.User, AuthenticationTypes.Password)); var controller = GetController <AuthenticationController>(); var result = controller.SignIn( new SignInRequest { UserNameOrEmail = "*****@*****.**", Password = "******" }, "/packages/upload"); ResultAssert.IsRedirectTo(result, "/packages/upload"); }
public void WillRedirectToTheReturnUrl() { var controller = GetController <AuthenticationController>(); var result = controller.LogOff("theReturnUrl"); ResultAssert.IsRedirectTo(result, "/"); }
public void WillRedirectToTheReturnUrl() { var controller = new TestableAuthenticationController(); controller.MockUsers .Setup(x => x.FindByUsernameOrEmailAddressAndPassword(It.IsAny <string>(), It.IsAny <string>())) .Returns(new User("theUsername", null)); var result = controller.LogOff("theReturnUrl") as RedirectResult; ResultAssert.IsRedirectTo(result, "aSafeRedirectUrl"); }
public void WillRedirectToTheReturnUrl() { var controller = new TestableAuthenticationController(); controller.MockUsers .Setup(x => x.FindByUsernameOrEmailAddressAndPassword(It.IsAny <string>(), It.IsAny <string>())) .Returns(new User("theUsername", null) { EmailAddress = "*****@*****.**" }); var result = controller.LogOn(new SignInRequest(), "theReturnUrl"); ResultAssert.IsRedirectTo(result, "aSafeRedirectUrl"); }
public void WillRedirectToTheReturnUrl() { var controller = GetController <AuthenticationController>(); GetMock <IUserService>() .Setup(x => x.FindByUsernameOrEmailAddressAndPassword(It.IsAny <string>(), It.IsAny <string>())) .Returns(new User("theUsername") { EmailAddress = "*****@*****.**" }); var result = controller.SignIn(new SignInRequest(), "theReturnUrl"); ResultAssert.IsRedirectTo(result, "/"); }
public void WillRedirectToTheReturnUrl() { var controller = GetController <AuthenticationController>(); var user = new User("theUsername") { UnconfirmedEmailAddress = "*****@*****.**" }; GetMock <IUserService>() .Setup(x => x.Create(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>())) .Returns(user); var result = controller.Register(new RegisterRequest { EmailAddress = "*****@*****.**", Password = "******", Username = "******", }, "/theReturnUrl"); ResultAssert.IsRedirectTo(result, "/theReturnUrl"); }
public void WillRedirectToTheReturnUrl() { var user = new User("theUsername") { UnconfirmedEmailAddress = "*****@*****.**" }; GetMock <AuthenticationService>() .Setup(x => x.Register("theUsername", "thepassword", "*****@*****.**")) .Returns(new AuthenticatedUser(user, new Credential())); GetMock <AuthenticationService>() .Setup(x => x.CreateSession(It.IsAny <IOwinContext>(), user, AuthenticationTypes.Password)); var controller = GetController <AuthenticationController>(); var result = controller.Register(new RegisterRequest { EmailAddress = "*****@*****.**", Password = "******", Username = "******", }, "/theReturnUrl"); ResultAssert.IsRedirectTo(result, "/theReturnUrl"); }