Last active
October 29, 2015 11:06
-
-
Save heemskerkerik/f03f96e384933e3f5123 to your computer and use it in GitHub Desktop.
RavenDB test: Batch-loading when using read-only API key authentication
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Linq; | |
using Raven.Abstractions.Data; | |
using Raven.Client.Document; | |
using Raven.Database.Config; | |
using Raven.Tests.Helpers; | |
using Xunit; | |
// ReSharper disable InconsistentNaming | |
namespace Raven.ReadOnlyBatchLoadFailure | |
{ | |
public class OAuthReadOnlyAuthenticationBatchLoadTest: RavenTestBase | |
{ | |
[Fact] | |
public void OAuthReadOnlyAccess_BatchLoadSucceeds() | |
{ | |
using (var server = GetNewServer(configureConfig: ConfigureOptions, enableAuthentication: true)) | |
{ | |
using (var store = NewRemoteDocumentStore(ravenDbServer: server, fiddler: true)) | |
{ | |
using (var session = store.OpenSession("<system>")) | |
{ | |
session.Store(new ApiKeyDefinition | |
{ | |
Id = "Raven/ApiKeys/Test", | |
Name = "Test", | |
Secret = "gFjepjuccNJu7vq6hnQyv4lNBUXpdLpC", | |
Enabled = true, | |
Databases = | |
{ | |
new ResourceAccess | |
{ | |
TenantId = "OAuthReadOnlyAccess_BatchLoadSucceeds", | |
Admin = false, | |
ReadOnly = true, | |
}, | |
}, | |
}); | |
session.SaveChanges(); | |
} | |
using (var apiKeyStore = NewRemoteDocumentStore(ravenDbServer: server, fiddler: true, configureStore: ConfigureDocumentStore)) | |
{ | |
using (var session = apiKeyStore.OpenSession()) | |
{ | |
session.Load<object>(Enumerable.Range(1, 100).Select(i => "Documents/" + i)); | |
} | |
} | |
} | |
} | |
} | |
private void ConfigureOptions(InMemoryRavenConfiguration config) | |
{ | |
config.Settings["Raven/Licensing/AllowAdminAnonymousAccessForCommercialUse"] = "true"; | |
// valid license required because API key authentication is used. not included for obvious purposes. | |
config.Settings["Raven/License"] = @""; | |
} | |
private void ConfigureDocumentStore(DocumentStore store) | |
{ | |
store.ApiKey = "Test/gFjepjuccNJu7vq6hnQyv4lNBUXpdLpC"; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment