1
0
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:
Matt Gibson
2021-10-25 10:19:37 -05:00
committed by GitHub
parent c5d5601464
commit 8f0115e62f
4 changed files with 14 additions and 31 deletions

View File

@ -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);
}
}
}