mirror of
https://github.com/bitwarden/server.git
synced 2025-06-30 07:36:14 -05:00
[AC-292] Public Api - allow configuration of custom permissions (#4022)
* Also refactor OrganizationService user invite methods
This commit is contained in:
@ -61,4 +61,23 @@ public class IdentityApplicationFactory : WebApplicationFactoryBase<Startup>
|
||||
|
||||
return root.GetProperty("access_token").GetString();
|
||||
}
|
||||
|
||||
public async Task<string> TokenFromOrganizationApiKeyAsync(string clientId, string clientSecret,
|
||||
DeviceType deviceType = DeviceType.FirefoxBrowser)
|
||||
{
|
||||
var context = await Server.PostAsync("/connect/token",
|
||||
new FormUrlEncodedContent(new Dictionary<string, string>
|
||||
{
|
||||
{ "scope", "api.organization" },
|
||||
{ "client_id", clientId },
|
||||
{ "client_secret", clientSecret },
|
||||
{ "grant_type", "client_credentials" },
|
||||
{ "deviceType", ((int)deviceType).ToString() }
|
||||
}));
|
||||
|
||||
using var body = await AssertHelper.AssertResponseTypeIs<JsonDocument>(context);
|
||||
var root = body.RootElement;
|
||||
|
||||
return root.GetProperty("access_token").GetString();
|
||||
}
|
||||
}
|
||||
|
@ -166,6 +166,11 @@ public abstract class WebApplicationFactoryBase<T> : WebApplicationFactory<T>
|
||||
|
||||
// Disable logs
|
||||
services.AddSingleton<ILoggerFactory, NullLoggerFactory>();
|
||||
|
||||
// Noop StripePaymentService - this could be changed to integrate with our Stripe test account
|
||||
var stripePaymentService = services.First(sd => sd.ServiceType == typeof(IPaymentService));
|
||||
services.Remove(stripePaymentService);
|
||||
services.AddSingleton(Substitute.For<IPaymentService>());
|
||||
});
|
||||
|
||||
foreach (var configureTestService in _configureTestServices)
|
||||
|
Reference in New Issue
Block a user