public void UseSessionIdInCredentials()
        {
            SimpleSecurityWebServiceClient securityWebService = new SimpleSecurityWebServiceClient("User");

            SimpleDataWebServiceClient webServiceClient = new SimpleDataWebServiceClient(database, configuration, securityWebService);

            Assert.Throws <FaultException>(() =>
                                           webServiceClient.GetNavigationHierarchy(new GetNavigationHierarchyRequest()
            {
                Module      = AmplaModules.Production,
                Credentials = new Credentials {
                    Session = Guid.NewGuid().ToString()
                }
            }));

            securityWebService.AddExistingSession("User");

            Assert.That(securityWebService.Sessions, Is.Not.Empty);
            SimpleSession session = securityWebService.Sessions[0];

            webServiceClient.GetNavigationHierarchy(new GetNavigationHierarchyRequest()
            {
                Module      = AmplaModules.Production,
                Credentials = new Credentials {
                    Session = session.SessionId
                }
            });
        }
        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));
        }
예제 #3
0
        public void LoginUsingSession()
        {
            webServiceClient.AddExistingSession("Admin");
            Assert.That(webServiceClient.Sessions, Is.Not.Empty);

            string session = webServiceClient.Sessions[0].SessionId;

            string    message;
            AmplaUser user = amplaUserService.SessionLogin(session, out message);

            Assert.That(user, Is.Not.Null);

            Assert.That(user.UserName, Is.EqualTo("Admin"));
            Assert.That(user.Session, Is.Not.Empty);
            Assert.That(user.Session, Is.EqualTo(session));
            Assert.That(message, Is.Null.Or.Empty);
        }
예제 #4
0
        public void SessionStorageIsSetFromForms()
        {
            securityWebService.AddExistingSession("User");
            string    session = securityWebService.Sessions[0].SessionId;
            string    message;
            AmplaUser user = amplaUserService.SessionLogin(session, out message);

            Assert.That(user, Is.Not.Null);
            FormsAuthenticationService.StoreUserTicket(user, false);

            context.Response.Redirect("http://localhost/Production");

            Assert.That(AmplaSessionStorage.GetAmplaSession(), Is.Empty);
            new AlignSessionWithFormsAuthentication(context.Request, AmplaSessionStorage, FormsAuthenticationService).Execute();

            Assert.That(AmplaSessionStorage.GetAmplaSession(), Is.EqualTo(session));
        }