mirror of
https://github.com/bitwarden/server.git
synced 2025-07-03 09:02:48 -05:00
Revert "Merge branch 'main' into ac/ac-1682/ef-migrations"
This reverts commitf98646a722
, reversing changes made to7dfd2821f1
.
This commit is contained in:
@ -0,0 +1,74 @@
|
||||
using Bit.Api.IntegrationTest.Factories;
|
||||
using Bit.Api.IntegrationTest.Helpers;
|
||||
using Bit.Core.AdminConsole.Entities;
|
||||
using Bit.Core.Entities;
|
||||
using Bit.Core.Enums;
|
||||
using Bit.Core.Repositories;
|
||||
|
||||
namespace Bit.Api.IntegrationTest.SecretsManager;
|
||||
|
||||
public class SecretsManagerOrganizationHelper
|
||||
{
|
||||
private readonly ApiApplicationFactory _factory;
|
||||
private readonly string _ownerEmail;
|
||||
private readonly IOrganizationRepository _organizationRepository;
|
||||
private readonly IOrganizationUserRepository _organizationUserRepository;
|
||||
|
||||
public Organization _organization = null!;
|
||||
public OrganizationUser _owner = null!;
|
||||
|
||||
public SecretsManagerOrganizationHelper(ApiApplicationFactory factory, string ownerEmail)
|
||||
{
|
||||
_factory = factory;
|
||||
_organizationRepository = factory.GetService<IOrganizationRepository>();
|
||||
_organizationUserRepository = factory.GetService<IOrganizationUserRepository>();
|
||||
|
||||
_ownerEmail = ownerEmail;
|
||||
}
|
||||
|
||||
public async Task<(Organization organization, OrganizationUser owner)> Initialize(bool useSecrets, bool ownerAccessSecrets, bool organizationEnabled)
|
||||
{
|
||||
(_organization, _owner) = await OrganizationTestHelpers.SignUpAsync(_factory, ownerEmail: _ownerEmail, billingEmail: _ownerEmail);
|
||||
|
||||
if (useSecrets || !organizationEnabled)
|
||||
{
|
||||
if (useSecrets)
|
||||
{
|
||||
_organization.UseSecretsManager = true;
|
||||
}
|
||||
|
||||
if (!organizationEnabled)
|
||||
{
|
||||
_organization.Enabled = false;
|
||||
}
|
||||
|
||||
await _organizationRepository.ReplaceAsync(_organization);
|
||||
}
|
||||
|
||||
if (ownerAccessSecrets)
|
||||
{
|
||||
_owner.AccessSecretsManager = ownerAccessSecrets;
|
||||
await _organizationUserRepository.ReplaceAsync(_owner);
|
||||
}
|
||||
|
||||
return (_organization, _owner);
|
||||
}
|
||||
|
||||
public async Task<Organization> CreateSmOrganizationAsync()
|
||||
{
|
||||
var email = $"integration-test{Guid.NewGuid()}@bitwarden.com";
|
||||
await _factory.LoginWithNewAccount(email);
|
||||
var (organization, owner) =
|
||||
await OrganizationTestHelpers.SignUpAsync(_factory, ownerEmail: email, billingEmail: email);
|
||||
return organization;
|
||||
}
|
||||
|
||||
public async Task<(string email, OrganizationUser orgUser)> CreateNewUser(OrganizationUserType userType, bool accessSecrets)
|
||||
{
|
||||
var email = $"integration-test{Guid.NewGuid()}@bitwarden.com";
|
||||
await _factory.LoginWithNewAccount(email);
|
||||
var orgUser = await OrganizationTestHelpers.CreateUserAsync(_factory, _organization.Id, email, userType, accessSecrets);
|
||||
|
||||
return (email, orgUser);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user