mirror of
https://github.com/bitwarden/server.git
synced 2025-05-20 11:04:31 -05:00
[AC-2426] Allow editing of client organization name (#4072)
* Allow editing of client organization name * Removing unnecessary using for linter
This commit is contained in:
parent
e93894a6fd
commit
fd173e81b6
@ -133,10 +133,17 @@ public class ProviderClientsController(
|
|||||||
return TypedResults.Problem();
|
return TypedResults.Problem();
|
||||||
}
|
}
|
||||||
|
|
||||||
await assignSeatsToClientOrganizationCommand.AssignSeatsToClientOrganization(
|
if (clientOrganization.Seats != requestBody.AssignedSeats)
|
||||||
provider,
|
{
|
||||||
clientOrganization,
|
await assignSeatsToClientOrganizationCommand.AssignSeatsToClientOrganization(
|
||||||
requestBody.AssignedSeats);
|
provider,
|
||||||
|
clientOrganization,
|
||||||
|
requestBody.AssignedSeats);
|
||||||
|
}
|
||||||
|
|
||||||
|
clientOrganization.Name = requestBody.Name;
|
||||||
|
|
||||||
|
await organizationRepository.ReplaceAsync(clientOrganization);
|
||||||
|
|
||||||
return TypedResults.Ok();
|
return TypedResults.Ok();
|
||||||
}
|
}
|
||||||
|
@ -7,4 +7,7 @@ public class UpdateClientOrganizationRequestBody
|
|||||||
[Required]
|
[Required]
|
||||||
[Range(0, int.MaxValue, ErrorMessage = "You cannot assign negative seats to a client organization.")]
|
[Range(0, int.MaxValue, ErrorMessage = "You cannot assign negative seats to a client organization.")]
|
||||||
public int AssignedSeats { get; set; }
|
public int AssignedSeats { get; set; }
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public string Name { get; set; }
|
||||||
}
|
}
|
||||||
|
@ -301,7 +301,7 @@ public class ProviderClientsControllerTests
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Theory, BitAutoData]
|
[Theory, BitAutoData]
|
||||||
public async Task UpdateAsync_NoContent(
|
public async Task UpdateAsync_AssignedSeats_NoContent(
|
||||||
Guid providerId,
|
Guid providerId,
|
||||||
Guid providerOrganizationId,
|
Guid providerOrganizationId,
|
||||||
UpdateClientOrganizationRequestBody requestBody,
|
UpdateClientOrganizationRequestBody requestBody,
|
||||||
@ -333,6 +333,50 @@ public class ProviderClientsControllerTests
|
|||||||
organization,
|
organization,
|
||||||
requestBody.AssignedSeats);
|
requestBody.AssignedSeats);
|
||||||
|
|
||||||
|
await sutProvider.GetDependency<IOrganizationRepository>().Received(1)
|
||||||
|
.ReplaceAsync(Arg.Is<Organization>(org => org.Name == requestBody.Name));
|
||||||
|
|
||||||
|
Assert.IsType<Ok>(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Theory, BitAutoData]
|
||||||
|
public async Task UpdateAsync_Name_NoContent(
|
||||||
|
Guid providerId,
|
||||||
|
Guid providerOrganizationId,
|
||||||
|
UpdateClientOrganizationRequestBody requestBody,
|
||||||
|
Provider provider,
|
||||||
|
ProviderOrganization providerOrganization,
|
||||||
|
Organization organization,
|
||||||
|
SutProvider<ProviderClientsController> sutProvider)
|
||||||
|
{
|
||||||
|
sutProvider.GetDependency<IFeatureService>().IsEnabled(FeatureFlagKeys.EnableConsolidatedBilling)
|
||||||
|
.Returns(true);
|
||||||
|
|
||||||
|
sutProvider.GetDependency<ICurrentContext>().ProviderProviderAdmin(providerId)
|
||||||
|
.Returns(true);
|
||||||
|
|
||||||
|
sutProvider.GetDependency<IProviderRepository>().GetByIdAsync(providerId)
|
||||||
|
.Returns(provider);
|
||||||
|
|
||||||
|
sutProvider.GetDependency<IProviderOrganizationRepository>().GetByIdAsync(providerOrganizationId)
|
||||||
|
.Returns(providerOrganization);
|
||||||
|
|
||||||
|
sutProvider.GetDependency<IOrganizationRepository>().GetByIdAsync(providerOrganization.OrganizationId)
|
||||||
|
.Returns(organization);
|
||||||
|
|
||||||
|
requestBody.AssignedSeats = organization.Seats!.Value;
|
||||||
|
|
||||||
|
var result = await sutProvider.Sut.UpdateAsync(providerId, providerOrganizationId, requestBody);
|
||||||
|
|
||||||
|
await sutProvider.GetDependency<IAssignSeatsToClientOrganizationCommand>().DidNotReceiveWithAnyArgs()
|
||||||
|
.AssignSeatsToClientOrganization(
|
||||||
|
Arg.Any<Provider>(),
|
||||||
|
Arg.Any<Organization>(),
|
||||||
|
Arg.Any<int>());
|
||||||
|
|
||||||
|
await sutProvider.GetDependency<IOrganizationRepository>().Received(1)
|
||||||
|
.ReplaceAsync(Arg.Is<Organization>(org => org.Name == requestBody.Name));
|
||||||
|
|
||||||
Assert.IsType<Ok>(result);
|
Assert.IsType<Ok>(result);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
Loading…
x
Reference in New Issue
Block a user