public void does_not_update_enabled() { _users.Handle(new UserManagementMessage.Get(Envelope, SystemAccounts.System, "user1")); _queue.Process(); var user = HandledMessages.OfType <UserManagementMessage.UserDetailsResult>().SingleOrDefault(); Assert.NotNull(user); Assert.AreEqual(false, user.Data.Disabled); }
public void updates_stream_metadata() { var writes = HandledMessages.OfType <ClientMessage.WriteEvents>() .OfEventType(SystemEventTypes.StreamMetadata) .ToArray(); Assert.AreEqual(1, writes.Length); }
public void publishes_projection_kill_message() { var command = HandledMessages.OfType <CoreProjectionManagementMessage.GetState>().LastOrDefault(); Assert.IsNotNull(command); Assert.AreEqual(_projectionId, command.ProjectionId); Assert.AreEqual(_correlationId, command.CorrelationId); Assert.AreEqual(_partition, command.Partition); }
public void user_account_is_not_enabled() { _users.Handle(new UserManagementMessage.Get(Envelope, SystemAccount.Principal, "user1")); _queue.Process(); var user = HandledMessages.OfType <UserManagementMessage.UserDetailsResult>().SingleOrDefault(); Assert.NotNull(user); Assert.AreEqual(true, user.Data.Disabled); }
protected ClientMessage.WriteEvents[] HandledPasswordChangedNotificationWrites() { return(HandledMessages.OfType <ClientMessage.WriteEvents>() .Where( v => v.EventStreamId == Core.Services.UserManagement.UserManagementService .UserPasswordNotificationsStreamId).ToArray()); }
public void events_after_first_event_should_be_in_sequence() { Assert.Throws <InvalidOperationException>(() => { //_fromSequenceNumber+2 has been omitted HandleEvents(new long[] { _fromSequenceNumber, _fromSequenceNumber + 1, _fromSequenceNumber + 3, _fromSequenceNumber + 4 }); }); Assert.AreEqual(1, HandledMessages.OfType <ReaderSubscriptionMessage.Faulted>().Count()); }
public void publishes_all_events_from_the_stream() { var events = HandledMessages.OfType <EventReaderSubscriptionMessage.CommittedEventReceived>().ToArray(); Assert.AreEqual(4, events.Length); Assert.That( events.Select(v => v.Data.PositionStreamId) .SequenceEqual(new[] { "test-stream", "test-stream", "test-stream2", "test-stream2" })); }
public void publishes_eof_message() { var lastEvent = HandledMessages.OfType <EventReaderSubscriptionMessage>() .LastOrDefault(v => !(v is EventReaderSubscriptionMessage.ReaderAssignedReader)); Assert.IsNotNull(lastEvent); Assert.IsAssignableFrom <EventReaderSubscriptionMessage.EofReached>(lastEvent); }
public void publishes_partition_eof_message_at_the_end() { var events = HandledMessages.OfType <EventReaderSubscriptionMessage>(); var lastEvent = events.LastOrDefault(); Assert.IsNotNull(lastEvent); Assert.IsAssignableFrom <EventReaderSubscriptionMessage.PartitionEofReached>(lastEvent); }
public void events_after_first_event_should_not_be_in_sequence() { //_fromSequenceNumber+2 has been omitted HandleEvents(_streamNames[0], new long[] { _fromSequenceNumber, _fromSequenceNumber + 1, _fromSequenceNumber + 3, _fromSequenceNumber + 4 }); //to trigger event delivery: HandleEvents(_streamNames[1], 100, 101); Assert.AreEqual(2, HandledMessages.OfType <ReaderSubscriptionMessage.Faulted>().Count()); }
public void does_not_issue_a_new_read() { _commandReader.Handle(new ProjectionManagementMessage.Internal.ReadTimeout(_readStreamEventsCorrelationId, _projectionsMasterStream)); var response = HandledMessages.OfType <ClientMessage.ReadStreamEventsForward>().Last(x => x.EventStreamId == _projectionsMasterStream); Assert.IsNotNull(response); Assert.AreEqual(_readStreamEventsCorrelationId, response.CorrelationId); }
public void publishes_partition_result_message() { var results = HandledMessages.OfType<PartitionProcessingResultOutput>().ToArray(); Assert.AreEqual(3, results.Length); Assert.AreEqual("{\"data\":1}", results[0].Result); Assert.AreEqual("{\"data\":2}", results[1].Result); Assert.IsNull(results[2].Result); }
public void publishes_faulted_message() { var response = HandledMessages.OfType <CoreProjectionStatusMessage.Faulted>().LastOrDefault(); Assert.IsNotNull(response); Assert.AreEqual(_projectionId, response.ProjectionId); Assert.AreEqual("reason", response.FaultedReason); }
public void should_not_allow_first_event_to_be_greater_than_sequence_number() { long eventSequenceNumber = _fromSequenceNumber + 5; Assert.Throws <InvalidOperationException>(() => { HandleEvents(eventSequenceNumber, eventSequenceNumber); }); Assert.AreEqual(1, HandledMessages.OfType <ReaderSubscriptionMessage.Faulted>().Count()); }
public void should_not_allow_first_event_to_be_less_than_sequence_number() { long eventSequenceNumber = _fromSequenceNumber - 1; HandleEvents(_streamNames[0], eventSequenceNumber, eventSequenceNumber); //to trigger event delivery: HandleEvents(_streamNames[1], 100, 101); Assert.AreEqual(1, HandledMessages.OfType <ReaderSubscriptionMessage.Faulted>().Count()); }
public void anonymous_cannot_retrieve_projection_query() { GetInputQueue() .Publish( new ProjectionManagementMessage.Command.GetQuery( Envelope, _projectionName, ProjectionManagementMessage.RunAs.Anonymous)); _queue.Process(); Assert.IsTrue(HandledMessages.OfType <ProjectionManagementMessage.NotAuthorized>().Any()); }
public void truncates_existing_stream_at_correct_position() { var writes = HandledMessages.OfType <ClientMessage.WriteEvents>() .OfEventType(SystemEventTypes.StreamMetadata) .ToArray(); Assert.AreEqual(1, writes.Length); HelperExtensions.AssertJson(new { ___tb = 2 }, writes[0].Data.ParseJson <JObject>()); }
public void does_not_create_a_user_account() { _users.Handle(new UserManagementMessage.Get(Envelope, SystemAccounts.System, "user1")); _queue.Process(); var user = HandledMessages.OfType <UserManagementMessage.UserDetailsResult>().SingleOrDefault(); Assert.NotNull(user); Assert.IsFalse(user.Success); Assert.AreEqual(UserManagementMessage.Error.NotFound, user.Error); }
public void publishes_partition_result_message() { var results = HandledMessages.OfType <PartitionProcessingResultOutput>().ToArray(); Assert.AreEqual(1, results.Length); var result = results[0]; Assert.IsNull(result.Result); }
public void publishes_partition_eof_message_at_the_end_of_each_stream() { var events = HandledMessages .OfTypes <EventReaderSubscriptionMessageBase, EventReaderSubscriptionMessage.PartitionEofReached, EventReaderSubscriptionMessage.CommittedEventReceived>().ToArray(); Assert.IsAssignableFrom <EventReaderSubscriptionMessage.PartitionEofReached>(events[2]); Assert.IsAssignableFrom <EventReaderSubscriptionMessage.PartitionEofReached>(events[5]); }
public void does_not_update_details() { _users.Handle(new UserManagementMessage.Get(Envelope, SystemAccount.Principal, "user1")); _queue.Process(); var user = HandledMessages.OfType <UserManagementMessage.UserDetailsResult>().SingleOrDefault(); Assert.NotNull(user); Assert.AreEqual("John Doe", user.Data.FullName); Assert.AreEqual("user1", user.Data.LoginName); Assert.AreEqual(false, user.Data.Disabled); }
public void publishesspool_stream_reading_message() { var spoolStreamReading = HandledMessages.OfType <ReaderSubscriptionManagement.SpoolStreamReadingCore>().LastOrDefault(); Assert.IsNotNull(spoolStreamReading); Assert.AreEqual(Guid.ParseExact("4fb6aa53932045ce891752441a0fde5c", "N"), spoolStreamReading.SubscriptionId); Assert.AreEqual("streamId", spoolStreamReading.StreamId); Assert.AreEqual(100, spoolStreamReading.CatalogSequenceNumber); Assert.AreEqual(123456789123456789, spoolStreamReading.LimitingCommitPosition); }
public void changes_password() { HandledMessages.Clear(); _users.Handle( new UserManagementMessage.ChangePassword( Envelope, SystemAccounts.System, "user1", "new-password", "other-password")); _queue.Process(); var updateResult = HandledMessages.OfType <UserManagementMessage.UpdateResult>().Last(); Assert.NotNull(updateResult); Assert.IsTrue(updateResult.Success); }
protected ClientMessage.WriteEvents[] HandledPasswordChangedNotificationMetaStreamWrites() { return (HandledMessages.OfType <ClientMessage.WriteEvents>() .Where( v => v.EventStreamId == SystemStreams.MetastreamOf( Core.Authentication.InternalAuthentication.UserManagementService .UserPasswordNotificationsStreamId)) .ToArray()); }
public void creates_an_enabled_user_account_with_the_correct_password() { HandledMessages.Clear(); _users.Handle( new UserManagementMessage.ChangePassword( Envelope, SystemAccounts.System, "user1", "Johny123!", "new-password")); _queue.Process(); var updateResult = HandledMessages.OfType <UserManagementMessage.UpdateResult>().Last(); Assert.NotNull(updateResult); Assert.IsTrue(updateResult.Success); }
public void publishes_result_report_message() { var response = HandledMessages.OfType <CoreProjectionStatusMessage.ResultReport>().LastOrDefault(); Assert.IsNotNull(response); Assert.AreEqual(_projectionId, response.ProjectionId); Assert.AreEqual(_correlationId, response.CorrelationId); Assert.AreEqual(_partition, response.Partition); Assert.AreEqual(_result, response.Result); Assert.AreEqual(_position, response.Position); }
public void sends_committed_event_received_messages_in_correct_order() { var messages = HandledMessages.OfType <EventReaderSubscriptionMessage.CommittedEventReceived>().ToList(); Assert.AreEqual(2, messages.Count); var message1 = messages[0]; var message2 = messages[1]; Assert.AreEqual(_tag1, message1.CheckpointTag); Assert.AreEqual(_tag2, message2.CheckpointTag); }
public void does_not_override_user_password() { HandledMessages.Clear(); _users.Handle( new UserManagementMessage.ChangePassword( Envelope, SystemAccount.Principal, "user1", "existing!", "new-password")); _queue.Process(); var updateResult = HandledMessages.OfType <UserManagementMessage.UpdateResult>().Last(); Assert.NotNull(updateResult); Assert.IsTrue(updateResult.Success); }
public void projection_owner_can_retrieve_projection_query() { GetInputQueue() .Publish( new ProjectionManagementMessage.Command.GetQuery( Envelope, _projectionName, new ProjectionManagementMessage.RunAs(_testUserPrincipal))); _queue.Process(); var query = HandledMessages.OfType <ProjectionManagementMessage.ProjectionQuery>().FirstOrDefault(); Assert.NotNull(query); Assert.AreEqual(_projectionBody, query.Query); }
public void reported_state_is_before_the_fault_position() { var states = HandledMessages.OfType <ProjectionManagementMessage.ProjectionState>().ToArray(); Assert.AreEqual(1, states.Length); var state = states[0]; Assert.That(state.Position.Streams.Count == 1); Assert.That(state.Position.Streams.Keys.First() == "message1"); Assert.That(state.Position.Streams["message1"] == -1); Assert.That( state.Position.Position <= _message1Position, "{0} <= {1}", state.Position.Position, _message1Position); }