Beispiel #1
0
        static XafApplication NewApplication(this Platform platform, ModuleBase[] modules)
        {
            var xafApplication = platform.NewApplication <MicrosoftTodoModule>();

            xafApplication.Modules.AddRange(modules);
            return(xafApplication);
        }
Beispiel #2
0
        static XafApplication NewApplication(this Platform platform, ModuleBase[] modules)
        {
            var xafApplication = platform.NewApplication <GoogleCalendarModule>();

            xafApplication.Modules.AddRange(modules);
            return(xafApplication);
        }
Beispiel #3
0
        protected MicrosoftModule MicrosoftModule(Platform platform = Platform.Win, params ModuleBase[] modules)
        {
            var application = NewApplication(platform, modules);

            application.SetupSecurity(true);
            var module = application.AddModule <MicrosoftModule>();

            application.Model.ConfigureMicrosoft();
            application.Logon();
            application.CreateObjectSpace();
            return(module.Application.Modules.OfType <MicrosoftModule>().First());
        }
Beispiel #4
0
        public async Task Actions_Active_State_when_authentication_not_needed([ValueSource(nameof(PlatformDatasource))] Platform platform)
        {
            using (var application = MicrosoftModule(platform).Application){
                application.ObjectSpaceProvider.NewMicrosoftAuthentication(platform);
                var compositeView = application.NewView(ViewType.DetailView, application.Security.UserType);
                compositeView.CurrentObject = compositeView.ObjectSpace.GetObjectByKey(application.Security.UserType, SecuritySystem.CurrentUserId);
                var viewWindow = application.CreateViewWindow();

                viewWindow.SetView(compositeView);

                await ActiveState(viewWindow, false).ConfigureAwait(false);
            }
        }
Beispiel #5
0
        public void Actions_are_Activated_For_CurrentUser_Details([ValueSource(nameof(PlatformDatasource))] Platform platform)
        {
            using (var application = MicrosoftModule(platform).Application){
                var compositeView = application.NewView(ViewType.DetailView, application.Security.UserType);
                compositeView.CurrentObject = compositeView.ObjectSpace.GetObjectByKey(application.Security.UserType, SecuritySystem.CurrentUserId);
                var viewWindow = application.CreateViewWindow();

                viewWindow.SetView(compositeView);

                var msActions = viewWindow.Action <MicrosoftModule>();
                msActions.ConnectMicrosoft().Active[nameof(ActionsService.ActivateInUserDetails)].ShouldBeTrue();
                msActions.DisconnectMicrosoft().Active[nameof(ActionsService.ActivateInUserDetails)].ShouldBeTrue();
            }
        }
Beispiel #6
0
        public void Actions_Active_State_when_authentication_needed([ValueSource(nameof(PlatformDatasource))] Platform platform)
        {
            using (var application = MicrosoftModule(platform).Application){
                var compositeView = application.NewView(ViewType.DetailView, application.Security.UserType);
                compositeView.CurrentObject = compositeView.ObjectSpace.GetObjectByKey(application.Security.UserType, SecuritySystem.CurrentUserId);
                var viewWindow = application.CreateViewWindow();

                viewWindow.SetView(compositeView);

                var actions = viewWindow.Action <MicrosoftModule>();

                actions.ConnectMicrosoft().Active[nameof(MicrosoftService.MicrosoftNeedsAuthentication)].ShouldBeTrue();
                actions.DisconnectMicrosoft().Active[nameof(MicrosoftService.MicrosoftNeedsAuthentication)].ShouldBeFalse();
            }
        }
Beispiel #7
0
        public static GoogleCalendarModule CalendarModule(this Platform platform, params ModuleBase[] modules)
        {
            var application = NewApplication(platform, modules);

            application.SetupGoogleSecurity();
            var module = application.AddModule <GoogleCalendarModule>(typeof(Event));

            application.Model.ConfigureGoogle(platform);
            var todoModel  = application.Model.ToReactiveModule <IModelReactiveModuleOffice>().Office.Google().Calendar();
            var dependency = todoModel.Items.AddNode <IModelCalendarItem>();

            dependency.ObjectView = application.Model.BOModel.GetClass(typeof(Event)).DefaultDetailView;
            application.Logon();
            application.CreateObjectSpace();
            return(module.Application.Modules.OfType <GoogleCalendarModule>().First());
        }
