mirror of
https://github.com/bitwarden/server.git
synced 2025-05-13 07:32:17 -05:00
Refactor error handling in ProviderClientOrganizationSignUpCommand to use constants for error messages
This commit is contained in:
parent
b62e97f601
commit
bec9c555c6
@ -31,6 +31,10 @@ public interface IProviderClientOrganizationSignUpCommand
|
|||||||
|
|
||||||
public class ProviderClientOrganizationSignUpCommand : IProviderClientOrganizationSignUpCommand
|
public class ProviderClientOrganizationSignUpCommand : IProviderClientOrganizationSignUpCommand
|
||||||
{
|
{
|
||||||
|
public const string PlanNullErrorMessage = "Password Manager Plan was null.";
|
||||||
|
public const string PlanDisabledErrorMessage = "Password Manager Plan is disabled.";
|
||||||
|
public const string AdditionalSeatsNegativeErrorMessage = "You can't subtract Password Manager seats!";
|
||||||
|
|
||||||
private readonly ICurrentContext _currentContext;
|
private readonly ICurrentContext _currentContext;
|
||||||
private readonly IPricingClient _pricingClient;
|
private readonly IPricingClient _pricingClient;
|
||||||
private readonly IReferenceEventService _referenceEventService;
|
private readonly IReferenceEventService _referenceEventService;
|
||||||
@ -120,17 +124,17 @@ public class ProviderClientOrganizationSignUpCommand : IProviderClientOrganizati
|
|||||||
{
|
{
|
||||||
if (plan is null)
|
if (plan is null)
|
||||||
{
|
{
|
||||||
throw new BadRequestException("Password Manager Plan was null.");
|
throw new BadRequestException(PlanNullErrorMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plan.Disabled)
|
if (plan.Disabled)
|
||||||
{
|
{
|
||||||
throw new BadRequestException("Password Manager Plan is disabled.");
|
throw new BadRequestException(PlanDisabledErrorMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (additionalSeats < 0)
|
if (additionalSeats < 0)
|
||||||
{
|
{
|
||||||
throw new BadRequestException("You can't subtract Password Manager seats!");
|
throw new BadRequestException(AdditionalSeatsNegativeErrorMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,7 +114,7 @@ public class ProviderClientOrganizationSignUpCommandTests
|
|||||||
var exception = await Assert.ThrowsAsync<BadRequestException>(
|
var exception = await Assert.ThrowsAsync<BadRequestException>(
|
||||||
() => sutProvider.Sut.SignUpClientOrganizationAsync(signup));
|
() => sutProvider.Sut.SignUpClientOrganizationAsync(signup));
|
||||||
|
|
||||||
Assert.Contains("Password Manager Plan was null", exception.Message);
|
Assert.Contains(ProviderClientOrganizationSignUpCommand.PlanNullErrorMessage, exception.Message);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Theory]
|
[Theory]
|
||||||
@ -134,7 +134,7 @@ public class ProviderClientOrganizationSignUpCommandTests
|
|||||||
var exception = await Assert.ThrowsAsync<BadRequestException>(
|
var exception = await Assert.ThrowsAsync<BadRequestException>(
|
||||||
() => sutProvider.Sut.SignUpClientOrganizationAsync(signup));
|
() => sutProvider.Sut.SignUpClientOrganizationAsync(signup));
|
||||||
|
|
||||||
Assert.Contains("You can't subtract Password Manager seats", exception.Message);
|
Assert.Contains(ProviderClientOrganizationSignUpCommand.AdditionalSeatsNegativeErrorMessage, exception.Message);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Theory]
|
[Theory]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user