public void LoadUserPolicyHandlersPopulatesAllHandlers()
        {
            // Arrange & Act
            var service  = new SecurityPolicyService();
            var handlers = ((IEnumerable <UserSecurityPolicyHandler>)service.GetType()
                            .GetProperty("UserPolicyHandlers", BindingFlags.GetProperty | BindingFlags.NonPublic | BindingFlags.Instance)
                            .GetValue(service)).ToList();

            // Assert
            Assert.NotNull(handlers);
            Assert.Equal(2, handlers.Count);
            Assert.Equal(typeof(RequireMinClientVersionForPushPolicy), handlers[0].GetType());
            Assert.Equal(typeof(RequirePackageVerifyScopePolicy), handlers[1].GetType());
        }
Пример #2
0
        public void UserHandlers_ReturnsRegisteredUserSecurityPolicyHandlers()
        {
            // Arrange.
            var service = new SecurityPolicyService(_entities, _auditing, _diagnostics);

            // Act.
            var handlers = ((IEnumerable <UserSecurityPolicyHandler>)service.GetType()
                            .GetProperty("UserHandlers", BindingFlags.GetProperty | BindingFlags.NonPublic | BindingFlags.Instance)
                            .GetValue(service)).ToList();

            // Assert
            Assert.NotNull(handlers);
            Assert.Equal(2, handlers.Count);
            Assert.Equal(typeof(RequireMinClientVersionForPushPolicy), handlers[0].GetType());
            Assert.Equal(typeof(RequirePackageVerifyScopePolicy), handlers[1].GetType());
        }
Пример #3
0
        public void PackageHandlers_ReturnsRegisteredPackageSecurityPolicyHandlers()
        {
            // Arrange.
            var service = new SecurityPolicyService(_entities, _auditing, _diagnostics, _configuration, _userServiceFactory, _packageOwnershipManagementServiceFactory, _telemetryService);

            // Act.
            var handlers = ((IEnumerable <PackageSecurityPolicyHandler>)service.GetType()
                            .GetProperty("PackageHandlers", BindingFlags.GetProperty | BindingFlags.NonPublic | BindingFlags.Instance)
                            .GetValue(service))
                           .OfType <PackageSecurityPolicyHandler>().ToList();

            // Assert
            Assert.NotNull(handlers);
            Assert.Equal(1, handlers.Count);
            Assert.Equal(typeof(RequirePackageMetadataCompliancePolicy), handlers[0].GetType());
        }
Пример #4
0
        public void UserHandlers_ReturnsRegisteredUserSecurityPolicyHandlers()
        {
            // Arrange.
            var service = new SecurityPolicyService(_entities, _auditing, _diagnostics, _configuration, _userServiceFactory, _packageOwnershipManagementServiceFactory, _telemetryService);

            // Act.
            var handlers = ((IEnumerable <UserSecurityPolicyHandler>)service.GetType()
                            .GetProperty("UserHandlers", BindingFlags.GetProperty | BindingFlags.NonPublic | BindingFlags.Instance)
                            .GetValue(service)).ToList();

            // Assert
            Assert.NotNull(handlers);
            Assert.Equal(5, handlers.Count);
            Assert.Equal(typeof(RequirePackageVerifyScopePolicy), handlers[0].GetType());
            Assert.Equal(typeof(RequireMinProtocolVersionForPushPolicy), handlers[1].GetType());
            Assert.Equal(typeof(RequireOrganizationTenantPolicy), handlers[2].GetType());
            Assert.Equal(typeof(ControlRequiredSignerPolicy), handlers[3].GetType());
            Assert.Equal(typeof(AutomaticallyOverwriteRequiredSignerPolicy), handlers[4].GetType());
        }