public void should_read_only_events_forward_with_stream_id_regex()
        {
            var filter = new TcpClientMessageDto.Filter(
                FilterContext.StreamId,
                FilterType.Regex, new[] { @"^.*ES2.*$" });
            var eventFilter = EventFilter.Get(filter);

            var result = ReadIndex.ReadAllEventsForwardFiltered(_forwardReadPos, 10, 10, eventFilter);

            Assert.AreEqual(1, result.Records.Count);
        }
        public void should_read_only_events_backward_with_event_type_regex()
        {
            var filter = new TcpClientMessageDto.Filter(
                FilterContext.EventType,
                FilterType.Regex, new[] { @"^.*other-event.*$" });
            var eventFilter = EventFilter.Get(filter);

            var result = ReadIndex.ReadAllEventsBackwardFiltered(_backwardReadPos, 10, 10, eventFilter);

            Assert.AreEqual(2, result.Records.Count);
        }
        public void should_read_only_events_backward_with_stream_id_prefix()
        {
            var filter = new TcpClientMessageDto.Filter(
                FilterContext.StreamId,
                FilterType.Prefix, new[] { "ES2" });
            var eventFilter = EventFilter.Get(filter);

            var result = ReadIndex.ReadAllEventsBackwardFiltered(_backwardReadPos, 10, 10, eventFilter);

            Assert.AreEqual(1, result.Records.Count);
        }
        public void should_read_only_events_forward_with_event_type_prefix()
        {
            var filter = new TcpClientMessageDto.Filter(
                FilterContext.EventType,
                FilterType.Prefix, new[] { "event-type" });
            var eventFilter = EventFilter.Get(filter);

            var result = ReadIndex.ReadAllEventsForwardFiltered(_forwardReadPos, 10, 10, eventFilter);

            Assert.AreEqual(2, result.Records.Count);
        }
예제 #5
0
        public void should_read_only_events_backward_with_event_type_prefix()
        {
            var filter = new Filter(
                Filter.Types.FilterContext.EventType,
                Filter.Types.FilterType.Prefix, new[] { "event-type" });
            var eventFilter = EventFilter.Get(true, filter);

            var result = ReadIndex.ReadAllEventsBackwardFiltered(_backwardReadPos, 10, 10, eventFilter);

            Assert.AreEqual(2, result.Records.Count);
        }
예제 #6
0
        public void should_read_only_events_forward_with_stream_id_prefix()
        {
            var filter = new Filter(
                Filter.Types.FilterContext.StreamId,
                Filter.Types.FilterType.Prefix, new[] { "ES2" });
            var eventFilter = EventFilter.Get(true, filter);

            var result = ReadIndex.ReadAllEventsForwardFiltered(_forwardReadPos, 10, 10, eventFilter);

            Assert.AreEqual(1, result.Records.Count);
        }
예제 #7
0
        public void should_read_only_events_forward_with_event_type_regex()
        {
            var filter = new Filter(
                Filter.Types.FilterContext.EventType,
                Filter.Types.FilterType.Regex, new[] { @"^.*other-event.*$" });
            var eventFilter = EventFilter.Get(true, filter);

            var result = ReadIndex.ReadAllEventsForwardFiltered(_forwardReadPos, 10, 10, eventFilter);

            Assert.AreEqual(2, result.Records.Count);
        }
