diff --git a/bitwarden-server.sln b/bitwarden-server.sln index 410afae94..50095d725 100644 --- a/bitwarden-server.sln +++ b/bitwarden-server.sln @@ -74,6 +74,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MySqlMigrations", "util\MyS EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PostgresMigrations", "util\PostgresMigrations\PostgresMigrations.csproj", "{F72E0229-2EF7-49B3-9004-FF4C0043816E}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Common", "test\Common\Common.csproj", "{17DA09D7-0212-4009-879E-6B9CFDE5FA60}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -158,7 +160,6 @@ Global {F72E0229-2EF7-49B3-9004-FF4C0043816E}.Debug|Any CPU.Build.0 = Debug|Any CPU {F72E0229-2EF7-49B3-9004-FF4C0043816E}.Release|Any CPU.ActiveCfg = Release|Any CPU {F72E0229-2EF7-49B3-9004-FF4C0043816E}.Release|Any CPU.Build.0 = Release|Any CPU - {EDC0D688-D58C-4CE1-AA07-3606AC6874B8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {EDC0D688-D58C-4CE1-AA07-3606AC6874B8}.Debug|Any CPU.Build.0 = Debug|Any CPU {EDC0D688-D58C-4CE1-AA07-3606AC6874B8}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -167,6 +168,10 @@ Global {0E99A21B-684B-4C59-9831-90F775CAB6F7}.Debug|Any CPU.Build.0 = Debug|Any CPU {0E99A21B-684B-4C59-9831-90F775CAB6F7}.Release|Any CPU.ActiveCfg = Release|Any CPU {0E99A21B-684B-4C59-9831-90F775CAB6F7}.Release|Any CPU.Build.0 = Release|Any CPU + {17DA09D7-0212-4009-879E-6B9CFDE5FA60}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {17DA09D7-0212-4009-879E-6B9CFDE5FA60}.Debug|Any CPU.Build.0 = Debug|Any CPU + {17DA09D7-0212-4009-879E-6B9CFDE5FA60}.Release|Any CPU.ActiveCfg = Release|Any CPU + {17DA09D7-0212-4009-879E-6B9CFDE5FA60}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -193,6 +198,7 @@ Global {F72E0229-2EF7-49B3-9004-FF4C0043816E} = {DD5BD056-4AAE-43EF-BBD2-0B569B8DA84E} {EDC0D688-D58C-4CE1-AA07-3606AC6874B8} = {4FDB6543-F68B-4202-9EA6-7FEA984D2D0A} {0E99A21B-684B-4C59-9831-90F775CAB6F7} = {287CFF34-BBDB-4BC4-AF88-1E19A5A4679B} + {17DA09D7-0212-4009-879E-6B9CFDE5FA60} = {DD5BD056-4AAE-43EF-BBD2-0B569B8DA84F} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {E01CBF68-2E20-425F-9EDB-E0A6510CA92F} diff --git a/test/Core.Test/AutoFixture/Attributes/CustomAutoDataAttribute.cs b/test/Common/AutoFixture/Attributes/CustomAutoDataAttribute.cs similarity index 93% rename from test/Core.Test/AutoFixture/Attributes/CustomAutoDataAttribute.cs rename to test/Common/AutoFixture/Attributes/CustomAutoDataAttribute.cs index ac2e81c1a..cd2feebca 100644 --- a/test/Core.Test/AutoFixture/Attributes/CustomAutoDataAttribute.cs +++ b/test/Common/AutoFixture/Attributes/CustomAutoDataAttribute.cs @@ -3,7 +3,7 @@ using System.Linq; using AutoFixture; using AutoFixture.Xunit2; -namespace Bit.Core.Test.AutoFixture.Attributes +namespace Bit.Test.Common.AutoFixture.Attributes { public class CustomAutoDataAttribute : AutoDataAttribute { diff --git a/test/Core.Test/AutoFixture/Attributes/InlineCustomAutoDataAttribute.cs b/test/Common/AutoFixture/Attributes/InlineCustomAutoDataAttribute.cs similarity index 83% rename from test/Core.Test/AutoFixture/Attributes/InlineCustomAutoDataAttribute.cs rename to test/Common/AutoFixture/Attributes/InlineCustomAutoDataAttribute.cs index ac1c22a65..d36f963a4 100644 --- a/test/Core.Test/AutoFixture/Attributes/InlineCustomAutoDataAttribute.cs +++ b/test/Common/AutoFixture/Attributes/InlineCustomAutoDataAttribute.cs @@ -4,9 +4,9 @@ using Xunit.Sdk; using AutoFixture.Xunit2; using AutoFixture; -namespace Bit.Core.Test.AutoFixture.Attributes +namespace Bit.Test.Common.AutoFixture.Attributes { - internal class InlineCustomAutoDataAttribute : CompositeDataAttribute + public class InlineCustomAutoDataAttribute : CompositeDataAttribute { public InlineCustomAutoDataAttribute(Type[] iCustomizationTypes, params object[] values) : base(new DataAttribute[] { new InlineDataAttribute(values), diff --git a/test/Common/AutoFixture/Attributes/InlineSutAutoDataAttribute.cs b/test/Common/AutoFixture/Attributes/InlineSutAutoDataAttribute.cs new file mode 100644 index 000000000..89eebad8c --- /dev/null +++ b/test/Common/AutoFixture/Attributes/InlineSutAutoDataAttribute.cs @@ -0,0 +1,20 @@ +using System; +using System.Linq; +using AutoFixture; + +namespace Bit.Test.Common.AutoFixture.Attributes +{ + public class InlineSutAutoDataAttribute : InlineCustomAutoDataAttribute + { + public InlineSutAutoDataAttribute(params object[] values) : base( + new Type[] { typeof(SutProviderCustomization) }, values) + { } + public InlineSutAutoDataAttribute(Type[] iCustomizationTypes, params object[] values) : base( + iCustomizationTypes.Append(typeof(SutProviderCustomization)).ToArray(), values) + { } + + public InlineSutAutoDataAttribute(ICustomization[] customizations, params object[] values) : base( + customizations.Append(new SutProviderCustomization()).ToArray(), values) + { } + } +} diff --git a/test/Common/AutoFixture/Attributes/SutAutoDataAttribute.cs b/test/Common/AutoFixture/Attributes/SutAutoDataAttribute.cs new file mode 100644 index 000000000..0aa666dad --- /dev/null +++ b/test/Common/AutoFixture/Attributes/SutAutoDataAttribute.cs @@ -0,0 +1,15 @@ +using System; +using System.Linq; +using System.Reflection; +using AutoFixture; +using AutoFixture.Xunit2; + +namespace Bit.Test.Common.AutoFixture.Attributes +{ + public class SutAutoDataAttribute : CustomAutoDataAttribute + { + public SutAutoDataAttribute(params Type[] iCustomizationTypes) : base( + iCustomizationTypes.Append(typeof(SutProviderCustomization)).ToArray()) + { } + } +} diff --git a/test/Core.Test/AutoFixture/FixtureExtensions.cs b/test/Common/AutoFixture/FixtureExtensions.cs similarity index 87% rename from test/Core.Test/AutoFixture/FixtureExtensions.cs rename to test/Common/AutoFixture/FixtureExtensions.cs index 10021fbee..7249e8e41 100644 --- a/test/Core.Test/AutoFixture/FixtureExtensions.cs +++ b/test/Common/AutoFixture/FixtureExtensions.cs @@ -1,7 +1,7 @@ using AutoFixture; using AutoFixture.AutoNSubstitute; -namespace Bit.Core.Test.AutoFixture +namespace Bit.Test.Common.AutoFixture { public static class FixtureExtensions { diff --git a/test/Core.Test/AutoFixture/GlobalSettingsFixtures.cs b/test/Common/AutoFixture/GlobalSettingsFixtures.cs similarity index 57% rename from test/Core.Test/AutoFixture/GlobalSettingsFixtures.cs rename to test/Common/AutoFixture/GlobalSettingsFixtures.cs index 9eea0b063..8df15b107 100644 --- a/test/Core.Test/AutoFixture/GlobalSettingsFixtures.cs +++ b/test/Common/AutoFixture/GlobalSettingsFixtures.cs @@ -1,19 +1,13 @@ using System; -using System.Collections; -using System.Collections.Generic; using System.Reflection; using AutoFixture; using AutoFixture.Kernel; -using AutoMapper; -using Bit.Core.Enums; -using Bit.Core.Models; -using Bit.Core.Models.Table; -using Bit.Core.Settings; -using Bit.Core.Test.Helpers.Factories; +using AutoFixture.Xunit2; +using Bit.Test.Common.Helpers.Factories; -namespace Bit.Core.Test.AutoFixture.GlobalSettingsFixtures +namespace Bit.Test.Common.AutoFixture { - internal class GlobalSettingsBuilder: ISpecimenBuilder + public class GlobalSettingsBuilder : ISpecimenBuilder { public object Create(object request, ISpecimenContext context) { @@ -25,22 +19,27 @@ namespace Bit.Core.Test.AutoFixture.GlobalSettingsFixtures var pi = request as ParameterInfo; var fixture = new Fixture(); - if (pi == null || pi.ParameterType != typeof(Settings.GlobalSettings)) + if (pi == null || pi.ParameterType != typeof(Bit.Core.Settings.GlobalSettings)) return new NoSpecimen(); return GlobalSettingsFactory.GlobalSettings; } } - internal class GlobalSettings : ICustomization + public class GlobalSettings : ICustomization { public void Customize(IFixture fixture) { - fixture.Customize(composer => composer + fixture.Customize(composer => composer .Without(s => s.BaseServiceUri) .Without(s => s.Attachment) .Without(s => s.Send) .Without(s => s.DataProtection)); } } + + public class GlobalSettingsCustomizeAttribute : CustomizeAttribute + { + public override ICustomization GetCustomization(ParameterInfo parameter) => new GlobalSettings(); + } } diff --git a/test/Core.Test/AutoFixture/ISutProvider.cs b/test/Common/AutoFixture/ISutProvider.cs similarity index 76% rename from test/Core.Test/AutoFixture/ISutProvider.cs rename to test/Common/AutoFixture/ISutProvider.cs index 3a22bf489..c72dc4a27 100644 --- a/test/Core.Test/AutoFixture/ISutProvider.cs +++ b/test/Common/AutoFixture/ISutProvider.cs @@ -1,6 +1,6 @@ using System; -namespace Bit.Core.Test.AutoFixture +namespace Bit.Test.Common.AutoFixture { public interface ISutProvider { diff --git a/test/Core.Test/AutoFixture/SutProvider.cs b/test/Common/AutoFixture/SutProvider.cs similarity index 98% rename from test/Core.Test/AutoFixture/SutProvider.cs rename to test/Common/AutoFixture/SutProvider.cs index e8b475d24..0846655a7 100644 --- a/test/Core.Test/AutoFixture/SutProvider.cs +++ b/test/Common/AutoFixture/SutProvider.cs @@ -4,9 +4,8 @@ using AutoFixture; using AutoFixture.Kernel; using System.Reflection; using System.Linq; -using Bit.Core.Test.AutoFixture.GlobalSettingsFixtures; -namespace Bit.Core.Test.AutoFixture +namespace Bit.Test.Common.AutoFixture { public class SutProvider : ISutProvider { diff --git a/test/Core.Test/AutoFixture/SutProviderCustomization.cs b/test/Common/AutoFixture/SutProviderCustomization.cs similarity index 94% rename from test/Core.Test/AutoFixture/SutProviderCustomization.cs rename to test/Common/AutoFixture/SutProviderCustomization.cs index 549af17e7..f6041e91e 100644 --- a/test/Core.Test/AutoFixture/SutProviderCustomization.cs +++ b/test/Common/AutoFixture/SutProviderCustomization.cs @@ -2,7 +2,7 @@ using System; using AutoFixture; using AutoFixture.Kernel; -namespace Bit.Core.Test.AutoFixture +namespace Bit.Test.Common.AutoFixture.Attributes { public class SutProviderCustomization : ICustomization, ISpecimenBuilder { diff --git a/test/Common/Common.csproj b/test/Common/Common.csproj new file mode 100644 index 000000000..16dc167d4 --- /dev/null +++ b/test/Common/Common.csproj @@ -0,0 +1,25 @@ + + + + false + Bit.Test.Common + + + + + + + all + runtime; build; native; contentfiles; analyzers + + + + + + + + + + + + diff --git a/test/Common/Helpers/Factories.cs b/test/Common/Helpers/Factories.cs new file mode 100644 index 000000000..5067662d2 --- /dev/null +++ b/test/Common/Helpers/Factories.cs @@ -0,0 +1,19 @@ +using System.Collections.Generic; +using Bit.Core.Repositories.EntityFramework; +using Bit.Core.Settings; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Configuration; + +namespace Bit.Test.Common.Helpers.Factories +{ + public static class GlobalSettingsFactory + { + public static GlobalSettings GlobalSettings { get; } = new GlobalSettings(); + static GlobalSettingsFactory() + { + var configBuilder = new ConfigurationBuilder().AddUserSecrets(); + var Configuration = configBuilder.Build(); + ConfigurationBinder.Bind(Configuration.GetSection("GlobalSettings"), GlobalSettings); + } + } +} diff --git a/test/Core.Test/AutoFixture/CipherFixtures.cs b/test/Core.Test/AutoFixture/CipherFixtures.cs index 30d21f132..23730fe9d 100644 --- a/test/Core.Test/AutoFixture/CipherFixtures.cs +++ b/test/Core.Test/AutoFixture/CipherFixtures.cs @@ -7,14 +7,13 @@ using AutoFixture.Kernel; using Bit.Core.Models.Data; using Bit.Core.Models.Table; using Bit.Core.Repositories.EntityFramework; -using Bit.Core.Test.AutoFixture.Attributes; using Bit.Core.Test.AutoFixture.EntityFrameworkRepositoryFixtures; -using Bit.Core.Test.AutoFixture.GlobalSettingsFixtures; using Bit.Core.Test.AutoFixture.OrganizationFixtures; using Bit.Core.Test.AutoFixture.OrganizationUserFixtures; using Bit.Core.Test.AutoFixture.Relays; -using Bit.Core.Test.AutoFixture.TransactionFixtures; using Bit.Core.Test.AutoFixture.UserFixtures; +using Bit.Test.Common.AutoFixture; +using Bit.Test.Common.AutoFixture.Attributes; using Core.Models.Data; namespace Bit.Core.Test.AutoFixture.CipherFixtures diff --git a/test/Core.Test/AutoFixture/CollectionCipherFixtures.cs b/test/Core.Test/AutoFixture/CollectionCipherFixtures.cs index 54bc7524c..79a3cd38a 100644 --- a/test/Core.Test/AutoFixture/CollectionCipherFixtures.cs +++ b/test/Core.Test/AutoFixture/CollectionCipherFixtures.cs @@ -1,22 +1,15 @@ using AutoFixture; using TableModel = Bit.Core.Models.Table; -using Bit.Core.Test.AutoFixture.Attributes; -using Bit.Core.Test.AutoFixture.GlobalSettingsFixtures; -using AutoMapper; -using Bit.Core.Models.EntityFramework; -using Bit.Core.Models; -using System.Collections.Generic; -using Bit.Core.Enums; using AutoFixture.Kernel; using System; -using Bit.Core.Test.AutoFixture.OrganizationFixtures; using Bit.Core.Repositories.EntityFramework; using Bit.Core.Test.AutoFixture.EntityFrameworkRepositoryFixtures; -using Bit.Core.Test.AutoFixture.TransactionFixtures; using Bit.Core.Test.AutoFixture.Relays; using Bit.Core.Test.AutoFixture.CollectionFixtures; using Bit.Core.Test.AutoFixture.CipherFixtures; using Bit.Core.Test.AutoFixture.UserFixtures; +using Bit.Test.Common.AutoFixture; +using Bit.Test.Common.AutoFixture.Attributes; namespace Bit.Core.Test.AutoFixture.CollectionCipherFixtures { diff --git a/test/Core.Test/AutoFixture/CollectionFixtures.cs b/test/Core.Test/AutoFixture/CollectionFixtures.cs index adad029d8..fd1d91b5c 100644 --- a/test/Core.Test/AutoFixture/CollectionFixtures.cs +++ b/test/Core.Test/AutoFixture/CollectionFixtures.cs @@ -1,19 +1,13 @@ using AutoFixture; using TableModel = Bit.Core.Models.Table; -using Bit.Core.Test.AutoFixture.Attributes; -using Bit.Core.Test.AutoFixture.GlobalSettingsFixtures; -using AutoMapper; -using Bit.Core.Models.EntityFramework; -using Bit.Core.Models; -using System.Collections.Generic; -using Bit.Core.Enums; using AutoFixture.Kernel; using System; using Bit.Core.Test.AutoFixture.OrganizationFixtures; using Bit.Core.Repositories.EntityFramework; using Bit.Core.Test.AutoFixture.EntityFrameworkRepositoryFixtures; -using Bit.Core.Test.AutoFixture.TransactionFixtures; using Bit.Core.Test.AutoFixture.Relays; +using Bit.Test.Common.AutoFixture; +using Bit.Test.Common.AutoFixture.Attributes; namespace Bit.Core.Test.AutoFixture.CollectionFixtures { diff --git a/test/Core.Test/AutoFixture/CurrentContextFixtures.cs b/test/Core.Test/AutoFixture/CurrentContextFixtures.cs index 21b82102b..8dcaeb646 100644 --- a/test/Core.Test/AutoFixture/CurrentContextFixtures.cs +++ b/test/Core.Test/AutoFixture/CurrentContextFixtures.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using AutoFixture; using AutoFixture.Kernel; using Bit.Core.Context; +using Bit.Test.Common.AutoFixture; namespace Bit.Core.Test.AutoFixture.CurrentContextFixtures { diff --git a/test/Core.Test/AutoFixture/DeviceFixtures.cs b/test/Core.Test/AutoFixture/DeviceFixtures.cs index 17472c5fb..4fac109b0 100644 --- a/test/Core.Test/AutoFixture/DeviceFixtures.cs +++ b/test/Core.Test/AutoFixture/DeviceFixtures.cs @@ -1,20 +1,13 @@ using AutoFixture; using TableModel = Bit.Core.Models.Table; -using Bit.Core.Test.AutoFixture.Attributes; -using Bit.Core.Test.AutoFixture.GlobalSettingsFixtures; -using AutoMapper; -using Bit.Core.Models.EntityFramework; -using Bit.Core.Models; -using System.Collections.Generic; -using Bit.Core.Enums; using AutoFixture.Kernel; using System; -using Bit.Core.Test.AutoFixture.OrganizationFixtures; using Bit.Core.Repositories.EntityFramework; using Bit.Core.Test.AutoFixture.EntityFrameworkRepositoryFixtures; using Bit.Core.Test.AutoFixture.UserFixtures; -using Bit.Core.Test.AutoFixture.TransactionFixtures; using Bit.Core.Test.AutoFixture.Relays; +using Bit.Test.Common.AutoFixture; +using Bit.Test.Common.AutoFixture.Attributes; namespace Bit.Core.Test.AutoFixture.DeviceFixtures { diff --git a/test/Core.Test/AutoFixture/EmergencyAccessFixtures.cs b/test/Core.Test/AutoFixture/EmergencyAccessFixtures.cs index cdf240803..760a92a1e 100644 --- a/test/Core.Test/AutoFixture/EmergencyAccessFixtures.cs +++ b/test/Core.Test/AutoFixture/EmergencyAccessFixtures.cs @@ -1,21 +1,13 @@ using AutoFixture; using TableModel = Bit.Core.Models.Table; -using Bit.Core.Test.AutoFixture.Attributes; -using Bit.Core.Test.AutoFixture.GlobalSettingsFixtures; -using AutoMapper; -using Bit.Core.Models.EntityFramework; -using Bit.Core.Models; -using System.Collections.Generic; -using Bit.Core.Enums; using AutoFixture.Kernel; using System; -using Bit.Core.Test.AutoFixture.OrganizationFixtures; using Bit.Core.Repositories.EntityFramework; using Bit.Core.Test.AutoFixture.EntityFrameworkRepositoryFixtures; using Bit.Core.Test.AutoFixture.UserFixtures; -using Bit.Core.Test.AutoFixture.TransactionFixtures; -using AutoFixture.DataAnnotations; using Bit.Core.Test.AutoFixture.Relays; +using Bit.Test.Common.AutoFixture; +using Bit.Test.Common.AutoFixture.Attributes; namespace Bit.Core.Test.AutoFixture.EmergencyAccessFixtures { diff --git a/test/Core.Test/AutoFixture/EntityFrameworkRepositoryFixtures.cs b/test/Core.Test/AutoFixture/EntityFrameworkRepositoryFixtures.cs index 88bf72168..4096f6919 100644 --- a/test/Core.Test/AutoFixture/EntityFrameworkRepositoryFixtures.cs +++ b/test/Core.Test/AutoFixture/EntityFrameworkRepositoryFixtures.cs @@ -9,9 +9,9 @@ using Moq; using Microsoft.Extensions.DependencyInjection; using System.Reflection; using Bit.Core.Repositories.EntityFramework; -using Bit.Core.Test.Helpers.Factories; using Microsoft.EntityFrameworkCore; using Bit.Core.Settings; +using Bit.Core.Test.Helpers.Factories; namespace Bit.Core.Test.AutoFixture.EntityFrameworkRepositoryFixtures { diff --git a/test/Core.Test/AutoFixture/EventFixtures.cs b/test/Core.Test/AutoFixture/EventFixtures.cs index b903b2639..f5674ddd4 100644 --- a/test/Core.Test/AutoFixture/EventFixtures.cs +++ b/test/Core.Test/AutoFixture/EventFixtures.cs @@ -1,18 +1,12 @@ using AutoFixture; using TableModel = Bit.Core.Models.Table; -using Bit.Core.Test.AutoFixture.Attributes; -using Bit.Core.Test.AutoFixture.GlobalSettingsFixtures; -using AutoMapper; -using Bit.Core.Models.EntityFramework; -using Bit.Core.Models; -using System.Collections.Generic; -using Bit.Core.Enums; using AutoFixture.Kernel; using System; -using Bit.Core.Test.AutoFixture.OrganizationFixtures; using Bit.Core.Repositories.EntityFramework; using Bit.Core.Test.AutoFixture.EntityFrameworkRepositoryFixtures; using Bit.Core.Test.AutoFixture.Relays; +using Bit.Test.Common.AutoFixture; +using Bit.Test.Common.AutoFixture.Attributes; namespace Bit.Core.Test.AutoFixture.EventFixtures { diff --git a/test/Core.Test/AutoFixture/FolderFixtures.cs b/test/Core.Test/AutoFixture/FolderFixtures.cs index 9449ae71c..f46de2f75 100644 --- a/test/Core.Test/AutoFixture/FolderFixtures.cs +++ b/test/Core.Test/AutoFixture/FolderFixtures.cs @@ -1,19 +1,13 @@ using AutoFixture; using TableModel = Bit.Core.Models.Table; -using Bit.Core.Test.AutoFixture.Attributes; -using Bit.Core.Test.AutoFixture.GlobalSettingsFixtures; -using AutoMapper; -using Bit.Core.Models.EntityFramework; -using Bit.Core.Models; -using System.Collections.Generic; -using Bit.Core.Enums; using AutoFixture.Kernel; using System; -using Bit.Core.Test.AutoFixture.OrganizationFixtures; using Bit.Core.Repositories.EntityFramework; using Bit.Core.Test.AutoFixture.EntityFrameworkRepositoryFixtures; using Bit.Core.Test.AutoFixture.Relays; using Bit.Core.Test.AutoFixture.UserFixtures; +using Bit.Test.Common.AutoFixture; +using Bit.Test.Common.AutoFixture.Attributes; namespace Bit.Core.Test.AutoFixture.FolderFixtures { diff --git a/test/Core.Test/AutoFixture/GrantFixtures.cs b/test/Core.Test/AutoFixture/GrantFixtures.cs index a0142a29a..2c837f216 100644 --- a/test/Core.Test/AutoFixture/GrantFixtures.cs +++ b/test/Core.Test/AutoFixture/GrantFixtures.cs @@ -1,18 +1,12 @@ using AutoFixture; using TableModel = Bit.Core.Models.Table; -using Bit.Core.Test.AutoFixture.Attributes; -using Bit.Core.Test.AutoFixture.GlobalSettingsFixtures; -using AutoMapper; -using Bit.Core.Models.EntityFramework; -using Bit.Core.Models; -using System.Collections.Generic; -using Bit.Core.Enums; using AutoFixture.Kernel; using System; -using Bit.Core.Test.AutoFixture.OrganizationFixtures; using Bit.Core.Repositories.EntityFramework; using Bit.Core.Test.AutoFixture.EntityFrameworkRepositoryFixtures; using Bit.Core.Test.AutoFixture.Relays; +using Bit.Test.Common.AutoFixture; +using Bit.Test.Common.AutoFixture.Attributes; namespace Bit.Core.Test.AutoFixture.GrantFixtures { diff --git a/test/Core.Test/AutoFixture/GroupFixtures.cs b/test/Core.Test/AutoFixture/GroupFixtures.cs index 77190ce7b..b13a1c063 100644 --- a/test/Core.Test/AutoFixture/GroupFixtures.cs +++ b/test/Core.Test/AutoFixture/GroupFixtures.cs @@ -1,7 +1,5 @@ using AutoFixture; using TableModel = Bit.Core.Models.Table; -using Bit.Core.Test.AutoFixture.Attributes; -using Bit.Core.Test.AutoFixture.GlobalSettingsFixtures; using AutoFixture.Kernel; using System; using Bit.Core.Test.AutoFixture.OrganizationFixtures; @@ -9,6 +7,8 @@ using Bit.Core.Repositories.EntityFramework; using Bit.Core.Test.AutoFixture.EntityFrameworkRepositoryFixtures; using Bit.Core.Test.AutoFixture.Relays; using Fixtures = Bit.Core.Test.AutoFixture.OrganizationFixtures; +using Bit.Test.Common.AutoFixture.Attributes; +using Bit.Test.Common.AutoFixture; namespace Bit.Core.Test.AutoFixture.GroupFixtures { diff --git a/test/Core.Test/AutoFixture/GroupUserFixtures.cs b/test/Core.Test/AutoFixture/GroupUserFixtures.cs index 1ee09445e..6a44d7c81 100644 --- a/test/Core.Test/AutoFixture/GroupUserFixtures.cs +++ b/test/Core.Test/AutoFixture/GroupUserFixtures.cs @@ -1,17 +1,11 @@ using AutoFixture; using TableModel = Bit.Core.Models.Table; -using Bit.Core.Test.AutoFixture.Attributes; -using Bit.Core.Test.AutoFixture.GlobalSettingsFixtures; -using AutoMapper; -using Bit.Core.Models.EntityFramework; -using Bit.Core.Models; -using System.Collections.Generic; -using Bit.Core.Enums; using AutoFixture.Kernel; using System; -using Bit.Core.Test.AutoFixture.OrganizationFixtures; using Bit.Core.Repositories.EntityFramework; using Bit.Core.Test.AutoFixture.EntityFrameworkRepositoryFixtures; +using Bit.Test.Common.AutoFixture; +using Bit.Test.Common.AutoFixture.Attributes; namespace Bit.Core.Test.AutoFixture.GroupUserFixtures { diff --git a/test/Core.Test/AutoFixture/InstallationFixtures.cs b/test/Core.Test/AutoFixture/InstallationFixtures.cs index 8e1aa74ee..87980fa82 100644 --- a/test/Core.Test/AutoFixture/InstallationFixtures.cs +++ b/test/Core.Test/AutoFixture/InstallationFixtures.cs @@ -1,17 +1,11 @@ using AutoFixture; using TableModel = Bit.Core.Models.Table; -using Bit.Core.Test.AutoFixture.Attributes; -using Bit.Core.Test.AutoFixture.GlobalSettingsFixtures; -using AutoMapper; -using Bit.Core.Models.EntityFramework; -using Bit.Core.Models; -using System.Collections.Generic; -using Bit.Core.Enums; using AutoFixture.Kernel; using System; -using Bit.Core.Test.AutoFixture.OrganizationFixtures; using Bit.Core.Repositories.EntityFramework; using Bit.Core.Test.AutoFixture.EntityFrameworkRepositoryFixtures; +using Bit.Test.Common.AutoFixture; +using Bit.Test.Common.AutoFixture.Attributes; namespace Bit.Core.Test.AutoFixture.InstallationFixtures { diff --git a/test/Core.Test/AutoFixture/OrganizationFixtures.cs b/test/Core.Test/AutoFixture/OrganizationFixtures.cs index 2eb84ea6a..819ebeb85 100644 --- a/test/Core.Test/AutoFixture/OrganizationFixtures.cs +++ b/test/Core.Test/AutoFixture/OrganizationFixtures.cs @@ -7,13 +7,13 @@ using Bit.Core.Enums; using Bit.Core.Models.Business; using Bit.Core.Models.Data; using TableModel = Bit.Core.Models.Table; -using Bit.Core.Test.AutoFixture.Attributes; -using Bit.Core.Test.AutoFixture.GlobalSettingsFixtures; using Bit.Core.Utilities; using AutoFixture.Kernel; using Bit.Core.Models; using Bit.Core.Test.AutoFixture.EntityFrameworkRepositoryFixtures; using Bit.Core.Repositories.EntityFramework; +using Bit.Test.Common.AutoFixture.Attributes; +using Bit.Test.Common.AutoFixture; namespace Bit.Core.Test.AutoFixture.OrganizationFixtures { @@ -67,9 +67,9 @@ namespace Bit.Core.Test.AutoFixture.OrganizationFixtures public PlanType CheckedPlanType { get; set; } public void Customize(IFixture fixture) { - var validUpgradePlans = StaticStore.Plans.Where(p => p.Type != Enums.PlanType.Free && !p.Disabled).Select(p => p.Type).ToList(); + var validUpgradePlans = StaticStore.Plans.Where(p => p.Type != PlanType.Free && !p.Disabled).Select(p => p.Type).ToList(); var lowestActivePaidPlan = validUpgradePlans.First(); - CheckedPlanType = CheckedPlanType.Equals(Enums.PlanType.Free) ? lowestActivePaidPlan : CheckedPlanType; + CheckedPlanType = CheckedPlanType.Equals(PlanType.Free) ? lowestActivePaidPlan : CheckedPlanType; validUpgradePlans.Remove(lowestActivePaidPlan); fixture.Customize(composer => composer .With(o => o.PlanType, CheckedPlanType)); diff --git a/test/Core.Test/AutoFixture/OrganizationUserFixtures.cs b/test/Core.Test/AutoFixture/OrganizationUserFixtures.cs index f5e5256dd..1a083c2f3 100644 --- a/test/Core.Test/AutoFixture/OrganizationUserFixtures.cs +++ b/test/Core.Test/AutoFixture/OrganizationUserFixtures.cs @@ -1,9 +1,5 @@ using AutoFixture; using TableModel = Bit.Core.Models.Table; -using Bit.Core.Test.AutoFixture.Attributes; -using Bit.Core.Test.AutoFixture.GlobalSettingsFixtures; -using AutoMapper; -using Bit.Core.Models.EntityFramework; using Bit.Core.Models; using System.Collections.Generic; using Bit.Core.Enums; @@ -17,6 +13,8 @@ using System.Text.Json; using Bit.Core.Test.AutoFixture.UserFixtures; using AutoFixture.Xunit2; using System.Reflection; +using Bit.Test.Common.AutoFixture; +using Bit.Test.Common.AutoFixture.Attributes; namespace Bit.Core.Test.AutoFixture.OrganizationUserFixtures { diff --git a/test/Core.Test/AutoFixture/PolicyFixtures.cs b/test/Core.Test/AutoFixture/PolicyFixtures.cs index 868991693..71b2e30a7 100644 --- a/test/Core.Test/AutoFixture/PolicyFixtures.cs +++ b/test/Core.Test/AutoFixture/PolicyFixtures.cs @@ -2,14 +2,14 @@ using System.Reflection; using AutoFixture; using TableModel = Bit.Core.Models.Table; -using Bit.Core.Test.AutoFixture.Attributes; -using Bit.Core.Test.AutoFixture.GlobalSettingsFixtures; using Bit.Core.Enums; using AutoFixture.Kernel; using Bit.Core.Test.AutoFixture.OrganizationFixtures; using Bit.Core.Repositories.EntityFramework; using Bit.Core.Test.AutoFixture.EntityFrameworkRepositoryFixtures; using AutoFixture.Xunit2; +using Bit.Test.Common.AutoFixture; +using Bit.Test.Common.AutoFixture.Attributes; namespace Bit.Core.Test.AutoFixture.PolicyFixtures { diff --git a/test/Core.Test/AutoFixture/SendFixtures.cs b/test/Core.Test/AutoFixture/SendFixtures.cs index 1588837c6..17dee60ed 100644 --- a/test/Core.Test/AutoFixture/SendFixtures.cs +++ b/test/Core.Test/AutoFixture/SendFixtures.cs @@ -3,12 +3,12 @@ using AutoFixture; using AutoFixture.Kernel; using Bit.Core.Models.Table; using Bit.Core.Repositories.EntityFramework; -using Bit.Core.Test.AutoFixture.Attributes; using Bit.Core.Test.AutoFixture.EntityFrameworkRepositoryFixtures; -using Bit.Core.Test.AutoFixture.GlobalSettingsFixtures; using Bit.Core.Test.AutoFixture.OrganizationFixtures; using Bit.Core.Test.AutoFixture.Relays; using Bit.Core.Test.AutoFixture.UserFixtures; +using Bit.Test.Common.AutoFixture; +using Bit.Test.Common.AutoFixture.Attributes; namespace Bit.Core.Test.AutoFixture.SendFixtures { diff --git a/test/Core.Test/AutoFixture/SsoConfigFixtures.cs b/test/Core.Test/AutoFixture/SsoConfigFixtures.cs index 14e681af7..5ecbc247c 100644 --- a/test/Core.Test/AutoFixture/SsoConfigFixtures.cs +++ b/test/Core.Test/AutoFixture/SsoConfigFixtures.cs @@ -1,16 +1,14 @@ using System; using AutoFixture; using AutoFixture.Kernel; -using AutoMapper; using TableModel = Bit.Core.Models.Table; -using Bit.Core.Models.EntityFramework; -using Bit.Core.Test.AutoFixture.Attributes; -using Bit.Core.Test.AutoFixture.GlobalSettingsFixtures; using Bit.Core.Test.AutoFixture.OrganizationFixtures; using Bit.Core.Models.Data; using System.Text.Json; using Bit.Core.Test.AutoFixture.EntityFrameworkRepositoryFixtures; using Bit.Core.Repositories.EntityFramework; +using Bit.Test.Common.AutoFixture; +using Bit.Test.Common.AutoFixture.Attributes; namespace Bit.Core.Test.AutoFixture.SsoConfigFixtures { diff --git a/test/Core.Test/AutoFixture/SsoUserFixtures.cs b/test/Core.Test/AutoFixture/SsoUserFixtures.cs index bb756a73b..9dc452466 100644 --- a/test/Core.Test/AutoFixture/SsoUserFixtures.cs +++ b/test/Core.Test/AutoFixture/SsoUserFixtures.cs @@ -1,18 +1,16 @@ using AutoFixture; -using AutoMapper; -using Bit.Core.Models.EntityFramework; using Bit.Core.Repositories.EntityFramework; -using Bit.Core.Test.AutoFixture.Attributes; using Bit.Core.Test.AutoFixture.EntityFrameworkRepositoryFixtures; -using Bit.Core.Test.AutoFixture.GlobalSettingsFixtures; using Bit.Core.Test.AutoFixture.OrganizationFixtures; using Bit.Core.Test.AutoFixture.UserFixtures; +using Bit.Test.Common.AutoFixture; +using Bit.Test.Common.AutoFixture.Attributes; using TableModel = Bit.Core.Models.Table; namespace Bit.Core.Test.AutoFixture.SsoUserFixtures { - internal class EfSsoUser: ICustomization - { + internal class EfSsoUser : ICustomization + { public void Customize(IFixture fixture) { fixture.Customizations.Add(new IgnoreVirtualMembersCustomization()); diff --git a/test/Core.Test/AutoFixture/TaxRateFixtures.cs b/test/Core.Test/AutoFixture/TaxRateFixtures.cs index b0a94eacc..d1e89fa5d 100644 --- a/test/Core.Test/AutoFixture/TaxRateFixtures.cs +++ b/test/Core.Test/AutoFixture/TaxRateFixtures.cs @@ -1,18 +1,12 @@ using AutoFixture; using TableModel = Bit.Core.Models.Table; -using Bit.Core.Test.AutoFixture.Attributes; -using Bit.Core.Test.AutoFixture.GlobalSettingsFixtures; -using AutoMapper; -using Bit.Core.Models.EntityFramework; -using Bit.Core.Models; -using System.Collections.Generic; -using Bit.Core.Enums; using AutoFixture.Kernel; using System; -using Bit.Core.Test.AutoFixture.OrganizationFixtures; using Bit.Core.Repositories.EntityFramework; using Bit.Core.Test.AutoFixture.EntityFrameworkRepositoryFixtures; using Bit.Core.Test.AutoFixture.Relays; +using Bit.Test.Common.AutoFixture; +using Bit.Test.Common.AutoFixture.Attributes; namespace Bit.Core.Test.AutoFixture.TaxRateFixtures { diff --git a/test/Core.Test/AutoFixture/TransactionFixutres.cs b/test/Core.Test/AutoFixture/TransactionFixutres.cs index e2660c8c7..0610ced02 100644 --- a/test/Core.Test/AutoFixture/TransactionFixutres.cs +++ b/test/Core.Test/AutoFixture/TransactionFixutres.cs @@ -1,12 +1,6 @@ using AutoFixture; using TableModel = Bit.Core.Models.Table; -using Bit.Core.Test.AutoFixture.Attributes; -using Bit.Core.Test.AutoFixture.GlobalSettingsFixtures; -using AutoMapper; using Bit.Core.Models.EntityFramework; -using Bit.Core.Models; -using System.Collections.Generic; -using Bit.Core.Enums; using AutoFixture.Kernel; using System; using Bit.Core.Test.AutoFixture.OrganizationFixtures; @@ -14,6 +8,8 @@ using Bit.Core.Repositories.EntityFramework; using Bit.Core.Test.AutoFixture.EntityFrameworkRepositoryFixtures; using Bit.Core.Test.AutoFixture.UserFixtures; using Bit.Core.Test.AutoFixture.Relays; +using Bit.Test.Common.AutoFixture; +using Bit.Test.Common.AutoFixture.Attributes; namespace Bit.Core.Test.AutoFixture.TransactionFixtures { diff --git a/test/Core.Test/AutoFixture/U2fFixtures.cs b/test/Core.Test/AutoFixture/U2fFixtures.cs index d813fd20e..78fac0c4d 100644 --- a/test/Core.Test/AutoFixture/U2fFixtures.cs +++ b/test/Core.Test/AutoFixture/U2fFixtures.cs @@ -1,19 +1,13 @@ using AutoFixture; using TableModel = Bit.Core.Models.Table; -using Bit.Core.Test.AutoFixture.Attributes; -using Bit.Core.Test.AutoFixture.GlobalSettingsFixtures; -using AutoMapper; -using Bit.Core.Models.EntityFramework; -using Bit.Core.Models; -using System.Collections.Generic; -using Bit.Core.Enums; using AutoFixture.Kernel; using System; -using Bit.Core.Test.AutoFixture.OrganizationFixtures; using Bit.Core.Repositories.EntityFramework; using Bit.Core.Test.AutoFixture.EntityFrameworkRepositoryFixtures; using Bit.Core.Test.AutoFixture.Relays; using Bit.Core.Test.AutoFixture.UserFixtures; +using Bit.Test.Common.AutoFixture; +using Bit.Test.Common.AutoFixture.Attributes; namespace Bit.Core.Test.AutoFixture.U2fFixtures { diff --git a/test/Core.Test/AutoFixture/UserFixtures.cs b/test/Core.Test/AutoFixture/UserFixtures.cs index fb9a3e27c..1608db151 100644 --- a/test/Core.Test/AutoFixture/UserFixtures.cs +++ b/test/Core.Test/AutoFixture/UserFixtures.cs @@ -1,7 +1,5 @@ using AutoFixture; using TableModel = Bit.Core.Models.Table; -using Bit.Core.Test.AutoFixture.Attributes; -using Bit.Core.Test.AutoFixture.GlobalSettingsFixtures; using Bit.Core.Models; using System.Collections.Generic; using Bit.Core.Enums; @@ -10,6 +8,8 @@ using System; using Bit.Core.Test.AutoFixture.OrganizationFixtures; using Bit.Core.Repositories.EntityFramework; using Bit.Core.Test.AutoFixture.EntityFrameworkRepositoryFixtures; +using Bit.Test.Common.AutoFixture.Attributes; +using Bit.Test.Common.AutoFixture; namespace Bit.Core.Test.AutoFixture.UserFixtures { diff --git a/test/Core.Test/Core.Test.csproj b/test/Core.Test/Core.Test.csproj index 45c44fa1b..725a51d4c 100644 --- a/test/Core.Test/Core.Test.csproj +++ b/test/Core.Test/Core.Test.csproj @@ -25,6 +25,7 @@ + diff --git a/test/Core.Test/Helpers/Factories.cs b/test/Core.Test/Helpers/Factories.cs index 61469a543..56092122d 100644 --- a/test/Core.Test/Helpers/Factories.cs +++ b/test/Core.Test/Helpers/Factories.cs @@ -1,22 +1,12 @@ using System.Collections.Generic; using Bit.Core.Repositories.EntityFramework; using Bit.Core.Settings; +using Bit.Test.Common.Helpers.Factories; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; namespace Bit.Core.Test.Helpers.Factories { - public static class GlobalSettingsFactory - { - public static GlobalSettings GlobalSettings { get; } = new GlobalSettings(); - static GlobalSettingsFactory() - { - var configBuilder = new ConfigurationBuilder().AddUserSecrets(); - var Configuration = configBuilder.Build(); - ConfigurationBinder.Bind(Configuration.GetSection("GlobalSettings"), GlobalSettings); - } - } - public static class DatabaseOptionsFactory { public static List> Options { get; } = new List>(); diff --git a/test/Core.Test/Services/CipherServiceTests.cs b/test/Core.Test/Services/CipherServiceTests.cs index 94aa49863..45e1f189f 100644 --- a/test/Core.Test/Services/CipherServiceTests.cs +++ b/test/Core.Test/Services/CipherServiceTests.cs @@ -9,9 +9,9 @@ using Bit.Core.Models.Table; using Core.Models.Data; using Bit.Core.Test.AutoFixture.CipherFixtures; using System.Collections.Generic; -using Bit.Core.Test.AutoFixture; using System.Linq; using Castle.Core.Internal; +using Bit.Test.Common.AutoFixture; namespace Bit.Core.Test.Services { diff --git a/test/Core.Test/Services/CollectionServiceTests.cs b/test/Core.Test/Services/CollectionServiceTests.cs index b1748e858..727621690 100644 --- a/test/Core.Test/Services/CollectionServiceTests.cs +++ b/test/Core.Test/Services/CollectionServiceTests.cs @@ -7,9 +7,9 @@ using Bit.Core.Models.Data; using Bit.Core.Models.Table; using Bit.Core.Repositories; using Bit.Core.Services; -using Bit.Core.Test.AutoFixture; -using Bit.Core.Test.AutoFixture.Attributes; using Bit.Core.Test.AutoFixture.CollectionFixtures; +using Bit.Test.Common.AutoFixture; +using Bit.Test.Common.AutoFixture.Attributes; using NSubstitute; using Xunit; diff --git a/test/Core.Test/Services/DeviceServiceTests.cs b/test/Core.Test/Services/DeviceServiceTests.cs index dd125759b..413648634 100644 --- a/test/Core.Test/Services/DeviceServiceTests.cs +++ b/test/Core.Test/Services/DeviceServiceTests.cs @@ -1,5 +1,6 @@ using System; using System.Threading.Tasks; +using Bit.Core.Enums; using Bit.Core.Models.Table; using Bit.Core.Repositories; using Bit.Core.Services; @@ -23,7 +24,7 @@ namespace Bit.Core.Test.Services { Id = id, Name = "test device", - Type = Enums.DeviceType.Android, + Type = DeviceType.Android, UserId = userId, PushToken = "testtoken", Identifier = "testid" @@ -32,7 +33,7 @@ namespace Bit.Core.Test.Services Assert.True(device.RevisionDate - DateTime.UtcNow < TimeSpan.FromSeconds(1)); await pushRepo.Received().CreateOrUpdateRegistrationAsync("testtoken", id.ToString(), - userId.ToString(), "testid", Enums.DeviceType.Android); + userId.ToString(), "testid", DeviceType.Android); } } } diff --git a/test/Core.Test/Services/GroupServiceTests.cs b/test/Core.Test/Services/GroupServiceTests.cs index 3b8467ce3..04ddf20ce 100644 --- a/test/Core.Test/Services/GroupServiceTests.cs +++ b/test/Core.Test/Services/GroupServiceTests.cs @@ -10,6 +10,8 @@ using Bit.Core.Services; using Bit.Core.Test.AutoFixture; using Bit.Core.Test.AutoFixture.Attributes; using Bit.Core.Test.AutoFixture.GroupFixtures; +using Bit.Test.Common.AutoFixture; +using Bit.Test.Common.AutoFixture.Attributes; using NSubstitute; using Xunit; diff --git a/test/Core.Test/Services/LocalAttachmentStorageServiceTests.cs b/test/Core.Test/Services/LocalAttachmentStorageServiceTests.cs index e70495d47..386bc2bee 100644 --- a/test/Core.Test/Services/LocalAttachmentStorageServiceTests.cs +++ b/test/Core.Test/Services/LocalAttachmentStorageServiceTests.cs @@ -4,8 +4,6 @@ using Bit.Core.Settings; using NSubstitute; using Xunit; using System.IO; -using Bit.Core.Test.AutoFixture.Attributes; -using Bit.Core.Test.AutoFixture; using Bit.Core.Test.AutoFixture.CipherFixtures; using Bit.Core.Models.Data; using System.Threading.Tasks; @@ -13,6 +11,8 @@ using Bit.Core.Models.Table; using U2F.Core.Utils; using Bit.Core.Test.AutoFixture.CipherAttachmentMetaData; using AutoFixture; +using Bit.Test.Common.AutoFixture.Attributes; +using Bit.Test.Common.AutoFixture; namespace Bit.Core.Test.Services { diff --git a/test/Core.Test/Services/OrganizationServiceTests.cs b/test/Core.Test/Services/OrganizationServiceTests.cs index c9e74b93f..3bd77b8e8 100644 --- a/test/Core.Test/Services/OrganizationServiceTests.cs +++ b/test/Core.Test/Services/OrganizationServiceTests.cs @@ -9,10 +9,8 @@ using Bit.Core.Repositories; using Bit.Core.Services; using NSubstitute; using Xunit; -using Bit.Core.Test.AutoFixture; using Bit.Core.Exceptions; using Bit.Core.Enums; -using Bit.Core.Test.AutoFixture.Attributes; using Bit.Core.Test.AutoFixture.OrganizationFixtures; using System.Text.Json; using Bit.Core.Context; @@ -22,7 +20,8 @@ using OrganizationUser = Bit.Core.Models.Table.OrganizationUser; using Policy = Bit.Core.Models.Table.Policy; using Bit.Core.Test.AutoFixture.PolicyFixtures; using Bit.Core.Settings; -using AutoFixture.Xunit2; +using Bit.Test.Common.AutoFixture; +using Bit.Test.Common.AutoFixture.Attributes; namespace Bit.Core.Test.Services { diff --git a/test/Core.Test/Services/PolicyServiceTests.cs b/test/Core.Test/Services/PolicyServiceTests.cs index e1fd3f7c5..06185c39b 100644 --- a/test/Core.Test/Services/PolicyServiceTests.cs +++ b/test/Core.Test/Services/PolicyServiceTests.cs @@ -5,19 +5,19 @@ using Bit.Core.Exceptions; using Bit.Core.Models.Table; using Bit.Core.Repositories; using Bit.Core.Services; -using Bit.Core.Test.AutoFixture; -using Bit.Core.Test.AutoFixture.Attributes; -using Bit.Core.Test.AutoFixture.OrganizationUserFixtures; using PolicyFixtures = Bit.Core.Test.AutoFixture.PolicyFixtures; using NSubstitute; using Xunit; +using Bit.Core.Enums; +using Bit.Test.Common.AutoFixture.Attributes; +using Bit.Test.Common.AutoFixture; namespace Bit.Core.Test.Services { public class PolicyServiceTests { [Theory, CustomAutoData(typeof(SutProviderCustomization))] - public async Task SaveAsync_OrganizationDoesNotExist_ThrowsBadRequest([PolicyFixtures.Policy(Enums.PolicyType.DisableSend)] Core.Models.Table.Policy policy, SutProvider sutProvider) + public async Task SaveAsync_OrganizationDoesNotExist_ThrowsBadRequest([PolicyFixtures.Policy(PolicyType.DisableSend)] Core.Models.Table.Policy policy, SutProvider sutProvider) { SetupOrg(sutProvider, policy.OrganizationId, null); @@ -39,7 +39,7 @@ namespace Bit.Core.Test.Services } [Theory, CustomAutoData(typeof(SutProviderCustomization))] - public async Task SaveAsync_OrganizationCannotUsePolicies_ThrowsBadRequest([PolicyFixtures.Policy(Enums.PolicyType.DisableSend)] Core.Models.Table.Policy policy, SutProvider sutProvider) + public async Task SaveAsync_OrganizationCannotUsePolicies_ThrowsBadRequest([PolicyFixtures.Policy(PolicyType.DisableSend)] Core.Models.Table.Policy policy, SutProvider sutProvider) { var orgId = Guid.NewGuid(); @@ -66,7 +66,7 @@ namespace Bit.Core.Test.Services } [Theory, CustomAutoData(typeof(SutProviderCustomization))] - public async Task SaveAsync_SingleOrg_RequireSsoEnabled_ThrowsBadRequest([PolicyFixtures.Policy(Enums.PolicyType.SingleOrg)] Core.Models.Table.Policy policy, SutProvider sutProvider) + public async Task SaveAsync_SingleOrg_RequireSsoEnabled_ThrowsBadRequest([PolicyFixtures.Policy(PolicyType.SingleOrg)] Core.Models.Table.Policy policy, SutProvider sutProvider) { policy.Enabled = false; @@ -77,7 +77,7 @@ namespace Bit.Core.Test.Services }); sutProvider.GetDependency() - .GetByOrganizationIdTypeAsync(policy.OrganizationId, Enums.PolicyType.RequireSso) + .GetByOrganizationIdTypeAsync(policy.OrganizationId, PolicyType.RequireSso) .Returns(Task.FromResult(new Core.Models.Table.Policy { Enabled = true })); var badRequestException = await Assert.ThrowsAsync( @@ -126,7 +126,7 @@ namespace Bit.Core.Test.Services } [Theory, CustomAutoData(typeof(SutProviderCustomization))] - public async Task SaveAsync_RequireSsoPolicy_NotEnabled_ThrowsBadRequestAsync([PolicyFixtures.Policy(Enums.PolicyType.RequireSso)] Core.Models.Table.Policy policy, SutProvider sutProvider) + public async Task SaveAsync_RequireSsoPolicy_NotEnabled_ThrowsBadRequestAsync([PolicyFixtures.Policy(PolicyType.RequireSso)] Core.Models.Table.Policy policy, SutProvider sutProvider) { policy.Enabled = true; @@ -137,7 +137,7 @@ namespace Bit.Core.Test.Services }); sutProvider.GetDependency() - .GetByOrganizationIdTypeAsync(policy.OrganizationId, Enums.PolicyType.SingleOrg) + .GetByOrganizationIdTypeAsync(policy.OrganizationId, PolicyType.SingleOrg) .Returns(Task.FromResult(new Core.Models.Table.Policy { Enabled = false })); var badRequestException = await Assert.ThrowsAsync( @@ -158,7 +158,7 @@ namespace Bit.Core.Test.Services } [Theory, CustomAutoData(typeof(SutProviderCustomization))] - public async Task SaveAsync_NewPolicy_Created([PolicyFixtures.Policy(Enums.PolicyType.MasterPassword)] Core.Models.Table.Policy policy, SutProvider sutProvider) + public async Task SaveAsync_NewPolicy_Created([PolicyFixtures.Policy(PolicyType.MasterPassword)] Core.Models.Table.Policy policy, SutProvider sutProvider) { policy.Id = default; @@ -173,7 +173,7 @@ namespace Bit.Core.Test.Services await sutProvider.Sut.SaveAsync(policy, Substitute.For(), Substitute.For(), Guid.NewGuid()); await sutProvider.GetDependency().Received() - .LogPolicyEventAsync(policy, Enums.EventType.Policy_Updated); + .LogPolicyEventAsync(policy, EventType.Policy_Updated); await sutProvider.GetDependency().Received() .UpsertAsync(policy); @@ -215,7 +215,7 @@ namespace Bit.Core.Test.Services } [Theory, CustomAutoData(typeof(SutProviderCustomization))] - public async Task SaveAsync_ExistingPolicy_UpdateTwoFactor([PolicyFixtures.Policy(Enums.PolicyType.TwoFactorAuthentication)] Core.Models.Table.Policy policy, SutProvider sutProvider) + public async Task SaveAsync_ExistingPolicy_UpdateTwoFactor([PolicyFixtures.Policy(PolicyType.TwoFactorAuthentication)] Core.Models.Table.Policy policy, SutProvider sutProvider) { // If the policy that this is updating isn't enabled then do some work now that the current one is enabled @@ -233,15 +233,15 @@ namespace Bit.Core.Test.Services .Returns(new Core.Models.Table.Policy { Id = policy.Id, - Type = Enums.PolicyType.TwoFactorAuthentication, + Type = PolicyType.TwoFactorAuthentication, Enabled = false, }); var orgUserDetail = new Core.Models.Data.OrganizationUserUserDetails { Id = Guid.NewGuid(), - Status = Enums.OrganizationUserStatusType.Accepted, - Type = Enums.OrganizationUserType.User, + Status = OrganizationUserStatusType.Accepted, + Type = OrganizationUserType.User, // Needs to be different from what is passed in as the savingUserId to Sut.SaveAsync Email = "test@bitwarden.com", Name = "TEST", @@ -274,7 +274,7 @@ namespace Bit.Core.Test.Services .SendOrganizationUserRemovedForPolicyTwoStepEmailAsync(org.Name, orgUserDetail.Email); await sutProvider.GetDependency().Received() - .LogPolicyEventAsync(policy, Enums.EventType.Policy_Updated); + .LogPolicyEventAsync(policy, EventType.Policy_Updated); await sutProvider.GetDependency().Received() .UpsertAsync(policy); @@ -284,7 +284,7 @@ namespace Bit.Core.Test.Services } [Theory, CustomAutoData(typeof(SutProviderCustomization))] - public async Task SaveAsync_ExistingPolicy_UpdateSingleOrg([PolicyFixtures.Policy(Enums.PolicyType.TwoFactorAuthentication)] Core.Models.Table.Policy policy, SutProvider sutProvider) + public async Task SaveAsync_ExistingPolicy_UpdateSingleOrg([PolicyFixtures.Policy(PolicyType.TwoFactorAuthentication)] Core.Models.Table.Policy policy, SutProvider sutProvider) { // If the policy that this is updating isn't enabled then do some work now that the current one is enabled @@ -302,15 +302,15 @@ namespace Bit.Core.Test.Services .Returns(new Core.Models.Table.Policy { Id = policy.Id, - Type = Enums.PolicyType.SingleOrg, + Type = PolicyType.SingleOrg, Enabled = false, }); var orgUserDetail = new Core.Models.Data.OrganizationUserUserDetails { Id = Guid.NewGuid(), - Status = Enums.OrganizationUserStatusType.Accepted, - Type = Enums.OrganizationUserType.User, + Status = OrganizationUserStatusType.Accepted, + Type = OrganizationUserType.User, // Needs to be different from what is passed in as the savingUserId to Sut.SaveAsync Email = "test@bitwarden.com", Name = "TEST", @@ -337,7 +337,7 @@ namespace Bit.Core.Test.Services await sutProvider.Sut.SaveAsync(policy, userService, organizationService, savingUserId); await sutProvider.GetDependency().Received() - .LogPolicyEventAsync(policy, Enums.EventType.Policy_Updated); + .LogPolicyEventAsync(policy, EventType.Policy_Updated); await sutProvider.GetDependency().Received() .UpsertAsync(policy); diff --git a/test/Core.Test/Services/SendServiceTests.cs b/test/Core.Test/Services/SendServiceTests.cs index b18733edc..7c08f6d00 100644 --- a/test/Core.Test/Services/SendServiceTests.cs +++ b/test/Core.Test/Services/SendServiceTests.cs @@ -1,21 +1,19 @@ using System; using System.Collections.Generic; -using System.IO; -using System.Text; -using System.Text.Json; -using System.Linq; -using Bit.Core.Context; using Bit.Core.Enums; using Bit.Core.Exceptions; using Bit.Core.Models.Data; using Bit.Core.Models.Table; using Bit.Core.Repositories; using Bit.Core.Services; -using Bit.Core.Test.AutoFixture; using Bit.Core.Test.AutoFixture.SendFixtures; using Microsoft.AspNetCore.Identity; using NSubstitute; using Xunit; +using System.Text.Json; +using Bit.Test.Common.AutoFixture; +using System.IO; +using System.Text; namespace Bit.Core.Test.Services { diff --git a/test/Core.Test/Services/SsoConfigServiceTests.cs b/test/Core.Test/Services/SsoConfigServiceTests.cs index 403df8dac..c9b1baaab 100644 --- a/test/Core.Test/Services/SsoConfigServiceTests.cs +++ b/test/Core.Test/Services/SsoConfigServiceTests.cs @@ -3,8 +3,8 @@ using System.Threading.Tasks; using Bit.Core.Models.Table; using Bit.Core.Repositories; using Bit.Core.Services; -using Bit.Core.Test.AutoFixture; -using Bit.Core.Test.AutoFixture.Attributes; +using Bit.Test.Common.AutoFixture; +using Bit.Test.Common.AutoFixture.Attributes; using NSubstitute; using Xunit; diff --git a/test/Core.Test/Utilities/CoreHelpersTests.cs b/test/Core.Test/Utilities/CoreHelpersTests.cs index cf43aa13b..f793a41f6 100644 --- a/test/Core.Test/Utilities/CoreHelpersTests.cs +++ b/test/Core.Test/Utilities/CoreHelpersTests.cs @@ -3,15 +3,15 @@ using System.Collections.Generic; using System.Linq; using Bit.Core.Utilities; using Xunit; -using Bit.Core.Test.AutoFixture.Attributes; using Bit.Core.Test.AutoFixture.UserFixtures; using IdentityModel; using Bit.Core.Enums.Provider; using Bit.Core.Models.Table; using Bit.Core.Context; using AutoFixture; -using Bit.Core.Test.AutoFixture; using Bit.Core.Enums; +using Bit.Test.Common.AutoFixture.Attributes; +using Bit.Test.Common.AutoFixture; namespace Bit.Core.Test.Utilities { diff --git a/test/bitwarden.tests.sln b/test/bitwarden.tests.sln index 8968eea3d..cd5f7820f 100644 --- a/test/bitwarden.tests.sln +++ b/test/bitwarden.tests.sln @@ -9,6 +9,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Icons.Test", "Icons.Test\Ic EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Api.Test", "Api.Test\Api.Test.csproj", "{2B29139A-E3B5-4A44-8A85-1593ACB797CC}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Common", "Common\Common.csproj", "{E94B2922-EE05-435C-9472-FDEFEAD0AA37}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -58,5 +60,17 @@ Global {2B29139A-E3B5-4A44-8A85-1593ACB797CC}.Release|x64.Build.0 = Release|Any CPU {2B29139A-E3B5-4A44-8A85-1593ACB797CC}.Release|x86.ActiveCfg = Release|Any CPU {2B29139A-E3B5-4A44-8A85-1593ACB797CC}.Release|x86.Build.0 = Release|Any CPU + {E94B2922-EE05-435C-9472-FDEFEAD0AA37}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E94B2922-EE05-435C-9472-FDEFEAD0AA37}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E94B2922-EE05-435C-9472-FDEFEAD0AA37}.Debug|x64.ActiveCfg = Debug|Any CPU + {E94B2922-EE05-435C-9472-FDEFEAD0AA37}.Debug|x64.Build.0 = Debug|Any CPU + {E94B2922-EE05-435C-9472-FDEFEAD0AA37}.Debug|x86.ActiveCfg = Debug|Any CPU + {E94B2922-EE05-435C-9472-FDEFEAD0AA37}.Debug|x86.Build.0 = Debug|Any CPU + {E94B2922-EE05-435C-9472-FDEFEAD0AA37}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E94B2922-EE05-435C-9472-FDEFEAD0AA37}.Release|Any CPU.Build.0 = Release|Any CPU + {E94B2922-EE05-435C-9472-FDEFEAD0AA37}.Release|x64.ActiveCfg = Release|Any CPU + {E94B2922-EE05-435C-9472-FDEFEAD0AA37}.Release|x64.Build.0 = Release|Any CPU + {E94B2922-EE05-435C-9472-FDEFEAD0AA37}.Release|x86.ActiveCfg = Release|Any CPU + {E94B2922-EE05-435C-9472-FDEFEAD0AA37}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection EndGlobal