protected override void When() { _conn.SetStreamMetadataAsync( "$all", ExpectedVersion.Any, StreamMetadata.Build().SetReadRole(SystemRoles.All), new UserCredentials(SystemUsers.Admin, SystemUsers.DefaultAdminPassword)) .Wait(); _testEvents = Enumerable.Range(0, 20).Select(x => TestEvent.NewTestEvent(x.ToString())).ToArray(); _stream = "read_stream_events_with_unresolved_linkto"; _conn.AppendToStreamAsync(_stream, ExpectedVersion.EmptyStream, _testEvents).Wait(); _links = "read_stream_events_with_unresolved_linkto_links"; _conn.AppendToStreamAsync( _links, ExpectedVersion.EmptyStream, new EventData( Guid.NewGuid(), EventStore.ClientAPI.Common.SystemEventTypes.LinkTo, false, Encoding.UTF8.GetBytes("0@read_stream_events_with_unresolved_linkto"), null)) .Wait(); _conn.DeleteStreamAsync(_stream, ExpectedVersion.Any).Wait(); }
protected override async Task When() { await _conn.SetStreamMetadataAsync("$all", -1, StreamMetadata.Build().SetReadRole(SystemRoles.All), DefaultData.AdminCredentials); _testEvents = Enumerable .Range(0, 10) .Select(x => TestEvent.NewTestEvent(x.ToString(), eventName: "AEvent")) .ToList(); _testEvents.AddRange( Enumerable .Range(0, 10) .Select(x => TestEvent.NewTestEvent(x.ToString(), eventName: "BEvent")).ToList()); await _conn.AppendToStreamAsync("stream-a", ExpectedVersion.NoStream, _testEvents.EvenEvents()); await _conn.AppendToStreamAsync("stream-b", ExpectedVersion.NoStream, _testEvents.OddEvents()); }
public void setting_structured_metadata_with_multiple_roles_can_be_read_back() { StreamMetadata metadata = StreamMetadata.Build() .SetReadRoles(new [] { "r1", "r2", "r3" }) .SetWriteRoles(new[] { "w1", "w2" }) .SetDeleteRoles(new[] { "d1", "d2", "d3", "d4" }) .SetMetadataWriteRoles(new[] { "mw1", "mw2" }); _connection.SetStreamMetadataAsync(_stream, ExpectedVersion.EmptyStream, metadata).Wait(); var meta = _connection.GetStreamMetadataAsync(_stream).Result; Assert.AreEqual(_stream, meta.Stream); Assert.AreEqual(false, meta.IsStreamDeleted); Assert.AreEqual(0, meta.MetastreamVersion); Assert.NotNull(meta.StreamMetadata.Acl); Assert.AreEqual(new[] { "r1", "r2", "r3" }, meta.StreamMetadata.Acl.ReadRoles); Assert.AreEqual(new[] { "w1", "w2" }, meta.StreamMetadata.Acl.WriteRoles); Assert.AreEqual(new[] { "d1", "d2", "d3", "d4" }, meta.StreamMetadata.Acl.DeleteRoles); Assert.AreEqual(new[] { "mw1", "mw2" }, meta.StreamMetadata.Acl.MetaWriteRoles); }
public async Task returns_expected_result(long expectedVersion, string displayName, bool createStream, StreamMetadataBuilder builder) { var isEmpty = builder == null; var streamName = $"{GetStreamName()}_{displayName}_{createStream}_{isEmpty}"; var connection = _fixture.Connection; if (createStream) { await connection.AppendToStreamAsync(streamName, ExpectedVersion.NoStream, _fixture.CreateTestEvents()) .WithTimeout(); } var expected = (builder ?? StreamMetadata.Build()).Build(); await connection.SetStreamMetadataAsync(streamName, expectedVersion, expected).WithTimeout(); var result = await connection.GetStreamMetadataAsync(streamName).WithTimeout(); var actual = result.StreamMetadata; Assert.Equal(streamName, result.Stream); Assert.False(result.IsStreamDeleted); Assert.Equal(0, result.MetastreamVersion); Assert.Equal(expected.MaxCount, actual.MaxCount); Assert.Equal(expected.MaxAge, actual.MaxAge); Assert.Equal(expected.TruncateBefore, actual.TruncateBefore); Assert.Equal(expected.CacheControl, actual.CacheControl); Assert.Equal(expected.Acl?.ReadRoles, actual.Acl?.ReadRoles); Assert.Equal(expected.Acl?.WriteRoles, actual.Acl?.WriteRoles); Assert.Equal(expected.Acl?.DeleteRoles, actual.Acl?.DeleteRoles); Assert.Equal(expected.Acl?.MetaReadRoles, actual.Acl?.MetaReadRoles); Assert.Equal(expected.Acl?.MetaWriteRoles, actual.Acl?.MetaWriteRoles); Assert.Equal(expected.CustomKeys.Count(), actual.CustomKeys.Count()); foreach (var key in actual.CustomKeys) { Assert.True(expected.TryGetValueAsRawJsonString(key, out var value)); Assert.Equal(actual.GetValueAsRawJsonString(key), value); } }
public async Task setting_structured_metadata_with_multiple_roles_can_be_read_back() { const string stream = "setting_structured_metadata_with_multiple_roles_can_be_read_back"; StreamMetadata metadata = StreamMetadata.Build() .SetReadRoles(new[] { "r1", "r2", "r3" }) .SetWriteRoles(new[] { "w1", "w2" }) .SetDeleteRoles(new[] { "d1", "d2", "d3", "d4" }) .SetMetadataWriteRoles(new[] { "mw1", "mw2" }); await _connection.SetStreamMetadataAsync(stream, ExpectedVersion.NoStream, metadata); var meta = await _connection.GetStreamMetadataAsync(stream); Assert.AreEqual(stream, meta.Stream); Assert.AreEqual(false, meta.IsStreamDeleted); Assert.AreEqual(0, meta.MetastreamVersion); Assert.NotNull(meta.StreamMetadata.Acl); Assert.AreEqual(new[] { "r1", "r2", "r3" }, meta.StreamMetadata.Acl.ReadRoles); Assert.AreEqual(new[] { "w1", "w2" }, meta.StreamMetadata.Acl.WriteRoles); Assert.AreEqual(new[] { "d1", "d2", "d3", "d4" }, meta.StreamMetadata.Acl.DeleteRoles); Assert.AreEqual(new[] { "mw1", "mw2" }, meta.StreamMetadata.Acl.MetaWriteRoles); }
public async Task that_does_not_exist_with_expected_version_succeeds(long expectedVersion, string displayName) { var streamName = $"{GetStreamName()}_{displayName}"; await _fixture.Connection.SetStreamMetadataAsync(streamName, ExpectedVersion.Any, StreamMetadata.Build() .SetTruncateBefore(long.MaxValue)); await _fixture.Connection.DeleteStreamAsync(streamName, expectedVersion).WithTimeout(); }