예제 #8
0
        public void should_read_only_events_backward_with_stream_id_regex()
        {
            var filter = new Filter(
                Filter.Types.FilterContext.StreamId,
                Filter.Types.FilterType.Regex, new[] { @"^.*ES2.*$" });
            var eventFilter = EventFilter.Get(true, filter);

            var result = ReadIndex.ReadAllEventsBackwardFiltered(_backwardReadPos, 10, 10, eventFilter);

            Assert.AreEqual(1, result.Records.Count);
        }
        public void should_filter_out_disallowed_streams_when_reading_events_forward_with_stream_id_regex()
        {
            var filter = new Filter(
                Filter.Types.FilterContext.StreamId,
                Filter.Types.FilterType.Regex, new[] { @"^.*istentsubsc.*$" });
            var eventFilter = EventFilter.Get(true, filter);

            var result = ReadIndex.ReadAllEventsForwardFiltered(_forwardReadPos, 10, 10, eventFilter);

            Assert.AreEqual(1, result.Records.Count);
            Assert.True(result.Records.All(x => x.Event.EventStreamId != _disallowedStream));
            Assert.True(result.Records.Any(x => x.Event.EventStreamId == _allowedStream2));
        }
        public void should_filter_out_disallowed_streams_when_reading_events_forward_with_stream_id_prefix()
        {
            var filter = new TcpClientMessageDto.Filter(
                FilterContext.StreamId,
                FilterType.Prefix, new[] { "$persistentsubscripti" });
            var eventFilter = EventFilter.Get(true, filter);

            var result = ReadIndex.ReadAllEventsForwardFiltered(_forwardReadPos, 10, 10, eventFilter);

            Assert.AreEqual(1, result.Records.Count);
            Assert.True(result.Records.All(x => x.Event.EventStreamId != _disallowedStream));
            Assert.True(result.Records.Any(x => x.Event.EventStreamId == _allowedStream2));
        }
        public void should_filter_out_disallowed_streams_when_reading_events_forward_with_event_type_prefix()
        {
            var filter = new Filter(
                Filter.Types.FilterContext.EventType,
                Filter.Types.FilterType.Prefix, new[] { "event-type" });
            var eventFilter = EventFilter.Get(true, filter);

            var result = ReadIndex.ReadAllEventsForwardFiltered(_forwardReadPos, 10, 10, eventFilter);

            Assert.AreEqual(2, result.Records.Count);
            Assert.True(result.Records.All(x => x.Event.EventStreamId != _disallowedStream));
            Assert.True(result.Records.Any(x => x.Event.EventStreamId == _allowedStream1));
            Assert.True(result.Records.Any(x => x.Event.EventStreamId == _allowedStream2));
        }
        public void should_filter_out_disallowed_streams_when_reading_events_backward_with_event_type_regex()
        {
            var filter = new TcpClientMessageDto.Filter(
                FilterContext.EventType,
                FilterType.Regex, new[] { @"^.*event-type.*$" });
            var eventFilter = EventFilter.Get(true, filter);

            var result = ReadIndex.ReadAllEventsBackwardFiltered(_backwardReadPos, 10, 10, eventFilter);

            Assert.AreEqual(2, result.Records.Count);
            Assert.True(result.Records.All(x => x.Event.EventStreamId != _disallowedStream));
            Assert.True(result.Records.Any(x => x.Event.EventStreamId == _allowedStream1));
            Assert.True(result.Records.Any(x => x.Event.EventStreamId == _allowedStream2));
        }
예제 #13
0
        public override void Start(Guid correlationId)
        {
            CorrelationId = correlationId;

            Publisher.PublishWithAuthentication(_authenticationProvider, _userCredentials,
                                                ex => DropSubscription(Core.Services.SubscriptionDropReason.AccessDenied, ex),
                                                user => new ClientMessage.FilteredSubscribeToStream(
                                                    correlationId,
                                                    correlationId,
                                                    new PublishEnvelope(Publisher, true),
                                                    ConnectionId,
                                                    StreamId,
                                                    _resolveLinkTos,
                                                    user,
                                                    EventFilter.Get(_filter),
                                                    _checkpointInterval));
        }
예제 #14
0
        private ClientMessage.FilteredSubscribeToStream UnwrapFilteredSubscribeToStream(TcpPackage package,
                                                                                        IEnvelope envelope,
                                                                                        ClaimsPrincipal user,
                                                                                        TcpConnectionManager connection)
        {
            var dto = package.Data.Deserialize <TcpClientMessageDto.FilteredSubscribeToStream>();

            if (dto == null)
            {
                return(null);
            }

            IEventFilter eventFilter = EventFilter.Get(dto.Filter);

            return(new ClientMessage.FilteredSubscribeToStream(Guid.NewGuid(), package.CorrelationId, envelope,
                                                               connection.ConnectionId, dto.EventStreamId, dto.ResolveLinkTos, user, eventFilter,
                                                               dto.CheckpointInterval));
        }
예제 #15
0
        private static ClientMessage.FilteredReadAllEventsForward UnwrapFilteredReadAllEventsForward(TcpPackage package,
                                                                                                     IEnvelope envelope, ClaimsPrincipal user)
        {
            var dto = package.Data.Deserialize <TcpClientMessageDto.FilteredReadAllEvents>();

            if (dto == null)
            {
                return(null);
            }

            IEventFilter eventFilter = EventFilter.Get(dto.Filter);

            int maxSearchWindow = dto.MaxCount;

            if (dto.MaxSearchWindow.HasValue)
            {
                maxSearchWindow = dto.MaxSearchWindow.GetValueOrDefault();
            }

            return(new ClientMessage.FilteredReadAllEventsForward(Guid.NewGuid(), package.CorrelationId, envelope,
                                                                  dto.CommitPosition, dto.PreparePosition, dto.MaxCount,
                                                                  dto.ResolveLinkTos, dto.RequireLeader, maxSearchWindow, null, eventFilter, user, null));
        }