mirror of
https://github.com/bitwarden/server.git
synced 2025-06-30 07:36:14 -05:00
[BEEEP][SM-893] Add the ability to run SM integration tests as a service account (#3187)
* Add the ability to run SM integration tests as a service account
This commit is contained in:
@ -42,4 +42,23 @@ public class IdentityApplicationFactory : WebApplicationFactoryBase<Startup>
|
||||
|
||||
return (root.GetProperty("access_token").GetString(), root.GetProperty("refresh_token").GetString());
|
||||
}
|
||||
|
||||
public async Task<string> TokenFromAccessTokenAsync(Guid clientId, string clientSecret,
|
||||
DeviceType deviceType = DeviceType.SDK)
|
||||
{
|
||||
var context = await Server.PostAsync("/connect/token",
|
||||
new FormUrlEncodedContent(new Dictionary<string, string>
|
||||
{
|
||||
{ "scope", "api.secrets" },
|
||||
{ "client_id", clientId.ToString() },
|
||||
{ "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();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user