コード例 #1
0
        internal IResponseWriter TryExecute(WebRequestTO webRequest, string serviceName, string workspaceId, NameValueCollection headers, IPrincipal user)
        {
            _workspaceGuid = EnsureWorkspaceIdValid(workspaceId);
            _serializer    = new Dev2JsonSerializer();

            PrepareDataObject(webRequest, serviceName, headers, user, _workspaceGuid, out _resource);
            var isTestCoverage = _dataObject.ReturnType == EmitionTypes.Cover || _dataObject.ReturnType == EmitionTypes.CoverJson;
            var isTestRun      = (_dataObject.ReturnType == EmitionTypes.TEST ||
                                  _dataObject.ReturnType == EmitionTypes.TRX) && _dataObject.TestName == "*";

            if (isTestRun)
            {
                if (_serviceTestExecutor == null)
                {
                    _serviceTestExecutor = new ServiceTestExecutor();
                }
                return(ExecuteAsTest(user));
            }

            if (isTestCoverage)
            {
                return(ExecuteAsCoverage(webRequest, serviceName, _resource));
            }

            if (_resource is null)
            {
                var msg = string.Format(Warewolf.Resource.Errors.ErrorResource.ServiceNotFound, serviceName);
                _dataObject.Environment.AddError(msg);
                _dataObject.ExecutionException = new Exception(msg);
                _executionDataListId           = GlobalConstants.NullDataListID;
                return(null);
            }

            var workflowCanBeExecutedByGroup = _dataObject.CanExecuteCurrentResource(_resource, _authorizationService);

            _canExecute = workflowCanBeExecutedByGroup;

            _executionDataListId = GlobalConstants.NullDataListID;
            if (!_canExecute)
            {
                var message = webRequest.IsUrlWithTokenPrefix
                        ? Warewolf.Resource.Errors.ErrorResource.TokenNotAuthorizedToExecuteOuterWorkflowException
                        : Warewolf.Resource.Errors.ErrorResource.UserNotAuthorizedToExecuteOuterWorkflowException;

                var errorMessage = string.Format(message, _dataObject.ExecutingUser?.Identity.Name, _dataObject.ServiceName);
                _dataObject.Environment.AddError(errorMessage);
                _dataObject.ExecutionException = new AccessDeniedException(errorMessage);
            }
            else
            {
                if (_dataObject.ReturnType != EmitionTypes.OPENAPI)
                {
                    Thread.CurrentPrincipal = user;
                    _executionDataListId    = DoExecution(webRequest, serviceName, _workspaceGuid, _dataObject, user);
                }
            }

            return(null);
        }
コード例 #2
0
 protected ExecutorBase(IWorkspaceRepository workspaceRepository, IResourceCatalog resourceCatalog, ITestCatalog testCatalog, ITestCoverageCatalog testCoverageCatalog, IServiceTestExecutor serviceTestExecutor, IAuthorizationService authorizationService, IDataObjectFactory dataObjectFactory, IEsbChannelFactory esbChannelFactory, IJwtManager jwtManager)
 {
     _repository           = workspaceRepository;
     _resourceCatalog      = resourceCatalog;
     _testCatalog          = testCatalog;
     _testCoverageCatalog  = testCoverageCatalog;
     _authorizationService = authorizationService;
     _dataObjectFactory    = dataObjectFactory;
     _esbChannelFactory    = esbChannelFactory;
     _jwtManager           = jwtManager;
     _serviceTestExecutor  = serviceTestExecutor;
 }
コード例 #3
0
 protected AbstractWebRequestHandler(IResourceCatalog resourceCatalog, ITestCatalog testCatalog, ITestCoverageCatalog testCoverageCatalog, IServiceTestExecutor serviceTestExecutor, IWorkspaceRepository workspaceRepository, IAuthorizationService authorizationService, IDataObjectFactory dataObjectFactory, IEsbChannelFactory esbChannelFactory, ISecuritySettings securitySettings, IJwtManager jwtManager)
 {
     _resourceCatalog      = resourceCatalog;
     _testCatalog          = testCatalog;
     _testCoverageCatalog  = testCoverageCatalog;
     _serviceTestExecutor  = serviceTestExecutor;
     _workspaceRepository  = workspaceRepository;
     _authorizationService = authorizationService;
     _dataObjectFactory    = dataObjectFactory;
     _esbChannelFactory    = esbChannelFactory;
     _securitySettings     = securitySettings;
     _jwtManager           = jwtManager;
 }
コード例 #4
0
 protected AbstractWebRequestHandler(IResourceCatalog resourceCatalog, ITestCatalog testCatalog, ITestCoverageCatalog testCoverageCatalog, IServiceTestExecutor serviceTestExecutor, IWorkspaceRepository workspaceRepository, IAuthorizationService authorizationService, IDataObjectFactory dataObjectFactory, IEsbChannelFactory esbChannelFactory, ISecuritySettings securitySettings)
     : this(resourceCatalog, testCatalog, testCoverageCatalog, serviceTestExecutor, workspaceRepository, authorizationService, dataObjectFactory, esbChannelFactory, securitySettings, new JwtManager(securitySettings))
 {
 }
コード例 #5
0
ファイル: Executor.cs プロジェクト: Warewolf-ESB/Warewolf
 public Executor(IWorkspaceRepository workspaceRepository, IResourceCatalog resourceCatalog, ITestCatalog testCatalog, ITestCoverageCatalog testCoverageCatalog, IServiceTestExecutor serviceTestExecutor, IAuthorizationService authorizationService, IDataObjectFactory dataObjectFactory, IEsbChannelFactory esbChannelFactory, IJwtManager jwtManager)
     : base(workspaceRepository, resourceCatalog, testCatalog, testCoverageCatalog, serviceTestExecutor, authorizationService, dataObjectFactory, esbChannelFactory, jwtManager)
 {
 }