1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-31 22:45:12 -05:00
Files
bitwarden/test/Core.Test/Billing/Models/Business/OrganizationLicenseTests.cs
Conner Turnbull 9b65e9f4cc [PM-22580] Org/User License Codeownership Move (No logic changes) (#6080)
* Moved license models to billing

* Moved LicensingService to billing

* Moved license command and queries to billing

* Moved LicenseController to billing
2025-07-11 16:41:32 -04:00

37 lines
1.5 KiB
C#

using System.Security.Claims;
using Bit.Core.Billing.Models.Business;
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));
}
}