mirror of
https://github.com/bitwarden/server.git
synced 2025-06-30 15:42:48 -05:00
Check canScale when scaling for sso (#1661)
* Check canScale when scaling for sso * PR review Use AutoAddSeats to add seats in a consistent way. This requires moving user check out of that method. * User logic moved out of method
This commit is contained in:
@ -868,7 +868,7 @@ namespace Bit.Core.Test.Services
|
||||
organization.MaxAutoscaleSeats = maxAutoscaleSeats;
|
||||
sutProvider.GetDependency<ICurrentContext>().ManageUsers(organization.Id).Returns(true);
|
||||
|
||||
var (result, failureMessage) = await sutProvider.Sut.CanScaleAsync(organization, seatsToAdd);
|
||||
var (result, failureMessage) = sutProvider.Sut.CanScale(organization, seatsToAdd);
|
||||
|
||||
if (expectedFailureMessage == string.Empty)
|
||||
{
|
||||
@ -886,23 +886,10 @@ namespace Bit.Core.Test.Services
|
||||
SutProvider<OrganizationService> sutProvider)
|
||||
{
|
||||
sutProvider.GetDependency<IGlobalSettings>().SelfHosted.Returns(true);
|
||||
var (result, failureMessage) = await sutProvider.Sut.CanScaleAsync(organization, 10);
|
||||
var (result, failureMessage) = sutProvider.Sut.CanScale(organization, 10);
|
||||
|
||||
Assert.False(result);
|
||||
Assert.Contains("Cannot autoscale on self-hosted instance", failureMessage);
|
||||
}
|
||||
|
||||
[Theory, PaidOrganizationAutoData]
|
||||
public async Task CanScale_FailsIfCannotManageUsers(Organization organization,
|
||||
SutProvider<OrganizationService> sutProvider)
|
||||
{
|
||||
organization.MaxAutoscaleSeats = null;
|
||||
sutProvider.GetDependency<ICurrentContext>().ManageUsers(organization.Id).Returns(false);
|
||||
|
||||
var (result, failureMessage) = await sutProvider.Sut.CanScaleAsync(organization, 10);
|
||||
|
||||
Assert.False(result);
|
||||
Assert.Contains("Cannot manage organization users", failureMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user