예제 #1
0
        public virtual async Task ReadAsync()
        {
            if (EnvironmentConnection.IsConnected)
            {
                var communicationController = new CommunicationController
                {
                    ServiceName = "SecurityReadService"
                };
                Dev2Logger.Debug("Getting Permissions from Server", "Warewolf Debug");

                var securitySettingsTo = await communicationController.ExecuteCommandAsync <SecuritySettingsTO>(EnvironmentConnection, EnvironmentConnection.WorkspaceID).ConfigureAwait(true);

                List <WindowsGroupPermission> newPermissions = null;
                if (securitySettingsTo != null)
                {
                    Permissions    = securitySettingsTo.WindowsGroupPermissions;
                    newPermissions = securitySettingsTo.WindowsGroupPermissions;
                    Dev2Logger.Debug("Permissions from Server:" + Permissions, "Warewolf Debug");
                }
                if (newPermissions != null)
                {
                    RaisePermissionsModified(new PermissionsModifiedEventArgs(newPermissions));
                }
                RaisePermissionsChanged();
            }
        }
        public void ExecuteCommandAsync_GivenReturnExploreAuthorizationError_ShouldShowCorrectPopup()
        {
            //---------------Set up test pack-------------------
            var mock = new Mock <IPopupController>();

            mock.Setup(c => c.Show(It.IsAny <string>(), It.IsAny <string>(), MessageBoxButton.OK, MessageBoxImage.Error, "", false, false, true, false, false, false));
            CustomContainer.Register(mock.Object);
            var connection = new Mock <IEnvironmentConnection>();

            connection.Setup(environmentConnection => environmentConnection.IsConnected).Returns(true);
            var serializer = new Dev2JsonSerializer();

            var message = new ExecuteMessage
            {
                HasError = true,
                Message  = new StringBuilder(ErrorResource.NotAuthorizedToExecuteException)
            };

            var serializeToBuilder = serializer.SerializeToBuilder(message);

            connection.Setup(environmentConnection => environmentConnection.ExecuteCommandAsync(It.IsAny <StringBuilder>(), GlobalConstants.ServerWorkspaceID))
            .Returns(Task.FromResult(serializeToBuilder));
            var controller = new CommunicationController();
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------

            var explorerRepositoryResult = controller.ExecuteCommandAsync <ExplorerRepositoryResult>(connection.Object, GlobalConstants.ServerWorkspaceID).Result;

            //---------------Test Result -----------------------
            mock.Verify(c => c.Show(It.IsAny <string>(), It.IsAny <string>(), MessageBoxButton.OK, MessageBoxImage.Error, "", false, false, true, false, false, false), Times.Once);
        }
        public void ExecuteCommandAsync_GivenHasAuthorizationError_ShouldShowCorrectPopup_Aggregation()
        {
            //---------------Set up test pack-------------------
            var mock = new Mock <IPopupController>();

            mock.Setup(c => c.Show(It.IsAny <string>(), It.IsAny <string>(), MessageBoxButton.OK, MessageBoxImage.Error, "", false, false, true, false, false, false));
            CustomContainer.Register(mock.Object);
            var connection = new Mock <IEnvironmentConnection>();

            connection.Setup(environmentConnection => environmentConnection.IsConnected).Returns(true);
            var aggregateException = new AggregateException();

            connection.Setup(environmentConnection => environmentConnection.ExecuteCommandAsync(It.IsAny <StringBuilder>(), GlobalConstants.ServerWorkspaceID))
            .Throws(aggregateException);
            var controller = new CommunicationController();

            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------

            controller.ExecuteCommandAsync <ExecuteMessage>(connection.Object, GlobalConstants.ServerWorkspaceID).ContinueWith((d) =>
            {
                //---------------Test Result -----------------------
                Assert.IsNotNull(d);
                mock.Verify(c => c.Show(ErrorResource.NotAuthorizedToCreateException, "ServiceNotAuthorizedException", MessageBoxButton.OK, MessageBoxImage.Error, "", false, false, true, false, false, false), Times.Never);
            });
        }
예제 #4
0
        public async Task <ExecuteMessage> GetDependenciesXmlAsync(IContextualResourceModel resourceModel, bool getDependsOnMe)
        {
            if (resourceModel == null)
            {
                return(new ExecuteMessage {
                    HasError = false
                });
            }

            var comsController = new CommunicationController {
                ServiceName = "FindDependencyService"
            };

            comsController.AddPayloadArgument("ResourceId", resourceModel.ID.ToString());
            comsController.AddPayloadArgument("GetDependsOnMe", getDependsOnMe.ToString());

            var workspaceId = resourceModel.Environment.Connection.WorkspaceID;
            var payload     = await comsController.ExecuteCommandAsync <ExecuteMessage>(resourceModel.Environment.Connection, workspaceId);

            if (payload == null)
            {
                throw new Exception(string.Format(GlobalConstants.NetworkCommunicationErrorTextFormat, "FindDependencyService"));
            }

            return(payload);
        }
