mirror of
https://github.com/bitwarden/server.git
synced 2024-11-25 12:45:18 +01:00
[AC-1568] Refactor UpdateSecretsManagerSubscriptionCommandTests to use new ctor (#3210)
This commit is contained in:
parent
f9452e7b77
commit
c5b5225642
@ -20,11 +20,11 @@ public class OrganizationCustomization : ICustomization
|
|||||||
public void Customize(IFixture fixture)
|
public void Customize(IFixture fixture)
|
||||||
{
|
{
|
||||||
var organizationId = Guid.NewGuid();
|
var organizationId = Guid.NewGuid();
|
||||||
var maxConnections = (short)new Random().Next(10, short.MaxValue);
|
var maxCollections = (short)new Random().Next(10, short.MaxValue);
|
||||||
|
|
||||||
fixture.Customize<Organization>(composer => composer
|
fixture.Customize<Organization>(composer => composer
|
||||||
.With(o => o.Id, organizationId)
|
.With(o => o.Id, organizationId)
|
||||||
.With(o => o.MaxCollections, maxConnections)
|
.With(o => o.MaxCollections, maxCollections)
|
||||||
.With(o => o.UseGroups, UseGroups));
|
.With(o => o.UseGroups, UseGroups));
|
||||||
|
|
||||||
fixture.Customize<Collection>(composer =>
|
fixture.Customize<Collection>(composer =>
|
||||||
@ -127,6 +127,24 @@ internal class OrganizationInvite : ICustomization
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class SecretsManagerOrganizationCustomization : ICustomization
|
||||||
|
{
|
||||||
|
public void Customize(IFixture fixture)
|
||||||
|
{
|
||||||
|
var organizationId = Guid.NewGuid();
|
||||||
|
var planType = PlanType.EnterpriseAnnually;
|
||||||
|
|
||||||
|
fixture.Customize<Organization>(composer => composer
|
||||||
|
.With(o => o.Id, organizationId)
|
||||||
|
.With(o => o.UseSecretsManager, true)
|
||||||
|
.With(o => o.PlanType, planType)
|
||||||
|
.With(o => o.Plan, StaticStore.GetPasswordManagerPlan(planType).Name)
|
||||||
|
.With(o => o.MaxAutoscaleSmSeats, (int?)null)
|
||||||
|
.With(o => o.MaxAutoscaleSmServiceAccounts, (int?)null)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
internal class OrganizationCustomizeAttribute : BitCustomizeAttribute
|
internal class OrganizationCustomizeAttribute : BitCustomizeAttribute
|
||||||
{
|
{
|
||||||
public bool UseGroups { get; set; }
|
public bool UseGroups { get; set; }
|
||||||
@ -162,3 +180,9 @@ internal class OrganizationInviteCustomizeAttribute : BitCustomizeAttribute
|
|||||||
PermissionsBlob = PermissionsBlob,
|
PermissionsBlob = PermissionsBlob,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal class SecretsManagerOrganizationCustomizeAttribute : BitCustomizeAttribute
|
||||||
|
{
|
||||||
|
public override ICustomization GetCustomization() =>
|
||||||
|
new SecretsManagerOrganizationCustomization();
|
||||||
|
}
|
||||||
|
@ -0,0 +1,31 @@
|
|||||||
|
using Bit.Core.Entities;
|
||||||
|
using Bit.Core.Enums;
|
||||||
|
using Bit.Core.Exceptions;
|
||||||
|
using Bit.Core.Models.Business;
|
||||||
|
using Bit.Core.Test.AutoFixture.OrganizationFixtures;
|
||||||
|
using Bit.Test.Common.AutoFixture.Attributes;
|
||||||
|
using Xunit;
|
||||||
|
|
||||||
|
namespace Bit.Core.Test.Models.Business;
|
||||||
|
|
||||||
|
[SecretsManagerOrganizationCustomize]
|
||||||
|
public class SecretsManagerSubscriptionUpdateTests
|
||||||
|
{
|
||||||
|
[Theory]
|
||||||
|
[BitAutoData(PlanType.Custom)]
|
||||||
|
[BitAutoData(PlanType.FamiliesAnnually)]
|
||||||
|
[BitAutoData(PlanType.FamiliesAnnually2019)]
|
||||||
|
[BitAutoData(PlanType.EnterpriseMonthly2019)]
|
||||||
|
[BitAutoData(PlanType.EnterpriseAnnually2019)]
|
||||||
|
[BitAutoData(PlanType.TeamsMonthly2019)]
|
||||||
|
[BitAutoData(PlanType.TeamsAnnually2019)]
|
||||||
|
public async Task UpdateSubscriptionAsync_WithNonSecretsManagerPlanType_ThrowsBadRequestException(
|
||||||
|
PlanType planType,
|
||||||
|
Organization organization)
|
||||||
|
{
|
||||||
|
organization.PlanType = planType;
|
||||||
|
|
||||||
|
var exception = Assert.Throws<NotFoundException>(() => new SecretsManagerSubscriptionUpdate(organization, false));
|
||||||
|
Assert.Contains("Invalid Secrets Manager plan", exception.Message, StringComparison.InvariantCultureIgnoreCase);
|
||||||
|
}
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user