Beispiel #8
0
        public static MicrosoftTodoModule TodoModule(this Platform platform, params ModuleBase[] modules)
        {
            var application = NewApplication(platform, modules);

            application.SetupSecurity(true);
            var module = application.AddModule <MicrosoftTodoModule>(typeof(Task));

            application.Model.ConfigureMicrosoft();
            var todoModel  = application.Model.ToReactiveModule <IModelReactiveModuleOffice>().Office.Microsoft().Todo();
            var dependency = todoModel.Items.AddNode <IModelTodoItem>();

            dependency.ObjectView = application.Model.BOModel.GetClass(typeof(Task)).DefaultDetailView;
            application.Logon();
            application.CreateObjectSpace();
            return(module.Application.Modules.OfType <MicrosoftTodoModule>().First());
        }
Beispiel #9
0
        public static MicrosoftTodoModule TodoModule(this Platform platform, params ModuleBase[] modules)
        {
            var application             = NewApplication(platform, modules);
            var securityStrategyComplex = new SecurityStrategyComplex(typeof(PermissionPolicyUser),
                                                                      typeof(PermissionPolicyRole), new AuthenticationStandard());

            application.Security = securityStrategyComplex;
            var module     = application.AddModule <MicrosoftTodoModule>(typeof(Task));
            var todoModel  = application.Model.ToReactiveModule <IModelReactiveModuleOffice>().Office.Microsoft().Todo();
            var dependency = ((IModelObjectViews)todoModel).ObjectViews.AddNode <IModelObjectViewDependency>();

            dependency.ObjectView = application.Model.BOModel.GetClass(typeof(Task)).DefaultDetailView;
            application.Logon();
            application.CreateObjectSpace();
            return(module.Application.Modules.OfType <MicrosoftTodoModule>().First());
        }
        public static MicrosoftCalendarModule CalendarModule(this Platform platform, params ModuleBase[] modules)
        {
            var application = NewApplication(platform, modules);

            application.SetupSecurity(true);
            var module = application.AddModule <MicrosoftCalendarModule>(typeof(DevExpress.Persistent.BaseImpl.Event));

            application.Model.ConfigureMicrosoft();
            var todoModel  = application.Model.ToReactiveModule <IModelReactiveModuleOffice>().Office.Microsoft().Calendar();
            var dependency = (todoModel).Items.AddNode <IModelCalendarItem>();

            dependency.ObjectView = application.Model.BOModel.GetClass(typeof(DevExpress.Persistent.BaseImpl.Event)).DefaultDetailView;
            application.Logon();
            application.CreateObjectSpace();
            return(module.Application.Modules.OfType <MicrosoftCalendarModule>().First());
        }
Beispiel #11
0
        public async Task DisconnectMicrosoft_Action_Destroys_Connection([ValueSource(nameof(PlatformDatasource))] Platform platform)
        {
            using (var application = MicrosoftModule(platform).Application){
                application.ObjectSpaceProvider.NewMicrosoftAuthentication(platform);
                var compositeView = application.NewView(ViewType.DetailView, application.Security.UserType);
                compositeView.CurrentObject = compositeView.ObjectSpace.GetObjectByKey(application.Security.UserType, SecuritySystem.CurrentUserId);
                var viewWindow = application.CreateViewWindow();
                viewWindow.SetView(compositeView);

                var disconnectMicrosoft = viewWindow.Action <MicrosoftModule>().DisconnectMicrosoft();
                await disconnectMicrosoft.WhenActivated().FirstAsync().ToTaskWithoutConfigureAwait();

                disconnectMicrosoft.DoExecute();

                disconnectMicrosoft.Active[nameof(MicrosoftService.MicrosoftNeedsAuthentication)].ShouldBeFalse();
                viewWindow.Action <MicrosoftModule>().ConnectMicrosoft().Active[nameof(MicrosoftService.MicrosoftNeedsAuthentication)].ShouldBeTrue();
            }
        }
