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)); }
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 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); }