1
0
mirror of https://github.com/bitwarden/server synced 2025-12-16 08:13:33 +00:00
Files
server/test/Core.Test/Billing/Models/Business/OrganizationLicenseTests.cs
Alex Morask ec70a18bda [NO LOGIC] [PM-21100] Organize billing organization code (#6099)
* [NO LOGIC] Organize Billing organization code

* Run dotnet format
2025-07-17 12:02:25 -05:00

37 lines
1.6 KiB
C#

using System.Security.Claims;
using Bit.Core.Billing.Organizations.Models;
using Bit.Core.Settings;
using Bit.Test.Common.AutoFixture.Attributes;
using NSubstitute;
using Xunit;
namespace Bit.Core.Test.Billing.Models.Business;
public class OrganizationLicenseTests
{
/// <summary>
/// Verifies that when the license file is loaded from disk using the current OrganizationLicense class,
/// it matches the Organization it was generated for.
/// This guards against the risk that properties added in later versions are accidentally included in the validation
/// </summary>
[Theory]
[BitAutoData(OrganizationLicense.CurrentLicenseFileVersion)] // Previous version (this property is 1 behind)
[BitAutoData(OrganizationLicense.CurrentLicenseFileVersion + 1)] // Current version
public void OrganizationLicense_LoadedFromDisk_VerifyData_Passes(int licenseVersion, ClaimsPrincipal claimsPrincipal)
{
var license = OrganizationLicenseFileFixtures.GetVersion(licenseVersion);
// These licenses will naturally expire over time, but we still want them to be able to test
license.Expires = DateTime.MaxValue;
var organization = OrganizationLicenseFileFixtures.OrganizationFactory();
var globalSettings = Substitute.For<IGlobalSettings>();
globalSettings.Installation.Returns(new GlobalSettings.InstallationSettings
{
Id = new Guid(OrganizationLicenseFileFixtures.InstallationId)
});
Assert.True(license.VerifyData(organization, claimsPrincipal, globalSettings));
}
}