public SecurityPolicyService(
            IEntitiesContext entitiesContext,
            IAuditingService auditing,
            IDiagnosticsService diagnostics,
            IAppConfiguration configuration,
            Lazy <IUserService> userService,
            Lazy <IPackageOwnershipManagementService> packageOwnershipManagementService,
            ITelemetryService telemetryService,
            MicrosoftTeamSubscription microsoftTeamSubscription = null)
        {
            EntitiesContext = entitiesContext ?? throw new ArgumentNullException(nameof(entitiesContext));
            Auditing        = auditing ?? throw new ArgumentNullException(nameof(auditing));

            if (diagnostics == null)
            {
                throw new ArgumentNullException(nameof(diagnostics));
            }

            Diagnostics                        = diagnostics.SafeGetSource(nameof(SecurityPolicyService));
            Configuration                      = configuration ?? throw new ArgumentNullException(nameof(configuration));
            DefaultSubscription                = new DefaultSubscription();
            MicrosoftTeamSubscription          = microsoftTeamSubscription;
            _packageOwnershipManagementService = packageOwnershipManagementService ?? throw new ArgumentNullException(nameof(packageOwnershipManagementService));
            _userService                       = userService ?? throw new ArgumentNullException(nameof(userService));
            _telemetryService                  = telemetryService ?? throw new ArgumentNullException(nameof(telemetryService));
        }
Exemple #2
0
        public SecurityPolicyService(IEntitiesContext entitiesContext, IAuditingService auditing, IDiagnosticsService diagnostics, IAppConfiguration configuration,
                                     SecurePushSubscription securePush = null, RequireSecurePushForCoOwnersPolicy securePushForCoOwners = null)
        {
            EntitiesContext       = entitiesContext ?? throw new ArgumentNullException(nameof(entitiesContext));
            Auditing              = auditing ?? throw new ArgumentNullException(nameof(auditing));
            SecurePush            = securePush;
            SecurePushForCoOwners = securePushForCoOwners;

            if (diagnostics == null)
            {
                throw new ArgumentNullException(nameof(diagnostics));
            }

            Diagnostics         = diagnostics.SafeGetSource(nameof(SecurityPolicyService));
            Configuration       = configuration ?? throw new ArgumentNullException(nameof(configuration));
            DefaultSubscription = new DefaultSubscription();
        }
        private TestSecurityPolicyService CreateSecurityPolicyService()
        {
            var auditing = new Mock <IAuditingService>();

            auditing.Setup(s => s.SaveAuditRecordAsync(It.IsAny <AuditRecord>())).Returns(Task.CompletedTask).Verifiable();

            var subscription = new DefaultSubscription();

            var service = new TestSecurityPolicyService(
                mockAuditing: auditing,
                userHandlers: new UserSecurityPolicyHandler[]
            {
                new RequireMinProtocolVersionForPushPolicy(),
                new RequirePackageVerifyScopePolicy()
            },
                userSubscriptions: new[] { subscription });

            return(service);
        }