2023-11-29 00:18:08 +01:00
|
|
|
|
using Bit.Core.AdminConsole.Entities;
|
2023-08-22 01:55:39 +02:00
|
|
|
|
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)]
|
2023-11-01 13:43:35 +01:00
|
|
|
|
public Task UpdateSubscriptionAsync_WithNonSecretsManagerPlanType_ThrowsBadRequestException(
|
|
|
|
|
PlanType planType,
|
|
|
|
|
Organization organization)
|
|
|
|
|
{
|
|
|
|
|
// Arrange
|
|
|
|
|
organization.PlanType = planType;
|
|
|
|
|
|
|
|
|
|
// Act
|
|
|
|
|
var exception = Assert.Throws<NotFoundException>(() => new SecretsManagerSubscriptionUpdate(organization, false));
|
|
|
|
|
|
|
|
|
|
// Assert
|
|
|
|
|
Assert.Contains("Invalid Secrets Manager plan", exception.Message, StringComparison.InvariantCultureIgnoreCase);
|
|
|
|
|
return Task.CompletedTask;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Theory]
|
2023-08-22 01:55:39 +02:00
|
|
|
|
[BitAutoData(PlanType.EnterpriseMonthly2019)]
|
2023-11-01 13:43:35 +01:00
|
|
|
|
[BitAutoData(PlanType.EnterpriseMonthly2020)]
|
|
|
|
|
[BitAutoData(PlanType.EnterpriseMonthly)]
|
2023-08-22 01:55:39 +02:00
|
|
|
|
[BitAutoData(PlanType.EnterpriseAnnually2019)]
|
2023-11-01 13:43:35 +01:00
|
|
|
|
[BitAutoData(PlanType.EnterpriseAnnually2020)]
|
|
|
|
|
[BitAutoData(PlanType.EnterpriseAnnually)]
|
2023-08-22 01:55:39 +02:00
|
|
|
|
[BitAutoData(PlanType.TeamsMonthly2019)]
|
2023-11-01 13:43:35 +01:00
|
|
|
|
[BitAutoData(PlanType.TeamsMonthly2020)]
|
|
|
|
|
[BitAutoData(PlanType.TeamsMonthly)]
|
2023-08-22 01:55:39 +02:00
|
|
|
|
[BitAutoData(PlanType.TeamsAnnually2019)]
|
2023-11-01 13:43:35 +01:00
|
|
|
|
[BitAutoData(PlanType.TeamsAnnually2020)]
|
|
|
|
|
[BitAutoData(PlanType.TeamsAnnually)]
|
2023-11-03 23:26:47 +01:00
|
|
|
|
[BitAutoData(PlanType.TeamsStarter)]
|
2023-11-01 13:43:35 +01:00
|
|
|
|
public void UpdateSubscription_WithNonSecretsManagerPlanType_DoesNotThrowException(
|
2023-08-22 01:55:39 +02:00
|
|
|
|
PlanType planType,
|
|
|
|
|
Organization organization)
|
|
|
|
|
{
|
2023-11-01 13:43:35 +01:00
|
|
|
|
// Arrange
|
2023-08-22 01:55:39 +02:00
|
|
|
|
organization.PlanType = planType;
|
|
|
|
|
|
2023-11-01 13:43:35 +01:00
|
|
|
|
// Act
|
|
|
|
|
var ex = Record.Exception(() => new SecretsManagerSubscriptionUpdate(organization, false));
|
|
|
|
|
|
|
|
|
|
// Assert
|
|
|
|
|
Assert.Null(ex);
|
2023-08-22 01:55:39 +02:00
|
|
|
|
}
|
|
|
|
|
}
|