Beispiel #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SimpleDataWebServiceClient" /> class.
        /// </summary>
        /// <param name="amplaDatabase">The ampla database.</param>
        /// <param name="amplaConfiguration">The ampla configuration.</param>
        /// <param name="securityWebServiceClient">The security web service client.</param>
        /// <exception cref="System.ArgumentOutOfRangeException">module</exception>
        public SimpleDataWebServiceClient(IAmplaDatabase amplaDatabase, IAmplaConfiguration amplaConfiguration, SimpleSecurityWebServiceClient securityWebServiceClient)
        {
            this.amplaDatabase      = amplaDatabase;
            this.amplaConfiguration = amplaConfiguration;

            this.securityWebServiceClient = securityWebServiceClient;
        }
 protected override void OnTearDown()
 {
     base.OnTearDown();
     webServiceClient = null;
     amplaUserStore   = null;
     amplaUserService = null;
 }
        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));
        }
 protected override void OnSetUp()
 {
     base.OnSetUp();
     webServiceClient = new SimpleSecurityWebServiceClient("User");
     amplaUserStore   = new AmplaUserStore();
     amplaUserService = new AmplaUserService(webServiceClient, amplaUserStore);
 }
Beispiel #6
0
        protected override void OnSetUp()
        {
            base.OnSetUp();
            context = SimpleHttpContext.Create("http://localhost");

            securityWebService = new SimpleSecurityWebServiceClient("User");
            amplaUserService   = new AmplaUserService(securityWebService, new AmplaUserStore());
        }
        protected override void OnSetUp()
        {
            base.OnSetUp();
            webServiceClient = new SimpleSecurityWebServiceClient("User");
            amplaUserStore   = new AmplaUserStore();
            amplaUserService = new AmplaUserService(webServiceClient, amplaUserStore);

            context = SimpleHttpContext.Create("http://localhost");

            controller = new AccountController(amplaUserService, FormsAuthenticationService, AmplaSessionStorage);
        }
Beispiel #8
0
        protected override void OnSetUp()
        {
            base.OnSetUp();
            SimpleSecurityWebServiceClient securityWebService = new SimpleSecurityWebServiceClient("User");
            SimpleAmplaDatabase            amplaDatabase      = new SimpleAmplaDatabase();
            SimpleAmplaConfiguration       configuration      = new SimpleAmplaConfiguration();
            SimpleDataWebServiceClient     client             = new SimpleDataWebServiceClient(amplaDatabase, configuration, securityWebService);

            DataWebServiceFactory.Factory = () => client;
            Strategy = new T();
        }
Beispiel #9
0
        protected override void OnSetUp()
        {
            base.OnSetUp();

            database = new SimpleAmplaDatabase();
            database.EnableModule(module);
            configuration = new SimpleAmplaConfiguration();
            configuration.EnableModule(module);
            configuration.AddLocation(module, location);
            configuration.SetDefaultView(module, ProductionViews.StandardView());

            SimpleSecurityWebServiceClient securityWebService = new SimpleSecurityWebServiceClient("User");

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

            DataWebServiceFactory.Factory = () => webServiceClient;

            dynamicViewPoint = new DynamicViewPoint(location, module);
        }
Beispiel #10
0
        protected override void Load(ContainerBuilder builder)
        {
            base.Load(builder);

            SimpleSecurityWebServiceClient securityClient = new SimpleSecurityWebServiceClient("User");
            SimpleAmplaDatabase            amplaDatabase  = new SimpleAmplaDatabase();

            amplaDatabase.EnableModule("Production");
            amplaDatabase.EnableModule("Quality");
            amplaDatabase.EnableModule("Downtime");

            SimpleAmplaConfiguration configuration = new SimpleAmplaConfiguration();

            configuration.EnableModule("Production");
            configuration.AddLocation("Production", "Enterprise.Site.Area.Production");
            configuration.SetDefaultView("Production", QualityViews.StandardViewPlus(
                                             StandardViews.Field <double>("Weight"),
                                             StandardViews.Field <string>("Material", "Material", false, true)
                                             ));

            configuration.EnableModule("Quality");
            configuration.AddLocation("Quality", "Enterprise.Site.Area.Quality");
            configuration.SetDefaultView("Quality", QualityViews.StandardViewPlus(
                                             StandardViews.Field <double>("Moisture"),
                                             StandardViews.Field <string>("SampleId", "SampleId", false, true),
                                             StandardViews.Field <double>("Silica", "Silica", false, true),
                                             StandardViews.Field <double>("Sodium", "Sodium", false, true)
                                             ));

            configuration.EnableModule("Downtime");
            configuration.AddLocation("Downtime", "Enterprise.Site.Area.Downtime");
            configuration.SetDefaultView("Downtime", DowntimeViews.StandardView());

            builder.RegisterInstance(amplaDatabase).As <IAmplaDatabase>().SingleInstance();
            builder.RegisterInstance(configuration).As <IAmplaConfiguration>().SingleInstance();

            builder.RegisterInstance(securityClient).As <ISecurityWebServiceClient>().SingleInstance();
            builder.RegisterInstance(securityClient).SingleInstance();

            builder.RegisterType <SimpleDataWebServiceClient>().As <IDataWebServiceClient>();
        }
        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);
        }