mirror of
https://github.com/bitwarden/server.git
synced 2025-04-29 16:52:16 -05:00

* WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * Add `Notes` column to `OrganizationSponsorships` table * Add feature flag to `CreateAdminInitiatedSponsorshipHandler` * Unit tests for `CreateSponsorshipHandler` * More tests for `CreateSponsorshipHandler` * Forgot to add `Notes` column to `OrganizationSponsorships` table in the migration script * `CreateAdminInitiatedSponsorshipHandler` unit tests * Fix `CreateSponsorshipCommandTests` * Encrypt the notes field * Wrong business logic checking for invalid permissions. * Wrong business logic checking for invalid permissions. * Remove design patterns * duplicate definition in Constants.cs * initial commit * Merge Change with pm-17830 and use the property * Add the new property to download licence * Add the new property Signed-off-by: Cy Okeke <cokeke@bitwarden.com> * Remove the unsed failing test Signed-off-by: Cy Okeke <cokeke@bitwarden.com> * Remove unused method Signed-off-by: Cy Okeke <cokeke@bitwarden.com> --------- Signed-off-by: Cy Okeke <cokeke@bitwarden.com> Co-authored-by: Jonas Hendrickx <jhendrickx@bitwarden.com>
37 lines
1.5 KiB
C#
37 lines
1.5 KiB
C#
using System.Security.Claims;
|
|
using Bit.Core.Models.Business;
|
|
using Bit.Core.Settings;
|
|
using Bit.Test.Common.AutoFixture.Attributes;
|
|
using NSubstitute;
|
|
using Xunit;
|
|
|
|
namespace Bit.Core.Test.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));
|
|
}
|
|
}
|