Embedded store not picking up default user credentials

Hi,
I’m using the embedded event store in some unit tests but am having a problem with credentials. Even though I am calling SetDefaultUserCredentials (with admin/changeit) on the ConnectionSettingsBuilder i get an AccessDenied exception when trying to read from a by_category projection.

I am setting up the cluster as follows:

private static async Task StartEventStore()

{

var timeout = TimeSpan.FromSeconds(3);

var clusterVNode = EmbeddedVNodeBuilder.AsSingleNode()

.RunInMemory()

.RunProjections(ProjectionsMode.All)

.OnDefaultEndpoints()

.Build();

clusterVNode.MainQueue.Publish(new ProjectionManagementMessage.Command.Enable(

new NoopEnvelope(),

ProjectionNamesBuilder.StandardProjections.StreamsStandardProjection,

ProjectionManagementMessage.RunAs.System));

var startedEvent = new SemaphoreSlim(0, 1);

clusterVNode.MainBus.Subscribe(new AdHocHandler<SystemMessage.SystemStart>(m => startedEvent.Release()));

clusterVNode.Start();

if (!await startedEvent.WaitAsync(timeout))

throw new TimeoutException($“EventStore haven’t started in {timeout} seconds.”);

return clusterVNode;

}

``

and I create the connection using this code:

var csb = ConnectionSettings.Create()

.SetDefaultUserCredentials(new EventStore.ClientAPI.SystemData.UserCredentials(“admin”, “changeit”))

.KeepReconnecting();

var connection = EmbeddedEventStoreConnection.Create(cluster, csb);

``

When I run the code against a real running ES I do not get any problems. If I hardcode the credentials in the read operation it works.

This is the actual exception I’m seeing:

System.AggregateException: One or more errors occurred. —> EventStore.ClientAPI.Exceptions.AccessDeniedException: Read access denied for stream ‘$ce-deal’.

— End of inner exception stack trace —

at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)

at System.Threading.Tasks.Task`1.get_Result()

at EventStore.ClientAPI.EventStoreStreamCatchUpSubscription.ReadEventsTill(IEventStoreConnection connection, Boolean resolveLinkTos, UserCredentials userCredentials, Nullable1 lastCommitPosition, Nullable1 lastEventNumber)

at EventStore.ClientAPI.EventStoreCatchUpSubscription.b__33_0(Object _)

—> (Inner Exception #0) EventStore.ClientAPI.Exceptions.AccessDeniedException: Read access denied for stream ‘$ce-deal’.<—

Am I doing something wrong?

Thanks,

Cathal

Here’s a linqpad version of the problem: http://share.linqpad.net/9n596g.linq

Thanks for the reproduction. I am able to reproduce this side and will get back to you in a bit. For now, your work around would be to pass those credentials in with the subscription, which you say is working.

Thanks, yeah thats the workaround I’m using for now.