diff --git a/test/Core.Test/AutoFixture/CollectionFixtures.cs b/test/Core.Test/AutoFixture/CollectionFixtures.cs index 154e0f54cb..2ad602983b 100644 --- a/test/Core.Test/AutoFixture/CollectionFixtures.cs +++ b/test/Core.Test/AutoFixture/CollectionFixtures.cs @@ -61,7 +61,7 @@ namespace Bit.Core.Test.AutoFixture.CollectionFixtures internal class CollectionAutoDataAttribute : CustomAutoDataAttribute { - public CollectionAutoDataAttribute() : base(new SutProviderCustomization(), new Bit.Core.Test.AutoFixture.OrganizationFixtures.Organization()) + public CollectionAutoDataAttribute() : base(new SutProviderCustomization(), new OrganizationCustomization()) { } } } diff --git a/test/Core.Test/AutoFixture/GroupFixtures.cs b/test/Core.Test/AutoFixture/GroupFixtures.cs index 822ed421e3..d5abd759f6 100644 --- a/test/Core.Test/AutoFixture/GroupFixtures.cs +++ b/test/Core.Test/AutoFixture/GroupFixtures.cs @@ -8,21 +8,20 @@ using Bit.Core.Test.AutoFixture.Relays; using Bit.Infrastructure.EntityFramework.Repositories; using Bit.Test.Common.AutoFixture; using Bit.Test.Common.AutoFixture.Attributes; -using Fixtures = Bit.Core.Test.AutoFixture.OrganizationFixtures; namespace Bit.Core.Test.AutoFixture.GroupFixtures { internal class GroupOrganizationAutoDataAttribute : CustomAutoDataAttribute { public GroupOrganizationAutoDataAttribute() : base( - new SutProviderCustomization(), new Fixtures.Organization { UseGroups = true }) + new SutProviderCustomization(), new OrganizationCustomization { UseGroups = true }) { } } internal class GroupOrganizationNotUseGroupsAutoDataAttribute : CustomAutoDataAttribute { public GroupOrganizationNotUseGroupsAutoDataAttribute() : base( - new SutProviderCustomization(), new Bit.Core.Test.AutoFixture.OrganizationFixtures.Organization { UseGroups = false }) + new SutProviderCustomization(), new OrganizationCustomization { UseGroups = false }) { } } diff --git a/test/Core.Test/AutoFixture/OrganizationFixtures.cs b/test/Core.Test/AutoFixture/OrganizationFixtures.cs index d324aff6bf..a56fd42dac 100644 --- a/test/Core.Test/AutoFixture/OrganizationFixtures.cs +++ b/test/Core.Test/AutoFixture/OrganizationFixtures.cs @@ -17,7 +17,7 @@ using Bit.Test.Common.AutoFixture.Attributes; namespace Bit.Core.Test.AutoFixture.OrganizationFixtures { - public class Organization : ICustomization + public class OrganizationCustomization : ICustomization { public bool UseGroups { get; set; } @@ -26,7 +26,7 @@ namespace Bit.Core.Test.AutoFixture.OrganizationFixtures var organizationId = Guid.NewGuid(); var maxConnections = (short)new Random().Next(10, short.MaxValue); - fixture.Customize(composer => composer + fixture.Customize(composer => composer .With(o => o.Id, organizationId) .With(o => o.MaxCollections, maxConnections) .With(o => o.UseGroups, UseGroups)); @@ -51,14 +51,14 @@ namespace Bit.Core.Test.AutoFixture.OrganizationFixtures } var type = request as Type; - if (type == null || type != typeof(Entities.Organization)) + if (type == null || type != typeof(Organization)) { return new NoSpecimen(); } var fixture = new Fixture(); var providers = fixture.Create>(); - var organization = new Fixture().WithAutoNSubstitutions().Create(); + var organization = new Fixture().WithAutoNSubstitutions().Create(); organization.SetTwoFactorProviders(providers); return organization; } @@ -73,7 +73,7 @@ namespace Bit.Core.Test.AutoFixture.OrganizationFixtures var lowestActivePaidPlan = validUpgradePlans.First(); CheckedPlanType = CheckedPlanType.Equals(PlanType.Free) ? lowestActivePaidPlan : CheckedPlanType; validUpgradePlans.Remove(lowestActivePaidPlan); - fixture.Customize(composer => composer + fixture.Customize(composer => composer .With(o => o.PlanType, CheckedPlanType)); fixture.Customize(composer => composer .With(ou => ou.Plan, validUpgradePlans.First())); @@ -84,7 +84,7 @@ namespace Bit.Core.Test.AutoFixture.OrganizationFixtures { public void Customize(IFixture fixture) { - fixture.Customize(composer => composer + fixture.Customize(composer => composer .With(o => o.PlanType, PlanType.Free)); } } @@ -93,7 +93,7 @@ namespace Bit.Core.Test.AutoFixture.OrganizationFixtures { public void Customize(IFixture fixture) { - fixture.Customize(composer => composer + fixture.Customize(composer => composer .With(o => o.PlanType, PlanType.Free)); var plansToIgnore = new List { PlanType.Free, PlanType.Custom }; @@ -102,7 +102,7 @@ namespace Bit.Core.Test.AutoFixture.OrganizationFixtures fixture.Customize(composer => composer .With(ou => ou.Plan, selectedPlan.Type) .With(ou => ou.PremiumAccessAddon, selectedPlan.HasPremiumAccessOption)); - fixture.Customize(composer => composer + fixture.Customize(composer => composer .Without(o => o.GatewaySubscriptionId)); } } @@ -119,7 +119,7 @@ namespace Bit.Core.Test.AutoFixture.OrganizationFixtures { PropertyNamingPolicy = JsonNamingPolicy.CamelCase, }); - fixture.Customize(composer => composer + fixture.Customize(composer => composer .With(o => o.Id, organizationId) .With(o => o.Seats, (short)100)); fixture.Customize(composer => composer diff --git a/test/Core.Test/AutoFixture/OrganizationUserFixtures.cs b/test/Core.Test/AutoFixture/OrganizationUserFixtures.cs index b030432632..9bebea27de 100644 --- a/test/Core.Test/AutoFixture/OrganizationUserFixtures.cs +++ b/test/Core.Test/AutoFixture/OrganizationUserFixtures.cs @@ -5,6 +5,7 @@ using System.Text.Json; using AutoFixture; using AutoFixture.Kernel; using AutoFixture.Xunit2; +using Bit.Core.Entities; using Bit.Core.Enums; using Bit.Core.Models; using Bit.Core.Models.Data; @@ -27,10 +28,10 @@ namespace Bit.Core.Test.AutoFixture.OrganizationUserFixtures } var type = request as Type; - if (type == typeof(OrganizationUser)) + if (type == typeof(OrganizationUserCustomization)) { var fixture = new Fixture(); - var orgUser = fixture.WithAutoNSubstitutions().Create(); + var orgUser = fixture.WithAutoNSubstitutions().Create(); var orgUserPermissions = fixture.WithAutoNSubstitutions().Create(); orgUser.Permissions = JsonSerializer.Serialize(orgUserPermissions, new JsonSerializerOptions() { @@ -38,10 +39,10 @@ namespace Bit.Core.Test.AutoFixture.OrganizationUserFixtures }); return orgUser; } - else if (type == typeof(List)) + else if (type == typeof(List)) { var fixture = new Fixture(); - var orgUsers = fixture.WithAutoNSubstitutions().CreateMany(2); + var orgUsers = fixture.WithAutoNSubstitutions().CreateMany(2); foreach (var orgUser in orgUsers) { var providers = fixture.Create>(); @@ -57,12 +58,12 @@ namespace Bit.Core.Test.AutoFixture.OrganizationUserFixtures } } - internal class OrganizationUser : ICustomization + internal class OrganizationUserCustomization : ICustomization { public OrganizationUserStatusType Status { get; set; } public OrganizationUserType Type { get; set; } - public OrganizationUser(OrganizationUserStatusType status, OrganizationUserType type) + public OrganizationUserCustomization(OrganizationUserStatusType status, OrganizationUserType type) { Status = status; Type = type; @@ -70,7 +71,7 @@ namespace Bit.Core.Test.AutoFixture.OrganizationUserFixtures public void Customize(IFixture fixture) { - fixture.Customize(composer => composer + fixture.Customize(composer => composer .With(o => o.Type, Type) .With(o => o.Status, Status)); } @@ -91,7 +92,7 @@ namespace Bit.Core.Test.AutoFixture.OrganizationUserFixtures public override ICustomization GetCustomization(ParameterInfo parameter) { - return new OrganizationUser(_status, _type); + return new OrganizationUserCustomization(_status, _type); } } diff --git a/test/Core.Test/AutoFixture/PolicyFixtures.cs b/test/Core.Test/AutoFixture/PolicyFixtures.cs index a428e7395e..4d5a969ae2 100644 --- a/test/Core.Test/AutoFixture/PolicyFixtures.cs +++ b/test/Core.Test/AutoFixture/PolicyFixtures.cs @@ -3,6 +3,7 @@ using System.Reflection; using AutoFixture; using AutoFixture.Kernel; using AutoFixture.Xunit2; +using Bit.Core.Entities; using Bit.Core.Enums; using Bit.Core.Test.AutoFixture.EntityFrameworkRepositoryFixtures; using Bit.Core.Test.AutoFixture.OrganizationFixtures; @@ -12,18 +13,18 @@ using Bit.Test.Common.AutoFixture.Attributes; namespace Bit.Core.Test.AutoFixture.PolicyFixtures { - internal class Policy : ICustomization + internal class PolicyCustomization : ICustomization { public PolicyType Type { get; set; } - public Policy(PolicyType type) + public PolicyCustomization(PolicyType type) { Type = type; } public void Customize(IFixture fixture) { - fixture.Customize(composer => composer + fixture.Customize(composer => composer .With(o => o.OrganizationId, Guid.NewGuid()) .With(o => o.Type, Type) .With(o => o.Enabled, true)); @@ -41,7 +42,7 @@ namespace Bit.Core.Test.AutoFixture.PolicyFixtures public override ICustomization GetCustomization(ParameterInfo parameter) { - return new Policy(_type); + return new PolicyCustomization(_type); } } @@ -55,13 +56,13 @@ namespace Bit.Core.Test.AutoFixture.PolicyFixtures } var type = request as Type; - if (type == null || type != typeof(Entities.Policy)) + if (type == null || type != typeof(Policy)) { return new NoSpecimen(); } var fixture = new Fixture(); - var obj = fixture.WithAutoNSubstitutions().Create(); + var obj = fixture.WithAutoNSubstitutions().Create(); return obj; } } diff --git a/test/Core.Test/AutoFixture/TransactionFixutres.cs b/test/Core.Test/AutoFixture/TransactionFixutres.cs index 7c2199a305..43364e4629 100644 --- a/test/Core.Test/AutoFixture/TransactionFixutres.cs +++ b/test/Core.Test/AutoFixture/TransactionFixutres.cs @@ -23,7 +23,7 @@ namespace Bit.Core.Test.AutoFixture.TransactionFixtures } var type = request as Type; - if (type == null || type != typeof(Entities.Transaction)) + if (type == null || type != typeof(Transaction)) { return new NoSpecimen(); } @@ -35,7 +35,7 @@ namespace Bit.Core.Test.AutoFixture.TransactionFixtures .Without(c => c.OrganizationId)); } fixture.Customizations.Add(new MaxLengthStringRelay()); - var obj = fixture.WithAutoNSubstitutions().Create(); + var obj = fixture.WithAutoNSubstitutions().Create(); return obj; } } @@ -71,4 +71,3 @@ namespace Bit.Core.Test.AutoFixture.TransactionFixtures { } } } - diff --git a/test/Core.Test/Entities/OrganizationTests.cs b/test/Core.Test/Entities/OrganizationTests.cs new file mode 100644 index 0000000000..e83f8f490c --- /dev/null +++ b/test/Core.Test/Entities/OrganizationTests.cs @@ -0,0 +1,101 @@ +using System.Collections.Generic; +using System.Text.Json; +using Bit.Core.Entities; +using Bit.Core.Enums; +using Bit.Core.Models; +using Bit.Test.Common.Helpers; +using Xunit; + +namespace Bit.Core.Test.Entities +{ + public class OrganizationTests + { + private static readonly Dictionary _testConfig = new Dictionary() + { + [TwoFactorProviderType.OrganizationDuo] = new TwoFactorProvider + { + Enabled = true, + MetaData = new Dictionary + { + ["IKey"] = "IKey_value", + ["SKey"] = "SKey_value", + ["Host"] = "Host_value", + }, + } + }; + + + [Fact] + public void SetTwoFactorProviders_Success() + { + var organization = new Organization(); + organization.SetTwoFactorProviders(_testConfig); + + using var jsonDocument = JsonDocument.Parse(organization.TwoFactorProviders); + var root = jsonDocument.RootElement; + + var duo = AssertHelper.AssertJsonProperty(root, "6", JsonValueKind.Object); + AssertHelper.AssertJsonProperty(duo, "Enabled", JsonValueKind.True); + var duoMetaData = AssertHelper.AssertJsonProperty(duo, "MetaData", JsonValueKind.Object); + var iKey = AssertHelper.AssertJsonProperty(duoMetaData, "IKey", JsonValueKind.String).GetString(); + Assert.Equal("IKey_value", iKey); + var sKey = AssertHelper.AssertJsonProperty(duoMetaData, "SKey", JsonValueKind.String).GetString(); + Assert.Equal("SKey_value", sKey); + var host = AssertHelper.AssertJsonProperty(duoMetaData, "Host", JsonValueKind.String).GetString(); + Assert.Equal("Host_value", host); + } + + [Fact] + public void GetTwoFactorProviders_Success() + { + // This is to get rid of the cached dictionary the SetTwoFactorProviders keeps so we can fully test the JSON reading + // It intent is to mimic a storing of the entity in the database and it being read later + var tempOrganization = new Organization(); + tempOrganization.SetTwoFactorProviders(_testConfig); + var organization = new Organization + { + TwoFactorProviders = tempOrganization.TwoFactorProviders, + }; + + var twoFactorProviders = organization.GetTwoFactorProviders(); + + var duo = Assert.Contains(TwoFactorProviderType.OrganizationDuo, (IDictionary)twoFactorProviders); + Assert.True(duo.Enabled); + Assert.NotNull(duo.MetaData); + var iKey = Assert.Contains("IKey", (IDictionary)duo.MetaData); + Assert.Equal("IKey_value", iKey); + var sKey = Assert.Contains("SKey", (IDictionary)duo.MetaData); + Assert.Equal("SKey_value", sKey); + var host = Assert.Contains("Host", (IDictionary)duo.MetaData); + Assert.Equal("Host_value", host); + } + + [Fact] + public void GetTwoFactorProviders_SavedWithName_Success() + { + var organization = new Organization(); + // This should save items with the string name of the enum and we will validate that we can read + // from that just incase some organizations have it saved that way. + organization.TwoFactorProviders = JsonSerializer.Serialize(_testConfig); + + // Preliminary Asserts to make sure we are testing what we want to be testing + using var jsonDocument = JsonDocument.Parse(organization.TwoFactorProviders); + var root = jsonDocument.RootElement; + // This means it saved the enum as its string name + AssertHelper.AssertJsonProperty(root, "OrganizationDuo", JsonValueKind.Object); + + // Actual checks + var twoFactorProviders = organization.GetTwoFactorProviders(); + + var duo = Assert.Contains(TwoFactorProviderType.OrganizationDuo, (IDictionary)twoFactorProviders); + Assert.True(duo.Enabled); + Assert.NotNull(duo.MetaData); + var iKey = Assert.Contains("IKey", (IDictionary)duo.MetaData); + Assert.Equal("IKey_value", iKey); + var sKey = Assert.Contains("SKey", (IDictionary)duo.MetaData); + Assert.Equal("SKey_value", sKey); + var host = Assert.Contains("Host", (IDictionary)duo.MetaData); + Assert.Equal("Host_value", host); + } + } +} diff --git a/test/Core.Test/Entities/UserTests.cs b/test/Core.Test/Entities/UserTests.cs new file mode 100644 index 0000000000..39a10fff3c --- /dev/null +++ b/test/Core.Test/Entities/UserTests.cs @@ -0,0 +1,146 @@ +using System.Collections.Generic; +using System.Text.Json; +using Bit.Core.Entities; +using Bit.Core.Enums; +using Bit.Core.Models; +using Bit.Test.Common.Helpers; +using Xunit; + +namespace Bit.Core.Test.Entities +{ + public class UserTests + { + // KB MB GB + public const long Multiplier = 1024 * 1024 * 1024; + + [Fact] + public void StorageBytesRemaining_HasMax_DoesNotHaveStorage_ReturnsMaxAsBytes() + { + short maxStorageGb = 1; + + var user = new User + { + MaxStorageGb = maxStorageGb, + Storage = null, + }; + + var bytesRemaining = user.StorageBytesRemaining(); + + Assert.Equal(bytesRemaining, maxStorageGb * Multiplier); + } + + [Theory] + [InlineData(2, 1 * Multiplier, 1 * Multiplier)] + + public void StorageBytesRemaining_HasMax_HasStorage_ReturnRemainingStorage(short maxStorageGb, long storageBytes, long expectedRemainingBytes) + { + var user = new User + { + MaxStorageGb = maxStorageGb, + Storage = storageBytes, + }; + + var bytesRemaining = user.StorageBytesRemaining(); + + Assert.Equal(expectedRemainingBytes, bytesRemaining); + } + + private static readonly Dictionary _testTwoFactorConfig = new Dictionary + { + [TwoFactorProviderType.WebAuthn] = new TwoFactorProvider + { + Enabled = true, + MetaData = new Dictionary + { + ["Item"] = "thing", + }, + }, + [TwoFactorProviderType.Email] = new TwoFactorProvider + { + Enabled = false, + MetaData = new Dictionary + { + ["Email"] = "test@email.com", + }, + }, + }; + + [Fact] + public void SetTwoFactorProviders_Success() + { + var user = new User(); + user.SetTwoFactorProviders(_testTwoFactorConfig); + + using var jsonDocument = JsonDocument.Parse(user.TwoFactorProviders); + var root = jsonDocument.RootElement; + + var webAuthn = AssertHelper.AssertJsonProperty(root, "7", JsonValueKind.Object); + AssertHelper.AssertJsonProperty(webAuthn, "Enabled", JsonValueKind.True); + var webMetaData = AssertHelper.AssertJsonProperty(webAuthn, "MetaData", JsonValueKind.Object); + AssertHelper.AssertJsonProperty(webMetaData, "Item", JsonValueKind.String); + + var email = AssertHelper.AssertJsonProperty(root, "1", JsonValueKind.Object); + AssertHelper.AssertJsonProperty(email, "Enabled", JsonValueKind.False); + var emailMetaData = AssertHelper.AssertJsonProperty(email, "MetaData", JsonValueKind.Object); + AssertHelper.AssertJsonProperty(emailMetaData, "Email", JsonValueKind.String); + } + + [Fact] + public void GetTwoFactorProviders_Success() + { + // This is to get rid of the cached dictionary the SetTwoFactorProviders keeps so we can fully test the JSON reading + // It intent is to mimic a storing of the entity in the database and it being read later + var tempUser = new User(); + tempUser.SetTwoFactorProviders(_testTwoFactorConfig); + var user = new User + { + TwoFactorProviders = tempUser.TwoFactorProviders, + }; + + var twoFactorProviders = user.GetTwoFactorProviders(); + + var webAuthn = Assert.Contains(TwoFactorProviderType.WebAuthn, (IDictionary)twoFactorProviders); + Assert.True(webAuthn.Enabled); + Assert.NotNull(webAuthn.MetaData); + var webAuthnMetaDataItem = Assert.Contains("Item", (IDictionary)webAuthn.MetaData); + Assert.Equal("thing", webAuthnMetaDataItem); + + var email = Assert.Contains(TwoFactorProviderType.Email, (IDictionary)twoFactorProviders); + Assert.False(email.Enabled); + Assert.NotNull(email.MetaData); + var emailMetaDataEmail = Assert.Contains("Email", (IDictionary)email.MetaData); + Assert.Equal("test@email.com", emailMetaDataEmail); + } + + [Fact] + public void GetTwoFactorProviders_SavedWithName_Success() + { + var user = new User(); + // This should save items with the string name of the enum and we will validate that we can read + // from that just incase some users have it saved that way. + user.TwoFactorProviders = JsonSerializer.Serialize(_testTwoFactorConfig); + + // Preliminary Asserts to make sure we are testing what we want to be testing + using var jsonDocument = JsonDocument.Parse(user.TwoFactorProviders); + var root = jsonDocument.RootElement; + // This means it saved the enum as its string name + AssertHelper.AssertJsonProperty(root, "WebAuthn", JsonValueKind.Object); + AssertHelper.AssertJsonProperty(root, "Email", JsonValueKind.Object); + + // Actual checks + var twoFactorProviders = user.GetTwoFactorProviders(); + + var webAuthn = Assert.Contains(TwoFactorProviderType.WebAuthn, (IDictionary)twoFactorProviders); + Assert.True(webAuthn.Enabled); + Assert.NotNull(webAuthn.MetaData); + var webAuthnMetaDataItem = Assert.Contains("Item", (IDictionary)webAuthn.MetaData); + Assert.Equal("thing", webAuthnMetaDataItem); + + var email = Assert.Contains(TwoFactorProviderType.Email, (IDictionary)twoFactorProviders); + Assert.False(email.Enabled); + Assert.NotNull(email.MetaData); + var emailMetaDataEmail = Assert.Contains("Email", (IDictionary)email.MetaData); + Assert.Equal("test@email.com", emailMetaDataEmail); + } + } +} diff --git a/test/Core.Test/Models/Tables/UserTests.cs b/test/Core.Test/Models/Tables/UserTests.cs deleted file mode 100644 index 80fa623261..0000000000 --- a/test/Core.Test/Models/Tables/UserTests.cs +++ /dev/null @@ -1,86 +0,0 @@ -using System.Collections.Generic; -using System.Text.Json; -using Bit.Core.Entities; -using Bit.Core.Enums; -using Bit.Core.Models; -using Bit.Test.Common.Helpers; -using Xunit; - -namespace Bit.Core.Test.Models.Tables -{ - public class UserTests - { - // KB MB GB - public const long Multiplier = 1024 * 1024 * 1024; - - [Fact] - public void StorageBytesRemaining_HasMax_DoesNotHaveStorage_ReturnsMaxAsBytes() - { - short maxStorageGb = 1; - - var user = new User - { - MaxStorageGb = maxStorageGb, - Storage = null, - }; - - var bytesRemaining = user.StorageBytesRemaining(); - - Assert.Equal(bytesRemaining, maxStorageGb * Multiplier); - } - - [Theory] - [InlineData(2, 1 * Multiplier, 1 * Multiplier)] - - public void StorageBytesRemaining_HasMax_HasStorage_ReturnRemainingStorage(short maxStorageGb, long storageBytes, long expectedRemainingBytes) - { - var user = new User - { - MaxStorageGb = maxStorageGb, - Storage = storageBytes, - }; - - var bytesRemaining = user.StorageBytesRemaining(); - - Assert.Equal(expectedRemainingBytes, bytesRemaining); - } - - [Fact] - public void SetTwoFactorProviders() - { - var user = new User(); - user.SetTwoFactorProviders(new Dictionary - { - [TwoFactorProviderType.WebAuthn] = new TwoFactorProvider - { - Enabled = true, - MetaData = new Dictionary - { - ["Item"] = "thing", - }, - }, - [TwoFactorProviderType.Email] = new TwoFactorProvider - { - Enabled = false, - MetaData = new Dictionary - { - ["Email"] = "test@email.com", - }, - }, - }); - - using var jsonDocument = JsonDocument.Parse(user.TwoFactorProviders); - var root = jsonDocument.RootElement; - - var webAuthn = AssertHelper.AssertJsonProperty(root, "7", JsonValueKind.Object); - AssertHelper.AssertJsonProperty(webAuthn, "Enabled", JsonValueKind.True); - var webMetaData = AssertHelper.AssertJsonProperty(webAuthn, "MetaData", JsonValueKind.Object); - AssertHelper.AssertJsonProperty(webMetaData, "Item", JsonValueKind.String); - - var email = AssertHelper.AssertJsonProperty(root, "1", JsonValueKind.Object); - AssertHelper.AssertJsonProperty(email, "Enabled", JsonValueKind.False); - var emailMetaData = AssertHelper.AssertJsonProperty(email, "MetaData", JsonValueKind.Object); - AssertHelper.AssertJsonProperty(emailMetaData, "Email", JsonValueKind.String); - } - } -} diff --git a/test/Core.Test/Services/SendServiceTests.cs b/test/Core.Test/Services/SendServiceTests.cs index eeb467009b..8137c62524 100644 --- a/test/Core.Test/Services/SendServiceTests.cs +++ b/test/Core.Test/Services/SendServiceTests.cs @@ -10,6 +10,7 @@ using Bit.Core.Models.Data; using Bit.Core.Repositories; using Bit.Core.Services; using Bit.Core.Test.AutoFixture.SendFixtures; +using Bit.Core.Test.Entities; using Bit.Test.Common.AutoFixture; using Microsoft.AspNetCore.Identity; using NSubstitute; @@ -254,7 +255,7 @@ namespace Bit.Core.Test.Services EmailVerified = true, Premium = true, MaxStorageGb = 2, - Storage = 2 * Models.Tables.UserTests.Multiplier, + Storage = 2 * UserTests.Multiplier, }; send.UserId = user.Id; @@ -302,7 +303,7 @@ namespace Bit.Core.Test.Services .SelfHosted = true; var badRequest = await Assert.ThrowsAsync(() => - sutProvider.Sut.SaveFileSendAsync(send, null, 11000 * Models.Tables.UserTests.Multiplier) + sutProvider.Sut.SaveFileSendAsync(send, null, 11000 * UserTests.Multiplier) ); Assert.Contains("not enough storage", badRequest.Message, StringComparison.InvariantCultureIgnoreCase); @@ -335,7 +336,7 @@ namespace Bit.Core.Test.Services .SelfHosted = false; var badRequest = await Assert.ThrowsAsync(() => - sutProvider.Sut.SaveFileSendAsync(send, null, 2 * Models.Tables.UserTests.Multiplier) + sutProvider.Sut.SaveFileSendAsync(send, null, 2 * UserTests.Multiplier) ); Assert.Contains("not enough storage", badRequest.Message, StringComparison.InvariantCultureIgnoreCase); @@ -413,7 +414,7 @@ namespace Bit.Core.Test.Services .Returns(org); var badRequest = await Assert.ThrowsAsync(() => - sutProvider.Sut.SaveFileSendAsync(send, null, 2 * Models.Tables.UserTests.Multiplier) + sutProvider.Sut.SaveFileSendAsync(send, null, 2 * UserTests.Multiplier) ); Assert.Contains("not enough storage", badRequest.Message, StringComparison.InvariantCultureIgnoreCase); @@ -455,7 +456,7 @@ namespace Bit.Core.Test.Services var utcNow = DateTime.UtcNow; - var url = await sutProvider.Sut.SaveFileSendAsync(send, data, 1 * Models.Tables.UserTests.Multiplier); + var url = await sutProvider.Sut.SaveFileSendAsync(send, data, 1 * UserTests.Multiplier); Assert.Equal(testUrl, url); Assert.True(send.RevisionDate - utcNow < TimeSpan.FromSeconds(1)); @@ -510,7 +511,7 @@ namespace Bit.Core.Test.Services var utcNow = DateTime.UtcNow; var exception = await Assert.ThrowsAsync(() => - sutProvider.Sut.SaveFileSendAsync(send, data, 1 * Models.Tables.UserTests.Multiplier) + sutProvider.Sut.SaveFileSendAsync(send, data, 1 * UserTests.Multiplier) ); Assert.True(send.RevisionDate - utcNow < TimeSpan.FromSeconds(1));