예제 #5
0
        public async Task <ExecuteMessage> DeleteResourceFromWorkspaceAsync(IContextualResourceModel resourceModel)
        {
            if (resourceModel == null)
            {
                var msg = new ExecuteMessage {
                    HasError = true
                };
                msg.SetMessage("Failure");
                return(msg);
            }

            var comsController = new CommunicationController {
                ServiceName = "DeleteResourceService"
            };

            if (!string.IsNullOrEmpty(resourceModel.ResourceName) && resourceModel.ResourceName.Contains("Unsaved"))
            {
                comsController.AddPayloadArgument("ResourceID", resourceModel.ID.ToString());
                comsController.AddPayloadArgument("ResourceType", resourceModel.ResourceType.ToString());
                ExecuteMessage deleteResourceFromWorkspace = await comsController.ExecuteCommandAsync <ExecuteMessage>(_server.Connection, _server.Connection.WorkspaceID);

                return(deleteResourceFromWorkspace);
            }

            var res = _resourceModels.FirstOrDefault(c => c.ID == resourceModel.ID);

            if (res == null)
            {
                var msg = new ExecuteMessage {
                    HasError = true
                };
                msg.SetMessage("Failure");
                return(msg);
            }

            comsController.AddPayloadArgument("ResourceID", resourceModel.ID.ToString());
            comsController.AddPayloadArgument("ResourceType", resourceModel.ResourceType.ToString());
            return(await comsController.ExecuteCommandAsync <ExecuteMessage>(_server.Connection, _server.Connection.WorkspaceID));
        }
예제 #6
0
        public async Task <ExecuteMessage> ResumeWorkflowExecutionAsync(string resourceId, string environment, string startActivityId, string versionNumber, string currentUserPrincipal)
        {
            var comController = new CommunicationController {
                ServiceName = "WorkflowResume"
            };

            comController.AddPayloadArgument("resourceID", resourceId);
            comController.AddPayloadArgument("environment", environment);
            comController.AddPayloadArgument("startActivityId", startActivityId);
            comController.AddPayloadArgument("versionNumber", versionNumber);
            comController.AddPayloadArgument("currentuserprincipal", currentUserPrincipal);

            var result = comController.ExecuteCommandAsync <ExecuteMessage>(_environmentConnection, GlobalConstants.ServerWorkspaceID);

            return(await result);
        }
예제 #7
0
        /// <summary>
        /// Fetches the resource definition Asyncronouly.
        /// </summary>
        /// <param name="targetEnv">The target env.</param>
        /// <param name="workspaceId">The workspace unique identifier.</param>
        /// <param name="resourceModelId">The resource model unique identifier.</param>
        /// <param name="prepaireForDeployment"></param>
        /// <returns></returns>
        public async Task <ExecuteMessage> FetchResourceDefinitionAsync(IServer targetEnv, Guid workspaceId, Guid resourceModelId, bool prepaireForDeployment)
        {
            var comsController = new CommunicationController {
                ServiceName = "FetchResourceDefinitionService"
            };

            comsController.AddPayloadArgument("ResourceID", resourceModelId.ToString());
            comsController.AddPayloadArgument("PrepairForDeployment", prepaireForDeployment.ToString());

            var result = await comsController.ExecuteCommandAsync <ExecuteMessage>(targetEnv.Connection, workspaceId);

            // log the trace for fetch ;)
            if (result != null)
            {
                Dev2Logger.Debug($"Fetched Definition For {resourceModelId} From Workspace {workspaceId}");
            }

            return(result);
        }
예제 #8
0
 public virtual async Task ReadAsync()
 {
     var communicationController = new CommunicationController
     {
         ServiceName = "SecurityReadService"
     };
     Dev2Logger.Log.Debug("Getting Permissions from Server");
     SecuritySettingsTO securitySettingsTo = await communicationController.ExecuteCommandAsync<SecuritySettingsTO>(EnvironmentConnection, EnvironmentConnection.WorkspaceID);
     List<WindowsGroupPermission> newPermissions = null;
     if (securitySettingsTo != null)
     {
         Permissions = securitySettingsTo.WindowsGroupPermissions;
         newPermissions = securitySettingsTo.WindowsGroupPermissions;
         Dev2Logger.Log.Debug("Permissions from Server:" + Permissions);
     }
     if (newPermissions != null)
     {
         RaisePermissionsModified(new PermissionsModifiedEventArgs(newPermissions));
     }
     RaisePermissionsChanged();
 }