mirror of
https://github.com/bitwarden/server.git
synced 2024-11-24 12:35:25 +01:00
b12e881ece
* Add billing endpoint to determine SM standalone for org. * Add missing attribute
44 lines
1.4 KiB
C#
44 lines
1.4 KiB
C#
using Bit.Api.Billing.Controllers;
|
|
using Bit.Api.Billing.Models.Responses;
|
|
using Bit.Core.Billing.Models;
|
|
using Bit.Core.Billing.Queries;
|
|
using Bit.Test.Common.AutoFixture;
|
|
using Bit.Test.Common.AutoFixture.Attributes;
|
|
using Microsoft.AspNetCore.Http.HttpResults;
|
|
using NSubstitute;
|
|
using Xunit;
|
|
|
|
namespace Bit.Api.Test.Billing.Controllers;
|
|
|
|
[ControllerCustomize(typeof(OrganizationBillingController))]
|
|
[SutProviderCustomize]
|
|
public class OrganizationBillingControllerTests
|
|
{
|
|
[Theory, BitAutoData]
|
|
public async Task GetMetadataAsync_MetadataNull_NotFound(
|
|
Guid organizationId,
|
|
SutProvider<OrganizationBillingController> sutProvider)
|
|
{
|
|
var result = await sutProvider.Sut.GetMetadataAsync(organizationId);
|
|
|
|
Assert.IsType<NotFound>(result);
|
|
}
|
|
|
|
[Theory, BitAutoData]
|
|
public async Task GetMetadataAsync_OK(
|
|
Guid organizationId,
|
|
SutProvider<OrganizationBillingController> sutProvider)
|
|
{
|
|
sutProvider.GetDependency<IOrganizationBillingQueries>().GetMetadata(organizationId)
|
|
.Returns(new OrganizationMetadataDTO(true));
|
|
|
|
var result = await sutProvider.Sut.GetMetadataAsync(organizationId);
|
|
|
|
Assert.IsType<Ok<OrganizationMetadataResponse>>(result);
|
|
|
|
var organizationMetadataResponse = ((Ok<OrganizationMetadataResponse>)result).Value;
|
|
|
|
Assert.True(organizationMetadataResponse.IsOnSecretsManagerStandalone);
|
|
}
|
|
}
|