Beispiel #12
0
        public async Task ConnectMicrosoft_Action_Creates_Connection([ValueSource(nameof(PlatformDatasource))] Platform platform)
        {
            using (var application = MicrosoftModule(platform).Application){
                var compositeView = application.NewView(ViewType.DetailView, application.Security.UserType);
                compositeView.CurrentObject = compositeView.ObjectSpace.GetObjectByKey(application.Security.UserType, SecuritySystem.CurrentUserId);
                var viewWindow = application.CreateViewWindow();
                viewWindow.SetView(compositeView);
                MicrosoftService.CustomAquireTokenInteractively
                .Do(args => application.ObjectSpaceProvider.NewMicrosoftAuthentication(platform))
                .Do(e => e.Instance = Observable.Empty <AuthenticationResult>().FirstOrDefaultAsync()).Test();
                var connectMicrosoft    = viewWindow.Action <MicrosoftModule>().ConnectMicrosoft();
                var disconnectMicrosoft = viewWindow.Action <MicrosoftModule>().DisconnectMicrosoft();

                connectMicrosoft.DoExecute();

                await connectMicrosoft.WhenDeactivated().FirstAsync().Merge(disconnectMicrosoft.WhenActivated().FirstAsync()).Take(2).ToTaskWithoutConfigureAwait();

                connectMicrosoft.Active[nameof(MicrosoftService.MicrosoftNeedsAuthentication)].ShouldBeFalse();
                disconnectMicrosoft.Active[nameof(MicrosoftService.MicrosoftNeedsAuthentication)].ShouldBeTrue();
            }
        }
Beispiel #13
0
        public async Task NeedsAuthentication_when_MSAuthentication_does_not_contain_current_user([ValueSource(nameof(PlatformDatasource))] Platform platform)
        {
            using (var application = MicrosoftModule(platform).Application){
                var needsAuthentication = await application.MicrosoftNeedsAuthentication();

                needsAuthentication.ShouldBeTrue();
            }
        }
Beispiel #14
0
 protected override void OnConnect_Action_Creates_Connection(Platform platform, XafApplication application)
 => MicrosoftService.CustomAcquireTokenInteractively
 .Do(_ => application.ObjectSpaceProvider.NewAuthentication(platform))
 .Do(e => e.Instance = Observable.Empty <AuthenticationResult>().FirstOrDefaultAsync()).Test();
Beispiel #15
0
 protected override void NewAuthentication(Platform platform, XafApplication application) => application.ObjectSpaceProvider.NewAuthentication(platform);
Beispiel #16
0
 protected override XafApplication Application(Platform platform) => MicrosoftModule(platform).Application;
Beispiel #17
0
        public async Task Not_NeedsAuthentication_when_MSAuthentication_current_user_can_authenticate([ValueSource(nameof(PlatformDatasource))] Platform platform)
        {
            using (var application = MicrosoftModule(platform).Application){
                application.ObjectSpaceProvider.NewMicrosoftAuthentication(platform);

                var needsAuthentication = await application.MicrosoftNeedsAuthentication();

                needsAuthentication.ShouldBeFalse();
            }
        }
Beispiel #18
0
        public async Task NeedsAuthentication_when_MSAuthentication_current_user_cannot_authenticate([ValueSource(nameof(PlatformDatasource))] Platform platform)
        {
            using (var application = MicrosoftModule(platform).Application){
                await application.NewObjectSpace(space => {
                    var msAuthentication = space.CreateObject <MSAuthentication>();
                    msAuthentication.Oid = (Guid)SecuritySystem.CurrentUserId;
                    space.CommitChanges();
                    return(Unit.Default.ReturnObservable());
                });

                var needsAuthentication = await application.MicrosoftNeedsAuthentication();

                needsAuthentication.ShouldBeTrue();
            }
        }