public void AutomaticLoginFromSession() { SimpleSecurityWebServiceClient webServiceClient = new SimpleSecurityWebServiceClient("User"); webServiceClient.AddExistingSession("User"); string session = webServiceClient.Sessions[0].SessionId; string url = "http://localhost/?amplaSession=" + session; context = SimpleHttpContext.Create(url); IAmplaUserService amplaUserService = new AmplaUserService(webServiceClient, new AmplaUserStore()); Assert.That(SessionStorage.GetAmplaSession(), Is.Empty); LoginAmplaSessionUsingQueryString loginAmplaSession = new LoginAmplaSessionUsingQueryString(context.Request, context.Response, amplaUserService, FormsAuthenticationService, SessionStorage); loginAmplaSession.Execute(); Assert.That(context.Request.Cookies, Is.Not.Empty); Assert.That(context.Request.Url, Is.EqualTo(new Uri("http://localhost/"))); Assert.That(SessionStorage.GetAmplaSession(), Is.EqualTo(session)); var ticket = FormsAuthenticationService.GetUserTicket(); Assert.That(ticket, Is.Not.Null); Assert.That(ticket.UserData, Is.EqualTo(session)); }
public void NoSession() { SimpleSecurityWebServiceClient webServiceClient = new SimpleSecurityWebServiceClient("User"); const string session = "invalid"; const string url = "http://localhost/?amplaSession=" + session; context = SimpleHttpContext.Create(url); IAmplaUserService amplaUserService = new AmplaUserService(webServiceClient, new AmplaUserStore()); LoginAmplaSessionUsingQueryString loginAmplaSession = new LoginAmplaSessionUsingQueryString(context.Request, context.Response, amplaUserService, FormsAuthenticationService, SessionStorage); loginAmplaSession.Execute(); Assert.That(context.Request.Cookies, Is.Empty); Assert.That(context.Request.Url, Is.EqualTo(new Uri(url))); var ticket = FormsAuthenticationService.GetUserTicket(); Assert.That(ticket, Is.Null); Assert.That(SessionStorage.GetAmplaSession(), Is.Empty); }