コード例 #1
0
        public SecurityPolicyService(IEntitiesContext entitiesContext, IAuditingService auditing, IDiagnosticsService diagnostics,
                                     SecurePushSubscription securePush = null)
        {
            EntitiesContext = entitiesContext ?? throw new ArgumentNullException(nameof(entitiesContext));
            Auditing        = auditing ?? throw new ArgumentNullException(nameof(auditing));
            SecurePush      = securePush;

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

            Diagnostics = diagnostics.SafeGetSource(nameof(SecurityPolicyService));
        }
コード例 #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();
        }
コード例 #3
0
        private TestSecurityPolicyService CreateSecurityPolicyService()
        {
            var auditing = new Mock <IAuditingService>();

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

            var diagnostics        = new DiagnosticsService().GetSource(nameof(SecurePushSubscriptionFacts));
            var diagnosticsService = new Mock <IDiagnosticsService>();

            diagnosticsService.Setup(s => s.GetSource(It.IsAny <string>())).Returns(diagnostics);

            var subscription = new SecurePushSubscription(auditing.Object, diagnosticsService.Object);

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

            return(service);
        }