mirror of
https://github.com/bitwarden/server.git
synced 2024-11-28 13:15:12 +01:00
Feature/bit auto data (#2219)
* Update ProviderService tests * Use BitAutoData in CipherService tests * Simplify UserCipher fixture Because we use a single customizer for all ciphers, they all have the same userId. * Clean up more cipher fixtures * Swap Cipher Fixtures to BitCustomizeAttribute * Clean up collection fixtures * Clean up GroupFixtures * Move SendService Tests to BitAutoData * Clean up Organization Fixtures TODO: The customize attributes should not be customizing more than one class * Name files after the class they contain * Clear up usage of CustomAutoDataAttribute in tests * Clean up usages of InlineCustomAutoData * format * Manually merge with file-scoped-namespace changes
This commit is contained in:
parent
2d9d6ad812
commit
a6d97118fa
@ -114,7 +114,7 @@ csharp_new_line_before_finally = true
|
||||
csharp_new_line_before_members_in_object_initializers = true
|
||||
csharp_new_line_before_members_in_anonymous_types = true
|
||||
|
||||
# Namespace settigns
|
||||
# Namespace settings
|
||||
csharp_style_namespace_declarations = file_scoped:warning
|
||||
|
||||
# All files
|
||||
|
@ -21,9 +21,10 @@ using ProviderUser = Bit.Core.Entities.Provider.ProviderUser;
|
||||
|
||||
namespace Bit.Commercial.Core.Test.Services;
|
||||
|
||||
[SutProviderCustomize]
|
||||
public class ProviderServiceTests
|
||||
{
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task CreateAsync_UserIdIsInvalid_Throws(SutProvider<ProviderService> sutProvider)
|
||||
{
|
||||
var exception = await Assert.ThrowsAsync<BadRequestException>(
|
||||
@ -31,7 +32,7 @@ public class ProviderServiceTests
|
||||
Assert.Contains("Invalid owner.", exception.Message);
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task CreateAsync_Success(User user, SutProvider<ProviderService> sutProvider)
|
||||
{
|
||||
var userRepository = sutProvider.GetDependency<IUserRepository>();
|
||||
@ -43,7 +44,7 @@ public class ProviderServiceTests
|
||||
await sutProvider.GetDependency<IMailService>().ReceivedWithAnyArgs().SendProviderSetupInviteEmailAsync(default, default, default);
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task CompleteSetupAsync_UserIdIsInvalid_Throws(SutProvider<ProviderService> sutProvider)
|
||||
{
|
||||
var exception = await Assert.ThrowsAsync<BadRequestException>(
|
||||
@ -51,7 +52,7 @@ public class ProviderServiceTests
|
||||
Assert.Contains("Invalid owner.", exception.Message);
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task CompleteSetupAsync_TokenIsInvalid_Throws(User user, Provider provider,
|
||||
SutProvider<ProviderService> sutProvider)
|
||||
{
|
||||
@ -63,7 +64,7 @@ public class ProviderServiceTests
|
||||
Assert.Contains("Invalid token.", exception.Message);
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task CompleteSetupAsync_Success(User user, Provider provider, string key,
|
||||
[ProviderUser(ProviderUserStatusType.Confirmed, ProviderUserType.ProviderAdmin)] ProviderUser providerUser,
|
||||
SutProvider<ProviderService> sutProvider)
|
||||
@ -91,7 +92,7 @@ public class ProviderServiceTests
|
||||
.ReplaceAsync(Arg.Is<ProviderUser>(pu => pu.UserId == user.Id && pu.ProviderId == provider.Id && pu.Key == key));
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task UpdateAsync_ProviderIdIsInvalid_Throws(Provider provider, SutProvider<ProviderService> sutProvider)
|
||||
{
|
||||
provider.Id = default;
|
||||
@ -101,13 +102,13 @@ public class ProviderServiceTests
|
||||
Assert.Contains("Cannot create provider this way.", exception.Message);
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task UpdateAsync_Success(Provider provider, SutProvider<ProviderService> sutProvider)
|
||||
{
|
||||
await sutProvider.Sut.UpdateAsync(provider);
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task InviteUserAsync_ProviderIdIsInvalid_Throws(ProviderUserInvite<string> invite, SutProvider<ProviderService> sutProvider)
|
||||
{
|
||||
sutProvider.GetDependency<ICurrentContext>().ProviderManageUsers(invite.ProviderId).Returns(true);
|
||||
@ -115,14 +116,14 @@ public class ProviderServiceTests
|
||||
await Assert.ThrowsAsync<NotFoundException>(() => sutProvider.Sut.InviteUserAsync(invite));
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task InviteUserAsync_InvalidPermissions_Throws(ProviderUserInvite<string> invite, SutProvider<ProviderService> sutProvider)
|
||||
{
|
||||
sutProvider.GetDependency<ICurrentContext>().ProviderManageUsers(invite.ProviderId).Returns(false);
|
||||
await Assert.ThrowsAsync<InvalidOperationException>(() => sutProvider.Sut.InviteUserAsync(invite));
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task InviteUserAsync_EmailsInvalid_Throws(Provider provider, ProviderUserInvite<string> providerUserInvite,
|
||||
SutProvider<ProviderService> sutProvider)
|
||||
{
|
||||
@ -135,7 +136,7 @@ public class ProviderServiceTests
|
||||
await Assert.ThrowsAsync<NotFoundException>(() => sutProvider.Sut.InviteUserAsync(providerUserInvite));
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task InviteUserAsync_AlreadyInvited(Provider provider, ProviderUserInvite<string> providerUserInvite,
|
||||
SutProvider<ProviderService> sutProvider)
|
||||
{
|
||||
@ -149,7 +150,7 @@ public class ProviderServiceTests
|
||||
Assert.Empty(result);
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task InviteUserAsync_Success(Provider provider, ProviderUserInvite<string> providerUserInvite,
|
||||
SutProvider<ProviderService> sutProvider)
|
||||
{
|
||||
@ -165,14 +166,14 @@ public class ProviderServiceTests
|
||||
Assert.True(result.TrueForAll(pu => pu.ProviderId == providerUserInvite.ProviderId), "Provider Id must be correct");
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task ResendInviteUserAsync_InvalidPermissions_Throws(ProviderUserInvite<Guid> invite, SutProvider<ProviderService> sutProvider)
|
||||
{
|
||||
sutProvider.GetDependency<ICurrentContext>().ProviderManageUsers(invite.ProviderId).Returns(false);
|
||||
await Assert.ThrowsAsync<BadRequestException>(() => sutProvider.Sut.ResendInvitesAsync(invite));
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task ResendInvitesAsync_Errors(Provider provider,
|
||||
[ProviderUser(ProviderUserStatusType.Invited)] ProviderUser pu1,
|
||||
[ProviderUser(ProviderUserStatusType.Accepted)] ProviderUser pu2,
|
||||
@ -202,7 +203,7 @@ public class ProviderServiceTests
|
||||
Assert.Equal("User invalid.", result[3].Item2);
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task ResendInvitesAsync_Success(Provider provider, IEnumerable<ProviderUser> providerUsers,
|
||||
SutProvider<ProviderService> sutProvider)
|
||||
{
|
||||
@ -228,7 +229,7 @@ public class ProviderServiceTests
|
||||
Assert.True(result.All(r => r.Item2 == ""));
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task AcceptUserAsync_UserIsInvalid_Throws(SutProvider<ProviderService> sutProvider)
|
||||
{
|
||||
var exception = await Assert.ThrowsAsync<BadRequestException>(
|
||||
@ -236,7 +237,7 @@ public class ProviderServiceTests
|
||||
Assert.Equal("User invalid.", exception.Message);
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task AcceptUserAsync_AlreadyAccepted_Throws(
|
||||
[ProviderUser(ProviderUserStatusType.Accepted)] ProviderUser providerUser, User user,
|
||||
SutProvider<ProviderService> sutProvider)
|
||||
@ -249,7 +250,7 @@ public class ProviderServiceTests
|
||||
Assert.Equal("Already accepted.", exception.Message);
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task AcceptUserAsync_TokenIsInvalid_Throws(
|
||||
[ProviderUser(ProviderUserStatusType.Invited)] ProviderUser providerUser, User user,
|
||||
SutProvider<ProviderService> sutProvider)
|
||||
@ -262,7 +263,7 @@ public class ProviderServiceTests
|
||||
Assert.Equal("Invalid token.", exception.Message);
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task AcceptUserAsync_WrongEmail_Throws(
|
||||
[ProviderUser(ProviderUserStatusType.Invited)] ProviderUser providerUser, User user,
|
||||
SutProvider<ProviderService> sutProvider)
|
||||
@ -283,7 +284,7 @@ public class ProviderServiceTests
|
||||
Assert.Equal("User email does not match invite.", exception.Message);
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task AcceptUserAsync_Success(
|
||||
[ProviderUser(ProviderUserStatusType.Invited)] ProviderUser providerUser, User user,
|
||||
SutProvider<ProviderService> sutProvider)
|
||||
@ -306,7 +307,7 @@ public class ProviderServiceTests
|
||||
Assert.Equal(user.Id, pu.UserId);
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task ConfirmUsersAsync_NoValid(
|
||||
[ProviderUser(ProviderUserStatusType.Invited)] ProviderUser pu1,
|
||||
[ProviderUser(ProviderUserStatusType.Accepted)] ProviderUser pu2,
|
||||
@ -324,7 +325,7 @@ public class ProviderServiceTests
|
||||
Assert.Empty(result);
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task ConfirmUsersAsync_Success(
|
||||
[ProviderUser(ProviderUserStatusType.Invited)] ProviderUser pu1, User u1,
|
||||
[ProviderUser(ProviderUserStatusType.Accepted)] ProviderUser pu2, User u2,
|
||||
@ -352,7 +353,7 @@ public class ProviderServiceTests
|
||||
Assert.Equal("Invalid user.", result[2].Item2);
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task SaveUserAsync_UserIdIsInvalid_Throws(ProviderUser providerUser,
|
||||
SutProvider<ProviderService> sutProvider)
|
||||
{
|
||||
@ -362,7 +363,7 @@ public class ProviderServiceTests
|
||||
Assert.Equal("Invite the user first.", exception.Message);
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task SaveUserAsync_Success(
|
||||
[ProviderUser(type: ProviderUserType.ProviderAdmin)] ProviderUser providerUser, User savingUser,
|
||||
SutProvider<ProviderService> sutProvider)
|
||||
@ -376,7 +377,7 @@ public class ProviderServiceTests
|
||||
.LogProviderUserEventAsync(providerUser, EventType.ProviderUser_Updated, null);
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task DeleteUsersAsync_NoRemainingOwner_Throws(Provider provider, User deletingUser,
|
||||
ICollection<ProviderUser> providerUsers, SutProvider<ProviderService> sutProvider)
|
||||
{
|
||||
@ -399,7 +400,7 @@ public class ProviderServiceTests
|
||||
Assert.Equal("Provider must have at least one confirmed ProviderAdmin.", exception.Message);
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task DeleteUsersAsync_Success(Provider provider, User deletingUser, ICollection<ProviderUser> providerUsers,
|
||||
[ProviderUser(ProviderUserStatusType.Confirmed, ProviderUserType.ProviderAdmin)] ProviderUser remainingOwner,
|
||||
SutProvider<ProviderService> sutProvider)
|
||||
@ -426,7 +427,7 @@ public class ProviderServiceTests
|
||||
Assert.Equal("Invalid user.", result[2].Item2);
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task AddOrganization_OrganizationAlreadyBelongsToAProvider_Throws(Provider provider,
|
||||
Organization organization, ProviderOrganization po, User user, string key,
|
||||
SutProvider<ProviderService> sutProvider)
|
||||
@ -441,7 +442,7 @@ public class ProviderServiceTests
|
||||
Assert.Equal("Organization already belongs to a provider.", exception.Message);
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task AddOrganization_Success(Provider provider, Organization organization, User user, string key,
|
||||
SutProvider<ProviderService> sutProvider)
|
||||
{
|
||||
@ -460,7 +461,7 @@ public class ProviderServiceTests
|
||||
EventType.ProviderOrganization_Added);
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task CreateOrganizationAsync_Success(Provider provider, OrganizationSignup organizationSignup,
|
||||
Organization organization, string clientOwnerEmail, User user, SutProvider<ProviderService> sutProvider)
|
||||
{
|
||||
@ -488,7 +489,7 @@ public class ProviderServiceTests
|
||||
t.First().Item2 == null));
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task RemoveOrganization_ProviderOrganizationIsInvalid_Throws(Provider provider,
|
||||
ProviderOrganization providerOrganization, User user, SutProvider<ProviderService> sutProvider)
|
||||
{
|
||||
@ -501,7 +502,7 @@ public class ProviderServiceTests
|
||||
Assert.Equal("Invalid organization.", exception.Message);
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task RemoveOrganization_ProviderOrganizationBelongsToWrongProvider_Throws(Provider provider,
|
||||
ProviderOrganization providerOrganization, User user, SutProvider<ProviderService> sutProvider)
|
||||
{
|
||||
@ -514,7 +515,7 @@ public class ProviderServiceTests
|
||||
Assert.Equal("Invalid organization.", exception.Message);
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task RemoveOrganization_HasNoOwners_Throws(Provider provider,
|
||||
ProviderOrganization providerOrganization, User user, SutProvider<ProviderService> sutProvider)
|
||||
{
|
||||
@ -530,7 +531,7 @@ public class ProviderServiceTests
|
||||
Assert.Equal("Organization needs to have at least one confirmed owner.", exception.Message);
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task RemoveOrganization_Success(Provider provider,
|
||||
ProviderOrganization providerOrganization, User user, SutProvider<ProviderService> sutProvider)
|
||||
{
|
||||
|
@ -1,5 +1,4 @@
|
||||
using AutoFixture;
|
||||
using AutoFixture.Xunit2;
|
||||
using AutoFixture.Xunit2;
|
||||
using Xunit;
|
||||
using Xunit.Sdk;
|
||||
|
||||
@ -12,10 +11,4 @@ public class InlineCustomAutoDataAttribute : CompositeDataAttribute
|
||||
new CustomAutoDataAttribute(iCustomizationTypes)
|
||||
})
|
||||
{ }
|
||||
|
||||
public InlineCustomAutoDataAttribute(ICustomization[] customizations, params object[] values) : base(new DataAttribute[] {
|
||||
new InlineDataAttribute(values),
|
||||
new CustomAutoDataAttribute(customizations)
|
||||
})
|
||||
{ }
|
||||
}
|
||||
|
@ -1,17 +0,0 @@
|
||||
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)
|
||||
{ }
|
||||
}
|
@ -6,10 +6,3 @@ public class SutProviderCustomizeAttribute : BitCustomizeAttribute
|
||||
{
|
||||
public override ICustomization GetCustomization() => new SutProviderCustomization();
|
||||
}
|
||||
|
||||
public class SutAutoDataAttribute : CustomAutoDataAttribute
|
||||
{
|
||||
public SutAutoDataAttribute(params Type[] iCustomizationTypes) : base(
|
||||
iCustomizationTypes.Append(typeof(SutProviderCustomization)).ToArray())
|
||||
{ }
|
||||
}
|
@ -33,36 +33,12 @@ internal class UserCipher : ICustomization
|
||||
}
|
||||
}
|
||||
|
||||
internal class UserCipherAutoDataAttribute : CustomAutoDataAttribute
|
||||
internal class UserCipherCustomizeAttribute : BitCustomizeAttribute
|
||||
{
|
||||
public UserCipherAutoDataAttribute(string userId = null) : base(new SutProviderCustomization(),
|
||||
new UserCipher { UserId = userId == null ? (Guid?)null : new Guid(userId) })
|
||||
{ }
|
||||
}
|
||||
internal class InlineUserCipherAutoDataAttribute : InlineCustomAutoDataAttribute
|
||||
{
|
||||
public InlineUserCipherAutoDataAttribute(params object[] values) : base(new[] { typeof(SutProviderCustomization),
|
||||
typeof(UserCipher) }, values)
|
||||
{ }
|
||||
public override ICustomization GetCustomization() => new UserCipher();
|
||||
}
|
||||
|
||||
internal class InlineKnownUserCipherAutoDataAttribute : InlineCustomAutoDataAttribute
|
||||
internal class OrganizationCipherCustomizeAttribute : BitCustomizeAttribute
|
||||
{
|
||||
public InlineKnownUserCipherAutoDataAttribute(string userId, params object[] values) : base(new ICustomization[]
|
||||
{ new SutProviderCustomization(), new UserCipher { UserId = new Guid(userId) } }, values)
|
||||
{ }
|
||||
}
|
||||
|
||||
internal class OrganizationCipherAutoDataAttribute : CustomAutoDataAttribute
|
||||
{
|
||||
public OrganizationCipherAutoDataAttribute(string organizationId = null) : base(new SutProviderCustomization(),
|
||||
new OrganizationCipher { OrganizationId = organizationId == null ? (Guid?)null : new Guid(organizationId) })
|
||||
{ }
|
||||
}
|
||||
|
||||
internal class InlineOrganizationCipherAutoDataAttribute : InlineCustomAutoDataAttribute
|
||||
{
|
||||
public InlineOrganizationCipherAutoDataAttribute(params object[] values) : base(new[] { typeof(SutProviderCustomization),
|
||||
typeof(OrganizationCipher) }, values)
|
||||
{ }
|
||||
public override ICustomization GetCustomization() => new OrganizationCipher();
|
||||
}
|
||||
|
@ -1,10 +0,0 @@
|
||||
using Bit.Core.Test.AutoFixture.OrganizationFixtures;
|
||||
using Bit.Test.Common.AutoFixture.Attributes;
|
||||
|
||||
namespace Bit.Core.Test.AutoFixture.CollectionFixtures;
|
||||
|
||||
internal class CollectionAutoDataAttribute : CustomAutoDataAttribute
|
||||
{
|
||||
public CollectionAutoDataAttribute() : base(new SutProviderCustomization(), new OrganizationCustomization())
|
||||
{ }
|
||||
}
|
@ -2,6 +2,7 @@
|
||||
using AutoFixture.Kernel;
|
||||
using Bit.Core.Context;
|
||||
using Bit.Test.Common.AutoFixture;
|
||||
using Bit.Test.Common.AutoFixture.Attributes;
|
||||
|
||||
namespace Bit.Core.Test.AutoFixture.CurrentContextFixtures;
|
||||
|
||||
@ -35,3 +36,8 @@ internal class CurrentContextBuilder : ISpecimenBuilder
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
|
||||
internal class CurrentContextCustomize : BitCustomizeAttribute
|
||||
{
|
||||
public override ICustomization GetCustomization() => new CurrentContext();
|
||||
}
|
||||
|
@ -1,18 +0,0 @@
|
||||
using Bit.Core.Test.AutoFixture.OrganizationFixtures;
|
||||
using Bit.Test.Common.AutoFixture.Attributes;
|
||||
|
||||
namespace Bit.Core.Test.AutoFixture.GroupFixtures;
|
||||
|
||||
internal class GroupOrganizationAutoDataAttribute : CustomAutoDataAttribute
|
||||
{
|
||||
public GroupOrganizationAutoDataAttribute() : base(
|
||||
new SutProviderCustomization(), new OrganizationCustomization { UseGroups = true })
|
||||
{ }
|
||||
}
|
||||
|
||||
internal class GroupOrganizationNotUseGroupsAutoDataAttribute : CustomAutoDataAttribute
|
||||
{
|
||||
public GroupOrganizationNotUseGroupsAutoDataAttribute() : base(
|
||||
new SutProviderCustomization(), new OrganizationCustomization { UseGroups = false })
|
||||
{ }
|
||||
}
|
@ -64,7 +64,7 @@ internal class PaidOrganization : ICustomization
|
||||
public PlanType CheckedPlanType { get; set; }
|
||||
public void Customize(IFixture fixture)
|
||||
{
|
||||
var validUpgradePlans = StaticStore.Plans.Where(p => p.Type != PlanType.Free && !p.Disabled).Select(p => p.Type).ToList();
|
||||
var validUpgradePlans = StaticStore.Plans.Where(p => p.Type != PlanType.Free && p.LegacyYear == null).OrderBy(p => p.UpgradeSortOrder).Select(p => p.Type).ToList();
|
||||
var lowestActivePaidPlan = validUpgradePlans.First();
|
||||
CheckedPlanType = CheckedPlanType.Equals(PlanType.Free) ? lowestActivePaidPlan : CheckedPlanType;
|
||||
validUpgradePlans.Remove(lowestActivePaidPlan);
|
||||
@ -109,7 +109,7 @@ internal class OrganizationInvite : ICustomization
|
||||
public string PermissionsBlob { get; set; }
|
||||
public void Customize(IFixture fixture)
|
||||
{
|
||||
var organizationId = new Guid();
|
||||
var organizationId = Guid.NewGuid();
|
||||
PermissionsBlob = PermissionsBlob ?? JsonSerializer.Serialize(new Permissions(), new JsonSerializerOptions
|
||||
{
|
||||
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
|
||||
@ -126,60 +126,38 @@ internal class OrganizationInvite : ICustomization
|
||||
}
|
||||
}
|
||||
|
||||
internal class PaidOrganizationAutoDataAttribute : CustomAutoDataAttribute
|
||||
internal class OrganizationCustomizeAttribute : BitCustomizeAttribute
|
||||
{
|
||||
public PaidOrganizationAutoDataAttribute(PlanType planType) : base(new SutProviderCustomization(),
|
||||
new PaidOrganization { CheckedPlanType = planType })
|
||||
{ }
|
||||
public PaidOrganizationAutoDataAttribute(int planType = 0) : this((PlanType)planType) { }
|
||||
public bool UseGroups { get; set; }
|
||||
public override ICustomization GetCustomization() => new OrganizationCustomization() { UseGroups = UseGroups };
|
||||
}
|
||||
|
||||
internal class InlinePaidOrganizationAutoDataAttribute : InlineCustomAutoDataAttribute
|
||||
internal class PaidOrganizationCustomizeAttribute : BitCustomizeAttribute
|
||||
{
|
||||
public InlinePaidOrganizationAutoDataAttribute(PlanType planType, object[] values) : base(
|
||||
new ICustomization[] { new SutProviderCustomization(), new PaidOrganization { CheckedPlanType = planType } }, values)
|
||||
{ }
|
||||
|
||||
public InlinePaidOrganizationAutoDataAttribute(params object[] values) : base(new[] { typeof(SutProviderCustomization),
|
||||
typeof(PaidOrganization) }, values)
|
||||
{ }
|
||||
public PlanType CheckedPlanType { get; set; } = PlanType.FamiliesAnnually;
|
||||
public override ICustomization GetCustomization() => new PaidOrganization() { CheckedPlanType = CheckedPlanType };
|
||||
}
|
||||
|
||||
internal class InlineFreeOrganizationAutoDataAttribute : InlineCustomAutoDataAttribute
|
||||
internal class FreeOrganizationCustomizeAttribute : BitCustomizeAttribute
|
||||
{
|
||||
public InlineFreeOrganizationAutoDataAttribute(params object[] values) : base(new[] { typeof(SutProviderCustomization),
|
||||
typeof(FreeOrganization) }, values)
|
||||
{ }
|
||||
public override ICustomization GetCustomization() => new FreeOrganization();
|
||||
}
|
||||
|
||||
internal class FreeOrganizationUpgradeAutoDataAttribute : CustomAutoDataAttribute
|
||||
internal class FreeOrganizationUpgradeCustomize : BitCustomizeAttribute
|
||||
{
|
||||
public FreeOrganizationUpgradeAutoDataAttribute() : base(new SutProviderCustomization(), new FreeOrganizationUpgrade())
|
||||
{ }
|
||||
public override ICustomization GetCustomization() => new FreeOrganizationUpgrade();
|
||||
}
|
||||
|
||||
internal class InlineFreeOrganizationUpgradeAutoDataAttribute : InlineCustomAutoDataAttribute
|
||||
internal class OrganizationInviteCustomizeAttribute : BitCustomizeAttribute
|
||||
{
|
||||
public InlineFreeOrganizationUpgradeAutoDataAttribute(params object[] values) : base(new[] { typeof(SutProviderCustomization),
|
||||
typeof(FreeOrganizationUpgrade) }, values)
|
||||
{ }
|
||||
}
|
||||
public OrganizationUserType InviteeUserType { get; set; } = OrganizationUserType.Owner;
|
||||
public OrganizationUserType InvitorUserType { get; set; } = OrganizationUserType.Owner;
|
||||
public string PermissionsBlob { get; set; }
|
||||
|
||||
internal class OrganizationInviteAutoDataAttribute : CustomAutoDataAttribute
|
||||
{
|
||||
public OrganizationInviteAutoDataAttribute(int inviteeUserType = 0, int invitorUserType = 0, string permissionsBlob = null) : base(new SutProviderCustomization(),
|
||||
new OrganizationInvite
|
||||
public override ICustomization GetCustomization() => new OrganizationInvite
|
||||
{
|
||||
InviteeUserType = (OrganizationUserType)inviteeUserType,
|
||||
InvitorUserType = (OrganizationUserType)invitorUserType,
|
||||
PermissionsBlob = permissionsBlob,
|
||||
})
|
||||
{ }
|
||||
}
|
||||
|
||||
internal class InlineOrganizationInviteAutoDataAttribute : InlineCustomAutoDataAttribute
|
||||
{
|
||||
public InlineOrganizationInviteAutoDataAttribute(params object[] values) : base(new[] { typeof(SutProviderCustomization),
|
||||
typeof(OrganizationInvite) }, values)
|
||||
{ }
|
||||
InviteeUserType = InviteeUserType,
|
||||
InvitorUserType = InvitorUserType,
|
||||
PermissionsBlob = PermissionsBlob,
|
||||
};
|
||||
}
|
||||
|
@ -4,17 +4,6 @@ using Bit.Test.Common.AutoFixture.Attributes;
|
||||
|
||||
namespace Bit.Core.Test.AutoFixture.SendFixtures;
|
||||
|
||||
internal class OrganizationSend : ICustomization
|
||||
{
|
||||
public Guid? OrganizationId { get; set; }
|
||||
public void Customize(IFixture fixture)
|
||||
{
|
||||
fixture.Customize<Send>(composer => composer
|
||||
.With(s => s.OrganizationId, OrganizationId ?? Guid.NewGuid())
|
||||
.Without(s => s.UserId));
|
||||
}
|
||||
}
|
||||
|
||||
internal class UserSend : ICustomization
|
||||
{
|
||||
public Guid? UserId { get; set; }
|
||||
@ -26,38 +15,7 @@ internal class UserSend : ICustomization
|
||||
}
|
||||
}
|
||||
|
||||
internal class UserSendAutoDataAttribute : CustomAutoDataAttribute
|
||||
internal class UserSendCustomizeAttribute : BitCustomizeAttribute
|
||||
{
|
||||
public UserSendAutoDataAttribute(string userId = null) : base(new SutProviderCustomization(),
|
||||
new UserSend { UserId = userId == null ? (Guid?)null : new Guid(userId) })
|
||||
{ }
|
||||
}
|
||||
internal class InlineUserSendAutoDataAttribute : InlineCustomAutoDataAttribute
|
||||
{
|
||||
public InlineUserSendAutoDataAttribute(params object[] values) : base(new[] { typeof(CurrentContextFixtures.CurrentContext),
|
||||
typeof(SutProviderCustomization), typeof(UserSend) }, values)
|
||||
{ }
|
||||
}
|
||||
|
||||
internal class InlineKnownUserSendAutoDataAttribute : InlineCustomAutoDataAttribute
|
||||
{
|
||||
public InlineKnownUserSendAutoDataAttribute(string userId, params object[] values) : base(new ICustomization[]
|
||||
{ new CurrentContextFixtures.CurrentContext(), new SutProviderCustomization(),
|
||||
new UserSend { UserId = new Guid(userId) } }, values)
|
||||
{ }
|
||||
}
|
||||
|
||||
internal class OrganizationSendAutoDataAttribute : CustomAutoDataAttribute
|
||||
{
|
||||
public OrganizationSendAutoDataAttribute(string organizationId = null) : base(new CurrentContextFixtures.CurrentContext(),
|
||||
new SutProviderCustomization(),
|
||||
new OrganizationSend { OrganizationId = organizationId == null ? (Guid?)null : new Guid(organizationId) })
|
||||
{ }
|
||||
}
|
||||
|
||||
internal class InlineOrganizationSendAutoDataAttribute : InlineCustomAutoDataAttribute
|
||||
{
|
||||
public InlineOrganizationSendAutoDataAttribute(params object[] values) : base(new[] { typeof(CurrentContextFixtures.CurrentContext),
|
||||
typeof(SutProviderCustomization), typeof(OrganizationSend) }, values)
|
||||
{ }
|
||||
public override ICustomization GetCustomization() => new UserSend();
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ using Bit.Core.Enums;
|
||||
using Bit.Core.Models;
|
||||
using Bit.Core.Test.AutoFixture.OrganizationFixtures;
|
||||
using Bit.Test.Common.AutoFixture;
|
||||
using Bit.Test.Common.AutoFixture.Attributes;
|
||||
|
||||
namespace Bit.Core.Test.AutoFixture.UserFixtures;
|
||||
|
||||
@ -42,6 +43,11 @@ public class UserBuilder : ISpecimenBuilder
|
||||
}
|
||||
}
|
||||
|
||||
internal class UserCustomizeAttribute : BitCustomizeAttribute
|
||||
{
|
||||
public override ICustomization GetCustomization() => new UserFixture();
|
||||
}
|
||||
|
||||
public class UserFixture : ICustomization
|
||||
{
|
||||
public virtual void Customize(IFixture fixture)
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System.Text.Json;
|
||||
using Bit.Core.Entities;
|
||||
using Bit.Core.Test.AutoFixture.CipherFixtures;
|
||||
using Bit.Test.Common.AutoFixture.Attributes;
|
||||
using Xunit;
|
||||
|
||||
namespace Bit.Core.Test.Models;
|
||||
@ -8,9 +9,17 @@ namespace Bit.Core.Test.Models;
|
||||
public class CipherTests
|
||||
{
|
||||
[Theory]
|
||||
[InlineUserCipherAutoData]
|
||||
[InlineOrganizationCipherAutoData]
|
||||
public void Clone_CreatesExactCopy(Cipher cipher)
|
||||
[UserCipherCustomize]
|
||||
[BitAutoData]
|
||||
public void Clone_UserCipher_CreatesExactCopy(Cipher cipher)
|
||||
{
|
||||
Assert.Equal(JsonSerializer.Serialize(cipher), JsonSerializer.Serialize(cipher.Clone()));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[OrganizationCipherCustomize]
|
||||
[BitAutoData]
|
||||
public void Clone_OrganizationCipher_CreatesExactCopy(Cipher cipher)
|
||||
{
|
||||
Assert.Equal(JsonSerializer.Serialize(cipher), JsonSerializer.Serialize(cipher.Clone()));
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ using Bit.Core.Repositories;
|
||||
using Bit.Core.Services;
|
||||
using Bit.Core.Test.AutoFixture.CipherFixtures;
|
||||
using Bit.Test.Common.AutoFixture;
|
||||
using Bit.Test.Common.AutoFixture.Attributes;
|
||||
using Castle.Core.Internal;
|
||||
using Core.Models.Data;
|
||||
using NSubstitute;
|
||||
@ -11,9 +12,11 @@ using Xunit;
|
||||
|
||||
namespace Bit.Core.Test.Services;
|
||||
|
||||
[UserCipherCustomize]
|
||||
[SutProviderCustomize]
|
||||
public class CipherServiceTests
|
||||
{
|
||||
[Theory, UserCipherAutoData]
|
||||
[Theory, BitAutoData]
|
||||
public async Task SaveAsync_WrongRevisionDate_Throws(SutProvider<CipherService> sutProvider, Cipher cipher)
|
||||
{
|
||||
var lastKnownRevisionDate = cipher.RevisionDate.AddDays(-1);
|
||||
@ -23,7 +26,7 @@ public class CipherServiceTests
|
||||
Assert.Contains("out of date", exception.Message);
|
||||
}
|
||||
|
||||
[Theory, UserCipherAutoData]
|
||||
[Theory, BitAutoData]
|
||||
public async Task SaveDetailsAsync_WrongRevisionDate_Throws(SutProvider<CipherService> sutProvider,
|
||||
CipherDetails cipherDetails)
|
||||
{
|
||||
@ -34,7 +37,7 @@ public class CipherServiceTests
|
||||
Assert.Contains("out of date", exception.Message);
|
||||
}
|
||||
|
||||
[Theory, UserCipherAutoData]
|
||||
[Theory, BitAutoData]
|
||||
public async Task ShareAsync_WrongRevisionDate_Throws(SutProvider<CipherService> sutProvider, Cipher cipher,
|
||||
Organization organization, List<Guid> collectionIds)
|
||||
{
|
||||
@ -47,7 +50,7 @@ public class CipherServiceTests
|
||||
Assert.Contains("out of date", exception.Message);
|
||||
}
|
||||
|
||||
[Theory, UserCipherAutoData("99ab4f6c-44f8-4ff5-be7a-75c37c33c69e")]
|
||||
[Theory, BitAutoData]
|
||||
public async Task ShareManyAsync_WrongRevisionDate_Throws(SutProvider<CipherService> sutProvider,
|
||||
IEnumerable<Cipher> ciphers, Guid organizationId, List<Guid> collectionIds)
|
||||
{
|
||||
@ -66,8 +69,8 @@ public class CipherServiceTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineUserCipherAutoData("")]
|
||||
[InlineUserCipherAutoData("Correct Time")]
|
||||
[BitAutoData("")]
|
||||
[BitAutoData("Correct Time")]
|
||||
public async Task SaveAsync_CorrectRevisionDate_Passes(string revisionDateString,
|
||||
SutProvider<CipherService> sutProvider, Cipher cipher)
|
||||
{
|
||||
@ -78,8 +81,8 @@ public class CipherServiceTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineUserCipherAutoData("")]
|
||||
[InlineUserCipherAutoData("Correct Time")]
|
||||
[BitAutoData("")]
|
||||
[BitAutoData("Correct Time")]
|
||||
public async Task SaveDetailsAsync_CorrectRevisionDate_Passes(string revisionDateString,
|
||||
SutProvider<CipherService> sutProvider, CipherDetails cipherDetails)
|
||||
{
|
||||
@ -90,8 +93,8 @@ public class CipherServiceTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineUserCipherAutoData("")]
|
||||
[InlineUserCipherAutoData("Correct Time")]
|
||||
[BitAutoData("")]
|
||||
[BitAutoData("Correct Time")]
|
||||
public async Task ShareAsync_CorrectRevisionDate_Passes(string revisionDateString,
|
||||
SutProvider<CipherService> sutProvider, Cipher cipher, Organization organization, List<Guid> collectionIds)
|
||||
{
|
||||
@ -106,8 +109,8 @@ public class CipherServiceTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineKnownUserCipherAutoData(userId: "99ab4f6c-44f8-4ff5-be7a-75c37c33c69e", "")]
|
||||
[InlineKnownUserCipherAutoData(userId: "99ab4f6c-44f8-4ff5-be7a-75c37c33c69e", "CorrectTime")]
|
||||
[BitAutoData("")]
|
||||
[BitAutoData("Correct Time")]
|
||||
public async Task ShareManyAsync_CorrectRevisionDate_Passes(string revisionDateString,
|
||||
SutProvider<CipherService> sutProvider, IEnumerable<Cipher> ciphers, Organization organization, List<Guid> collectionIds)
|
||||
{
|
||||
@ -128,9 +131,8 @@ public class CipherServiceTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineKnownUserCipherAutoData("c64d8a15-606e-41d6-9c7e-174d4d8f3b2e", "c64d8a15-606e-41d6-9c7e-174d4d8f3b2e")]
|
||||
[InlineOrganizationCipherAutoData("c64d8a15-606e-41d6-9c7e-174d4d8f3b2e")]
|
||||
public async Task RestoreAsync_UpdatesCipher(Guid restoringUserId, Cipher cipher, SutProvider<CipherService> sutProvider)
|
||||
[BitAutoData]
|
||||
public async Task RestoreAsync_UpdatesUserCipher(Guid restoringUserId, Cipher cipher, SutProvider<CipherService> sutProvider)
|
||||
{
|
||||
sutProvider.GetDependency<ICipherRepository>().GetCanEditByIdAsync(restoringUserId, cipher.Id).Returns(true);
|
||||
|
||||
@ -145,10 +147,28 @@ public class CipherServiceTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineKnownUserCipherAutoData("c64d8a15-606e-41d6-9c7e-174d4d8f3b2e", "c64d8a15-606e-41d6-9c7e-174d4d8f3b2e")]
|
||||
public async Task RestoreManyAsync_UpdatesCiphers(Guid restoringUserId, IEnumerable<CipherDetails> ciphers,
|
||||
[OrganizationCipherCustomize]
|
||||
[BitAutoData]
|
||||
public async Task RestoreAsync_UpdatesOrganizationCipher(Guid restoringUserId, Cipher cipher, SutProvider<CipherService> sutProvider)
|
||||
{
|
||||
sutProvider.GetDependency<ICipherRepository>().GetCanEditByIdAsync(restoringUserId, cipher.Id).Returns(true);
|
||||
|
||||
var initialRevisionDate = new DateTime(1970, 1, 1, 0, 0, 0);
|
||||
cipher.DeletedDate = initialRevisionDate;
|
||||
cipher.RevisionDate = initialRevisionDate;
|
||||
|
||||
await sutProvider.Sut.RestoreAsync(cipher, restoringUserId, cipher.OrganizationId.HasValue);
|
||||
|
||||
Assert.Null(cipher.DeletedDate);
|
||||
Assert.NotEqual(initialRevisionDate, cipher.RevisionDate);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[BitAutoData]
|
||||
public async Task RestoreManyAsync_UpdatesCiphers(IEnumerable<CipherDetails> ciphers,
|
||||
SutProvider<CipherService> sutProvider)
|
||||
{
|
||||
var restoringUserId = ciphers.First().UserId.Value;
|
||||
var previousRevisionDate = DateTime.UtcNow;
|
||||
foreach (var cipher in ciphers)
|
||||
{
|
||||
@ -168,8 +188,7 @@ public class CipherServiceTests
|
||||
}
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineUserCipherAutoData]
|
||||
[Theory, BitAutoData]
|
||||
public async Task ShareManyAsync_FreeOrgWithAttachment_Throws(SutProvider<CipherService> sutProvider,
|
||||
IEnumerable<Cipher> ciphers, Guid organizationId, List<Guid> collectionIds)
|
||||
{
|
||||
@ -190,8 +209,7 @@ public class CipherServiceTests
|
||||
Assert.Contains("This organization cannot use attachments", exception.Message);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineUserCipherAutoData]
|
||||
[Theory, BitAutoData]
|
||||
public async Task ShareManyAsync_PaidOrgWithAttachment_Passes(SutProvider<CipherService> sutProvider,
|
||||
IEnumerable<Cipher> ciphers, Guid organizationId, List<Guid> collectionIds)
|
||||
{
|
||||
|
@ -4,7 +4,7 @@ using Bit.Core.Exceptions;
|
||||
using Bit.Core.Models.Data;
|
||||
using Bit.Core.Repositories;
|
||||
using Bit.Core.Services;
|
||||
using Bit.Core.Test.AutoFixture.CollectionFixtures;
|
||||
using Bit.Core.Test.AutoFixture.OrganizationFixtures;
|
||||
using Bit.Test.Common.AutoFixture;
|
||||
using Bit.Test.Common.AutoFixture.Attributes;
|
||||
using NSubstitute;
|
||||
@ -12,9 +12,11 @@ using Xunit;
|
||||
|
||||
namespace Bit.Core.Test.Services;
|
||||
|
||||
[SutProviderCustomize]
|
||||
[OrganizationCustomize]
|
||||
public class CollectionServiceTest
|
||||
{
|
||||
[Theory, CollectionAutoData]
|
||||
[Theory, BitAutoData]
|
||||
public async Task SaveAsync_DefaultId_CreatesCollectionInTheRepository(Collection collection, Organization organization, SutProvider<CollectionService> sutProvider)
|
||||
{
|
||||
collection.Id = default;
|
||||
@ -30,7 +32,7 @@ public class CollectionServiceTest
|
||||
Assert.True(collection.RevisionDate - utcNow < TimeSpan.FromSeconds(1));
|
||||
}
|
||||
|
||||
[Theory, CollectionAutoData]
|
||||
[Theory, BitAutoData]
|
||||
public async Task SaveAsync_DefaultIdWithGroups_CreateCollectionWithGroupsInRepository(Collection collection,
|
||||
IEnumerable<SelectionReadOnly> groups, Organization organization, SutProvider<CollectionService> sutProvider)
|
||||
{
|
||||
@ -48,7 +50,7 @@ public class CollectionServiceTest
|
||||
Assert.True(collection.RevisionDate - utcNow < TimeSpan.FromSeconds(1));
|
||||
}
|
||||
|
||||
[Theory, CollectionAutoData]
|
||||
[Theory, BitAutoData]
|
||||
public async Task SaveAsync_NonDefaultId_ReplacesCollectionInRepository(Collection collection, Organization organization, SutProvider<CollectionService> sutProvider)
|
||||
{
|
||||
var creationDate = collection.CreationDate;
|
||||
@ -64,7 +66,7 @@ public class CollectionServiceTest
|
||||
Assert.True(collection.RevisionDate - utcNow < TimeSpan.FromSeconds(1));
|
||||
}
|
||||
|
||||
[Theory, CollectionAutoData]
|
||||
[Theory, BitAutoData]
|
||||
public async Task SaveAsync_OrganizationNotUseGroup_CreateCollectionWithoutGroupsInRepository(Collection collection, IEnumerable<SelectionReadOnly> groups,
|
||||
Organization organization, SutProvider<CollectionService> sutProvider)
|
||||
{
|
||||
@ -81,7 +83,7 @@ public class CollectionServiceTest
|
||||
Assert.True(collection.RevisionDate - utcNow < TimeSpan.FromSeconds(1));
|
||||
}
|
||||
|
||||
[Theory, CollectionAutoData]
|
||||
[Theory, BitAutoData]
|
||||
public async Task SaveAsync_DefaultIdWithUserId_UpdateUserInCollectionRepository(Collection collection,
|
||||
Organization organization, OrganizationUser organizationUser, SutProvider<CollectionService> sutProvider)
|
||||
{
|
||||
@ -104,7 +106,7 @@ public class CollectionServiceTest
|
||||
Assert.True(collection.RevisionDate - utcNow < TimeSpan.FromSeconds(1));
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task SaveAsync_NonExistingOrganizationId_ThrowsBadRequest(Collection collection, SutProvider<CollectionService> sutProvider)
|
||||
{
|
||||
var ex = await Assert.ThrowsAsync<BadRequestException>(() => sutProvider.Sut.SaveAsync(collection));
|
||||
@ -115,7 +117,7 @@ public class CollectionServiceTest
|
||||
await sutProvider.GetDependency<IEventService>().DidNotReceiveWithAnyArgs().LogCollectionEventAsync(default, default);
|
||||
}
|
||||
|
||||
[Theory, CollectionAutoData]
|
||||
[Theory, BitAutoData]
|
||||
public async Task SaveAsync_ExceedsOrganizationMaxCollections_ThrowsBadRequest(Collection collection, Organization organization, SutProvider<CollectionService> sutProvider)
|
||||
{
|
||||
collection.Id = default;
|
||||
@ -131,7 +133,7 @@ public class CollectionServiceTest
|
||||
await sutProvider.GetDependency<IEventService>().DidNotReceiveWithAnyArgs().LogCollectionEventAsync(default, default);
|
||||
}
|
||||
|
||||
[Theory, CollectionAutoData]
|
||||
[Theory, BitAutoData]
|
||||
public async Task DeleteUserAsync_DeletesValidUserWhoBelongsToCollection(Collection collection,
|
||||
Organization organization, OrganizationUser organizationUser, SutProvider<CollectionService> sutProvider)
|
||||
{
|
||||
@ -148,7 +150,7 @@ public class CollectionServiceTest
|
||||
await sutProvider.GetDependency<IEventService>().Received().LogOrganizationUserEventAsync(organizationUser, EventType.OrganizationUser_Updated);
|
||||
}
|
||||
|
||||
[Theory, CollectionAutoData]
|
||||
[Theory, BitAutoData]
|
||||
public async Task DeleteUserAsync_InvalidUser_ThrowsNotFound(Collection collection, Organization organization,
|
||||
OrganizationUser organizationUser, SutProvider<CollectionService> sutProvider)
|
||||
{
|
||||
|
@ -11,9 +11,10 @@ using Xunit;
|
||||
|
||||
namespace Bit.Core.Test.Services;
|
||||
|
||||
[SutProviderCustomize]
|
||||
public class EmergencyAccessServiceTests
|
||||
{
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task SaveAsync_PremiumCannotUpdate(
|
||||
SutProvider<EmergencyAccessService> sutProvider, User savingUser)
|
||||
{
|
||||
@ -33,7 +34,7 @@ public class EmergencyAccessServiceTests
|
||||
await sutProvider.GetDependency<IEmergencyAccessRepository>().DidNotReceiveWithAnyArgs().ReplaceAsync(default);
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task InviteAsync_UserWithKeyConnectorCannotUseTakeover(
|
||||
SutProvider<EmergencyAccessService> sutProvider, User invitingUser, string email, int waitTime)
|
||||
{
|
||||
@ -47,7 +48,7 @@ public class EmergencyAccessServiceTests
|
||||
await sutProvider.GetDependency<IEmergencyAccessRepository>().DidNotReceiveWithAnyArgs().CreateAsync(default);
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task ConfirmUserAsync_UserWithKeyConnectorCannotUseTakeover(
|
||||
SutProvider<EmergencyAccessService> sutProvider, User confirmingUser, string key)
|
||||
{
|
||||
@ -69,7 +70,7 @@ public class EmergencyAccessServiceTests
|
||||
await sutProvider.GetDependency<IEmergencyAccessRepository>().DidNotReceiveWithAnyArgs().ReplaceAsync(default);
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task SaveAsync_UserWithKeyConnectorCannotUseTakeover(
|
||||
SutProvider<EmergencyAccessService> sutProvider, User savingUser)
|
||||
{
|
||||
@ -91,7 +92,7 @@ public class EmergencyAccessServiceTests
|
||||
await sutProvider.GetDependency<IEmergencyAccessRepository>().DidNotReceiveWithAnyArgs().ReplaceAsync(default);
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task InitiateAsync_UserWithKeyConnectorCannotUseTakeover(
|
||||
SutProvider<EmergencyAccessService> sutProvider, User initiatingUser, User grantor)
|
||||
{
|
||||
@ -114,7 +115,7 @@ public class EmergencyAccessServiceTests
|
||||
await sutProvider.GetDependency<IEmergencyAccessRepository>().DidNotReceiveWithAnyArgs().ReplaceAsync(default);
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task TakeoverAsync_UserWithKeyConnectorCannotUseTakeover(
|
||||
SutProvider<EmergencyAccessService> sutProvider, User requestingUser, User grantor)
|
||||
{
|
||||
@ -136,7 +137,7 @@ public class EmergencyAccessServiceTests
|
||||
Assert.Contains("You cannot takeover an account that is using Key Connector", exception.Message);
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task PasswordAsync_Disables_2FA_Providers_And_Unknown_Device_Verification_On_The_Grantor(
|
||||
SutProvider<EmergencyAccessService> sutProvider, User requestingUser, User grantor)
|
||||
{
|
||||
|
@ -4,7 +4,7 @@ using Bit.Core.Exceptions;
|
||||
using Bit.Core.Models.Data;
|
||||
using Bit.Core.Repositories;
|
||||
using Bit.Core.Services;
|
||||
using Bit.Core.Test.AutoFixture.GroupFixtures;
|
||||
using Bit.Core.Test.AutoFixture.OrganizationFixtures;
|
||||
using Bit.Test.Common.AutoFixture;
|
||||
using Bit.Test.Common.AutoFixture.Attributes;
|
||||
using NSubstitute;
|
||||
@ -12,9 +12,11 @@ using Xunit;
|
||||
|
||||
namespace Bit.Core.Test.Services;
|
||||
|
||||
[SutProviderCustomize]
|
||||
[OrganizationCustomize(UseGroups = true)]
|
||||
public class GroupServiceTests
|
||||
{
|
||||
[Theory, GroupOrganizationAutoData]
|
||||
[Theory, BitAutoData]
|
||||
public async Task SaveAsync_DefaultGroupId_CreatesGroupInRepository(Group group, Organization organization, SutProvider<GroupService> sutProvider)
|
||||
{
|
||||
group.Id = default(Guid);
|
||||
@ -31,7 +33,7 @@ public class GroupServiceTests
|
||||
Assert.True(group.RevisionDate - utcNow < TimeSpan.FromSeconds(1));
|
||||
}
|
||||
|
||||
[Theory, GroupOrganizationAutoData]
|
||||
[Theory, BitAutoData]
|
||||
public async Task SaveAsync_DefaultGroupIdAndCollections_CreatesGroupInRepository(Group group, Organization organization, List<SelectionReadOnly> collections, SutProvider<GroupService> sutProvider)
|
||||
{
|
||||
group.Id = default(Guid);
|
||||
@ -48,7 +50,7 @@ public class GroupServiceTests
|
||||
Assert.True(group.RevisionDate - utcNow < TimeSpan.FromSeconds(1));
|
||||
}
|
||||
|
||||
[Theory, GroupOrganizationAutoData]
|
||||
[Theory, BitAutoData]
|
||||
public async Task SaveAsync_NonDefaultGroupId_ReplaceGroupInRepository(Group group, Organization organization, List<SelectionReadOnly> collections, SutProvider<GroupService> sutProvider)
|
||||
{
|
||||
organization.UseGroups = true;
|
||||
@ -62,7 +64,7 @@ public class GroupServiceTests
|
||||
Assert.True(group.RevisionDate - DateTime.UtcNow < TimeSpan.FromSeconds(1));
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task SaveAsync_NonExistingOrganizationId_ThrowsBadRequest(Group group, SutProvider<GroupService> sutProvider)
|
||||
{
|
||||
var exception = await Assert.ThrowsAsync<BadRequestException>(
|
||||
@ -73,7 +75,7 @@ public class GroupServiceTests
|
||||
await sutProvider.GetDependency<IEventService>().DidNotReceiveWithAnyArgs().LogGroupEventAsync(default, default, default);
|
||||
}
|
||||
|
||||
[Theory, GroupOrganizationNotUseGroupsAutoData]
|
||||
[Theory, OrganizationCustomize(UseGroups = false), BitAutoData]
|
||||
public async Task SaveAsync_OrganizationDoesNotUseGroups_ThrowsBadRequest(Group group, Organization organization, SutProvider<GroupService> sutProvider)
|
||||
{
|
||||
sutProvider.GetDependency<IOrganizationRepository>().GetByIdAsync(organization.Id).Returns(organization);
|
||||
@ -87,7 +89,7 @@ public class GroupServiceTests
|
||||
await sutProvider.GetDependency<IEventService>().DidNotReceiveWithAnyArgs().LogGroupEventAsync(default, default, default);
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task DeleteAsync_ValidData_DeletesGroup(Group group, SutProvider<GroupService> sutProvider)
|
||||
{
|
||||
await sutProvider.Sut.DeleteAsync(group);
|
||||
@ -97,7 +99,7 @@ public class GroupServiceTests
|
||||
.LogGroupEventAsync(group, EventType.Group_Deleted);
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task DeleteUserAsync_ValidData_DeletesUserInGroupRepository(Group group, Organization organization, OrganizationUser organizationUser, SutProvider<GroupService> sutProvider)
|
||||
{
|
||||
group.OrganizationId = organization.Id;
|
||||
@ -114,7 +116,7 @@ public class GroupServiceTests
|
||||
.LogOrganizationUserEventAsync(organizationUser, EventType.OrganizationUser_UpdatedGroups);
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task DeleteUserAsync_InvalidUser_ThrowsNotFound(Group group, Organization organization, OrganizationUser organizationUser, SutProvider<GroupService> sutProvider)
|
||||
{
|
||||
group.OrganizationId = organization.Id;
|
||||
|
@ -13,6 +13,7 @@ using Xunit;
|
||||
|
||||
namespace Bit.Core.Test.Services;
|
||||
|
||||
[SutProviderCustomize]
|
||||
public class LocalAttachmentStorageServiceTests
|
||||
{
|
||||
|
||||
@ -155,10 +156,14 @@ public class LocalAttachmentStorageServiceTests
|
||||
}
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineUserCipherAutoData]
|
||||
[InlineOrganizationCipherAutoData]
|
||||
public async Task CleanupAsync_Succes(Cipher cipher)
|
||||
[Theory, BitAutoData]
|
||||
[UserCipherCustomize]
|
||||
public async Task UserCipher_CleanupAsync_Success(Cipher cipher) => await CleanupAsync_Success(cipher);
|
||||
[Theory, BitAutoData]
|
||||
[OrganizationCipherCustomize]
|
||||
public async Task OrganizationCipher_CleanupAsync_Success(Cipher cipher) => await CleanupAsync_Success(cipher);
|
||||
|
||||
private async Task CleanupAsync_Success(Cipher cipher)
|
||||
{
|
||||
using (var tempDirectory = new TempDirectory())
|
||||
{
|
||||
@ -176,10 +181,14 @@ public class LocalAttachmentStorageServiceTests
|
||||
}
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineUserCipherAutoData]
|
||||
[InlineOrganizationCipherAutoData]
|
||||
public async Task DeleteAttachmentsForCipherAsync_Succes(Cipher cipher)
|
||||
[Theory, BitAutoData]
|
||||
[UserCipherCustomize]
|
||||
public async Task UserCipher_DeleteAttachmentsForCipherAsync_Succes(Cipher cipher) => await DeleteAttachmentsForCipherAsync_Succes(cipher);
|
||||
[Theory, BitAutoData]
|
||||
[OrganizationCipherCustomize]
|
||||
public async Task OrganizationCipher_DeleteAttachmentsForCipherAsync_Succes(Cipher cipher) => await DeleteAttachmentsForCipherAsync_Succes(cipher);
|
||||
|
||||
private async Task DeleteAttachmentsForCipherAsync_Succes(Cipher cipher)
|
||||
{
|
||||
using (var tempDirectory = new TempDirectory())
|
||||
{
|
||||
|
@ -22,10 +22,11 @@ using Policy = Bit.Core.Entities.Policy;
|
||||
|
||||
namespace Bit.Core.Test.Services;
|
||||
|
||||
[SutProviderCustomize]
|
||||
public class OrganizationServiceTests
|
||||
{
|
||||
// [Fact]
|
||||
[Theory, PaidOrganizationAutoData]
|
||||
[Theory, PaidOrganizationCustomize, BitAutoData]
|
||||
public async Task OrgImportCreateNewUsers(SutProvider<OrganizationService> sutProvider, Guid userId,
|
||||
Organization org, List<OrganizationUserUserDetails> existingUsers, List<ImportedOrganizationUser> newUsers)
|
||||
{
|
||||
@ -75,7 +76,7 @@ public class OrganizationServiceTests
|
||||
referenceEvent.Users == expectedNewUsersCount));
|
||||
}
|
||||
|
||||
[Theory, PaidOrganizationAutoData]
|
||||
[Theory, PaidOrganizationCustomize, BitAutoData]
|
||||
public async Task OrgImportCreateNewUsersAndMarryExistingUser(SutProvider<OrganizationService> sutProvider,
|
||||
Guid userId, Organization org, List<OrganizationUserUserDetails> existingUsers,
|
||||
List<ImportedOrganizationUser> newUsers)
|
||||
@ -133,7 +134,7 @@ public class OrganizationServiceTests
|
||||
referenceEvent.Users == expectedNewUsersCount));
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task UpgradePlan_OrganizationIsNull_Throws(Guid organizationId, OrganizationUpgrade upgrade,
|
||||
SutProvider<OrganizationService> sutProvider)
|
||||
{
|
||||
@ -142,7 +143,7 @@ public class OrganizationServiceTests
|
||||
() => sutProvider.Sut.UpgradePlanAsync(organizationId, upgrade));
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task UpgradePlan_GatewayCustomIdIsNull_Throws(Organization organization, OrganizationUpgrade upgrade,
|
||||
SutProvider<OrganizationService> sutProvider)
|
||||
{
|
||||
@ -153,7 +154,7 @@ public class OrganizationServiceTests
|
||||
Assert.Contains("no payment method", exception.Message);
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task UpgradePlan_AlreadyInPlan_Throws(Organization organization, OrganizationUpgrade upgrade,
|
||||
SutProvider<OrganizationService> sutProvider)
|
||||
{
|
||||
@ -164,7 +165,7 @@ public class OrganizationServiceTests
|
||||
Assert.Contains("already on this plan", exception.Message);
|
||||
}
|
||||
|
||||
[Theory, PaidOrganizationAutoData]
|
||||
[Theory, PaidOrganizationCustomize(CheckedPlanType = PlanType.Free), BitAutoData]
|
||||
public async Task UpgradePlan_UpgradeFromPaidPlan_Throws(Organization organization, OrganizationUpgrade upgrade,
|
||||
SutProvider<OrganizationService> sutProvider)
|
||||
{
|
||||
@ -175,7 +176,7 @@ public class OrganizationServiceTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[FreeOrganizationUpgradeAutoData]
|
||||
[FreeOrganizationUpgradeCustomize, BitAutoData]
|
||||
public async Task UpgradePlan_Passes(Organization organization, OrganizationUpgrade upgrade,
|
||||
SutProvider<OrganizationService> sutProvider)
|
||||
{
|
||||
@ -185,7 +186,7 @@ public class OrganizationServiceTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[OrganizationInviteAutoData]
|
||||
[OrganizationInviteCustomize, BitAutoData]
|
||||
public async Task InviteUser_NoEmails_Throws(Organization organization, OrganizationUser invitor,
|
||||
OrganizationUserInvite invite, SutProvider<OrganizationService> sutProvider)
|
||||
{
|
||||
@ -196,7 +197,7 @@ public class OrganizationServiceTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[OrganizationInviteAutoData]
|
||||
[OrganizationInviteCustomize, BitAutoData]
|
||||
public async Task InviteUser_DuplicateEmails_PassesWithoutDuplicates(Organization organization, OrganizationUser invitor,
|
||||
[OrganizationUser(OrganizationUserStatusType.Confirmed, OrganizationUserType.Owner)] OrganizationUser owner,
|
||||
OrganizationUserInvite invite, SutProvider<OrganizationService> sutProvider)
|
||||
@ -218,10 +219,10 @@ public class OrganizationServiceTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[OrganizationInviteAutoData(
|
||||
inviteeUserType: (int)OrganizationUserType.Admin,
|
||||
invitorUserType: (int)OrganizationUserType.Owner
|
||||
)]
|
||||
[OrganizationInviteCustomize(
|
||||
InviteeUserType = OrganizationUserType.Admin,
|
||||
InvitorUserType = OrganizationUserType.Owner
|
||||
), BitAutoData]
|
||||
public async Task InviteUser_NoOwner_Throws(Organization organization, OrganizationUser invitor,
|
||||
OrganizationUserInvite invite, SutProvider<OrganizationService> sutProvider)
|
||||
{
|
||||
@ -234,10 +235,10 @@ public class OrganizationServiceTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[OrganizationInviteAutoData(
|
||||
inviteeUserType: (int)OrganizationUserType.Owner,
|
||||
invitorUserType: (int)OrganizationUserType.Admin
|
||||
)]
|
||||
[OrganizationInviteCustomize(
|
||||
InviteeUserType = OrganizationUserType.Owner,
|
||||
InvitorUserType = OrganizationUserType.Admin
|
||||
), BitAutoData]
|
||||
public async Task InviteUser_NonOwnerConfiguringOwner_Throws(Organization organization, OrganizationUserInvite invite,
|
||||
OrganizationUser invitor, SutProvider<OrganizationService> sutProvider)
|
||||
{
|
||||
@ -253,10 +254,10 @@ public class OrganizationServiceTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[OrganizationInviteAutoData(
|
||||
inviteeUserType: (int)OrganizationUserType.Custom,
|
||||
invitorUserType: (int)OrganizationUserType.User
|
||||
)]
|
||||
[OrganizationInviteCustomize(
|
||||
InviteeUserType = OrganizationUserType.Custom,
|
||||
InvitorUserType = OrganizationUserType.User
|
||||
), BitAutoData]
|
||||
public async Task InviteUser_NonAdminConfiguringAdmin_Throws(Organization organization, OrganizationUserInvite invite,
|
||||
OrganizationUser invitor, SutProvider<OrganizationService> sutProvider)
|
||||
{
|
||||
@ -272,10 +273,10 @@ public class OrganizationServiceTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[OrganizationInviteAutoData(
|
||||
inviteeUserType: (int)OrganizationUserType.Manager,
|
||||
invitorUserType: (int)OrganizationUserType.Custom
|
||||
)]
|
||||
[OrganizationInviteCustomize(
|
||||
InviteeUserType = OrganizationUserType.Manager,
|
||||
InvitorUserType = OrganizationUserType.Custom
|
||||
), BitAutoData]
|
||||
public async Task InviteUser_CustomUserWithoutManageUsersConfiguringUser_Throws(Organization organization, OrganizationUserInvite invite,
|
||||
OrganizationUser invitor, SutProvider<OrganizationService> sutProvider)
|
||||
{
|
||||
@ -298,10 +299,10 @@ public class OrganizationServiceTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[OrganizationInviteAutoData(
|
||||
inviteeUserType: (int)OrganizationUserType.Admin,
|
||||
invitorUserType: (int)OrganizationUserType.Custom
|
||||
)]
|
||||
[OrganizationInviteCustomize(
|
||||
InviteeUserType = OrganizationUserType.Admin,
|
||||
InvitorUserType = OrganizationUserType.Custom
|
||||
), BitAutoData]
|
||||
public async Task InviteUser_CustomUserConfiguringAdmin_Throws(Organization organization, OrganizationUserInvite invite,
|
||||
OrganizationUser invitor, SutProvider<OrganizationService> sutProvider)
|
||||
{
|
||||
@ -324,10 +325,10 @@ public class OrganizationServiceTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[OrganizationInviteAutoData(
|
||||
inviteeUserType: (int)OrganizationUserType.User,
|
||||
invitorUserType: (int)OrganizationUserType.Owner
|
||||
)]
|
||||
[OrganizationInviteCustomize(
|
||||
InviteeUserType = OrganizationUserType.User,
|
||||
InvitorUserType = OrganizationUserType.Owner
|
||||
), BitAutoData]
|
||||
public async Task InviteUser_NoPermissionsObject_Passes(Organization organization, OrganizationUserInvite invite,
|
||||
OrganizationUser invitor, SutProvider<OrganizationService> sutProvider)
|
||||
{
|
||||
@ -347,10 +348,10 @@ public class OrganizationServiceTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[OrganizationInviteAutoData(
|
||||
inviteeUserType: (int)OrganizationUserType.User,
|
||||
invitorUserType: (int)OrganizationUserType.Custom
|
||||
)]
|
||||
[OrganizationInviteCustomize(
|
||||
InviteeUserType = OrganizationUserType.User,
|
||||
InvitorUserType = OrganizationUserType.Custom
|
||||
), BitAutoData]
|
||||
public async Task InviteUser_Passes(Organization organization, IEnumerable<(OrganizationUserInvite invite, string externalId)> invites,
|
||||
OrganizationUser invitor,
|
||||
[OrganizationUser(OrganizationUserStatusType.Confirmed, OrganizationUserType.Owner)] OrganizationUser owner,
|
||||
@ -383,7 +384,7 @@ public class OrganizationServiceTests
|
||||
Arg.Is<IEnumerable<(OrganizationUser, ExpiringToken)>>(v => v.Count() == invites.SelectMany(i => i.invite.Emails).Count()));
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task SaveUser_NoUserId_Throws(OrganizationUser user, Guid? savingUserId,
|
||||
IEnumerable<SelectionReadOnly> collections, SutProvider<OrganizationService> sutProvider)
|
||||
{
|
||||
@ -393,7 +394,7 @@ public class OrganizationServiceTests
|
||||
Assert.Contains("invite the user first", exception.Message.ToLowerInvariant());
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task SaveUser_NoChangeToData_Throws(OrganizationUser user, Guid? savingUserId,
|
||||
IEnumerable<SelectionReadOnly> collections, SutProvider<OrganizationService> sutProvider)
|
||||
{
|
||||
@ -404,7 +405,7 @@ public class OrganizationServiceTests
|
||||
Assert.Contains("make changes before saving", exception.Message.ToLowerInvariant());
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task SaveUser_Passes(
|
||||
OrganizationUser oldUserData,
|
||||
OrganizationUser newUserData,
|
||||
@ -426,7 +427,7 @@ public class OrganizationServiceTests
|
||||
await sutProvider.Sut.SaveUserAsync(newUserData, savingUser.UserId, collections);
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task DeleteUser_InvalidUser(OrganizationUser organizationUser, OrganizationUser deletingUser,
|
||||
SutProvider<OrganizationService> sutProvider)
|
||||
{
|
||||
@ -439,7 +440,7 @@ public class OrganizationServiceTests
|
||||
Assert.Contains("User not valid.", exception.Message);
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task DeleteUser_RemoveYourself(OrganizationUser deletingUser, SutProvider<OrganizationService> sutProvider)
|
||||
{
|
||||
var organizationUserRepository = sutProvider.GetDependency<IOrganizationUserRepository>();
|
||||
@ -451,7 +452,7 @@ public class OrganizationServiceTests
|
||||
Assert.Contains("You cannot remove yourself.", exception.Message);
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task DeleteUser_NonOwnerRemoveOwner(
|
||||
[OrganizationUser(type: OrganizationUserType.Owner)] OrganizationUser organizationUser,
|
||||
[OrganizationUser(type: OrganizationUserType.Admin)] OrganizationUser deletingUser,
|
||||
@ -469,7 +470,7 @@ public class OrganizationServiceTests
|
||||
Assert.Contains("Only owners can delete other owners.", exception.Message);
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task DeleteUser_LastOwner(
|
||||
[OrganizationUser(type: OrganizationUserType.Owner)] OrganizationUser organizationUser,
|
||||
OrganizationUser deletingUser,
|
||||
@ -487,7 +488,7 @@ public class OrganizationServiceTests
|
||||
Assert.Contains("Organization must have at least one confirmed owner.", exception.Message);
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task DeleteUser_Success(
|
||||
OrganizationUser organizationUser,
|
||||
[OrganizationUser(OrganizationUserStatusType.Confirmed, OrganizationUserType.Owner)] OrganizationUser deletingUser,
|
||||
@ -506,7 +507,7 @@ public class OrganizationServiceTests
|
||||
await sutProvider.Sut.DeleteUserAsync(deletingUser.OrganizationId, organizationUser.Id, deletingUser.UserId);
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task DeleteUsers_FilterInvalid(OrganizationUser organizationUser, OrganizationUser deletingUser,
|
||||
SutProvider<OrganizationService> sutProvider)
|
||||
{
|
||||
@ -520,7 +521,7 @@ public class OrganizationServiceTests
|
||||
Assert.Contains("Users invalid.", exception.Message);
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task DeleteUsers_RemoveYourself(
|
||||
[OrganizationUser(OrganizationUserStatusType.Confirmed, OrganizationUserType.Owner)] OrganizationUser orgUser,
|
||||
OrganizationUser deletingUser,
|
||||
@ -536,7 +537,7 @@ public class OrganizationServiceTests
|
||||
Assert.Contains("You cannot remove yourself.", result[0].Item2);
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task DeleteUsers_NonOwnerRemoveOwner(
|
||||
[OrganizationUser(type: OrganizationUserType.Admin)] OrganizationUser deletingUser,
|
||||
[OrganizationUser(type: OrganizationUserType.Owner)] OrganizationUser orgUser1,
|
||||
@ -555,7 +556,7 @@ public class OrganizationServiceTests
|
||||
Assert.Contains("Only owners can delete other owners.", result[0].Item2);
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task DeleteUsers_LastOwner(
|
||||
[OrganizationUser(status: OrganizationUserStatusType.Confirmed, OrganizationUserType.Owner)] OrganizationUser orgUser,
|
||||
SutProvider<OrganizationService> sutProvider)
|
||||
@ -572,7 +573,7 @@ public class OrganizationServiceTests
|
||||
Assert.Contains("Organization must have at least one confirmed owner.", exception.Message);
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task DeleteUsers_Success(
|
||||
[OrganizationUser(OrganizationUserStatusType.Confirmed, OrganizationUserType.Owner)] OrganizationUser deletingUser,
|
||||
[OrganizationUser(type: OrganizationUserType.Owner)] OrganizationUser orgUser1, OrganizationUser orgUser2,
|
||||
@ -593,7 +594,7 @@ public class OrganizationServiceTests
|
||||
await sutProvider.Sut.DeleteUsersAsync(deletingUser.OrganizationId, organizationUserIds, deletingUser.UserId);
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task ConfirmUser_InvalidStatus(OrganizationUser confirmingUser,
|
||||
[OrganizationUser(OrganizationUserStatusType.Invited)] OrganizationUser orgUser, string key,
|
||||
SutProvider<OrganizationService> sutProvider)
|
||||
@ -608,7 +609,7 @@ public class OrganizationServiceTests
|
||||
Assert.Contains("User not valid.", exception.Message);
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task ConfirmUser_WrongOrganization(OrganizationUser confirmingUser,
|
||||
[OrganizationUser(OrganizationUserStatusType.Accepted)] OrganizationUser orgUser, string key,
|
||||
SutProvider<OrganizationService> sutProvider)
|
||||
@ -624,8 +625,8 @@ public class OrganizationServiceTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineCustomAutoData(new[] { typeof(SutProviderCustomization) }, OrganizationUserType.Admin)]
|
||||
[InlineCustomAutoData(new[] { typeof(SutProviderCustomization) }, OrganizationUserType.Owner)]
|
||||
[BitAutoData(OrganizationUserType.Admin)]
|
||||
[BitAutoData(OrganizationUserType.Owner)]
|
||||
public async Task ConfirmUserToFree_AlreadyFreeAdminOrOwner_Throws(OrganizationUserType userType, Organization org, OrganizationUser confirmingUser,
|
||||
[OrganizationUser(OrganizationUserStatusType.Accepted)] OrganizationUser orgUser, User user,
|
||||
string key, SutProvider<OrganizationService> sutProvider)
|
||||
@ -650,28 +651,28 @@ public class OrganizationServiceTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineCustomAutoData(new[] { typeof(SutProviderCustomization) }, PlanType.Custom, OrganizationUserType.Admin)]
|
||||
[InlineCustomAutoData(new[] { typeof(SutProviderCustomization) }, PlanType.Custom, OrganizationUserType.Owner)]
|
||||
[InlineCustomAutoData(new[] { typeof(SutProviderCustomization) }, PlanType.EnterpriseAnnually, OrganizationUserType.Admin)]
|
||||
[InlineCustomAutoData(new[] { typeof(SutProviderCustomization) }, PlanType.EnterpriseAnnually, OrganizationUserType.Owner)]
|
||||
[InlineCustomAutoData(new[] { typeof(SutProviderCustomization) }, PlanType.EnterpriseAnnually2019, OrganizationUserType.Admin)]
|
||||
[InlineCustomAutoData(new[] { typeof(SutProviderCustomization) }, PlanType.EnterpriseAnnually2019, OrganizationUserType.Owner)]
|
||||
[InlineCustomAutoData(new[] { typeof(SutProviderCustomization) }, PlanType.EnterpriseMonthly, OrganizationUserType.Admin)]
|
||||
[InlineCustomAutoData(new[] { typeof(SutProviderCustomization) }, PlanType.EnterpriseMonthly, OrganizationUserType.Owner)]
|
||||
[InlineCustomAutoData(new[] { typeof(SutProviderCustomization) }, PlanType.EnterpriseMonthly2019, OrganizationUserType.Admin)]
|
||||
[InlineCustomAutoData(new[] { typeof(SutProviderCustomization) }, PlanType.EnterpriseMonthly2019, OrganizationUserType.Owner)]
|
||||
[InlineCustomAutoData(new[] { typeof(SutProviderCustomization) }, PlanType.FamiliesAnnually, OrganizationUserType.Admin)]
|
||||
[InlineCustomAutoData(new[] { typeof(SutProviderCustomization) }, PlanType.FamiliesAnnually, OrganizationUserType.Owner)]
|
||||
[InlineCustomAutoData(new[] { typeof(SutProviderCustomization) }, PlanType.FamiliesAnnually2019, OrganizationUserType.Admin)]
|
||||
[InlineCustomAutoData(new[] { typeof(SutProviderCustomization) }, PlanType.FamiliesAnnually2019, OrganizationUserType.Owner)]
|
||||
[InlineCustomAutoData(new[] { typeof(SutProviderCustomization) }, PlanType.TeamsAnnually, OrganizationUserType.Admin)]
|
||||
[InlineCustomAutoData(new[] { typeof(SutProviderCustomization) }, PlanType.TeamsAnnually, OrganizationUserType.Owner)]
|
||||
[InlineCustomAutoData(new[] { typeof(SutProviderCustomization) }, PlanType.TeamsAnnually2019, OrganizationUserType.Admin)]
|
||||
[InlineCustomAutoData(new[] { typeof(SutProviderCustomization) }, PlanType.TeamsAnnually2019, OrganizationUserType.Owner)]
|
||||
[InlineCustomAutoData(new[] { typeof(SutProviderCustomization) }, PlanType.TeamsMonthly, OrganizationUserType.Admin)]
|
||||
[InlineCustomAutoData(new[] { typeof(SutProviderCustomization) }, PlanType.TeamsMonthly, OrganizationUserType.Owner)]
|
||||
[InlineCustomAutoData(new[] { typeof(SutProviderCustomization) }, PlanType.TeamsMonthly2019, OrganizationUserType.Admin)]
|
||||
[InlineCustomAutoData(new[] { typeof(SutProviderCustomization) }, PlanType.TeamsMonthly2019, OrganizationUserType.Owner)]
|
||||
[BitAutoData(PlanType.Custom, OrganizationUserType.Admin)]
|
||||
[BitAutoData(PlanType.Custom, OrganizationUserType.Owner)]
|
||||
[BitAutoData(PlanType.EnterpriseAnnually, OrganizationUserType.Admin)]
|
||||
[BitAutoData(PlanType.EnterpriseAnnually, OrganizationUserType.Owner)]
|
||||
[BitAutoData(PlanType.EnterpriseAnnually2019, OrganizationUserType.Admin)]
|
||||
[BitAutoData(PlanType.EnterpriseAnnually2019, OrganizationUserType.Owner)]
|
||||
[BitAutoData(PlanType.EnterpriseMonthly, OrganizationUserType.Admin)]
|
||||
[BitAutoData(PlanType.EnterpriseMonthly, OrganizationUserType.Owner)]
|
||||
[BitAutoData(PlanType.EnterpriseMonthly2019, OrganizationUserType.Admin)]
|
||||
[BitAutoData(PlanType.EnterpriseMonthly2019, OrganizationUserType.Owner)]
|
||||
[BitAutoData(PlanType.FamiliesAnnually, OrganizationUserType.Admin)]
|
||||
[BitAutoData(PlanType.FamiliesAnnually, OrganizationUserType.Owner)]
|
||||
[BitAutoData(PlanType.FamiliesAnnually2019, OrganizationUserType.Admin)]
|
||||
[BitAutoData(PlanType.FamiliesAnnually2019, OrganizationUserType.Owner)]
|
||||
[BitAutoData(PlanType.TeamsAnnually, OrganizationUserType.Admin)]
|
||||
[BitAutoData(PlanType.TeamsAnnually, OrganizationUserType.Owner)]
|
||||
[BitAutoData(PlanType.TeamsAnnually2019, OrganizationUserType.Admin)]
|
||||
[BitAutoData(PlanType.TeamsAnnually2019, OrganizationUserType.Owner)]
|
||||
[BitAutoData(PlanType.TeamsMonthly, OrganizationUserType.Admin)]
|
||||
[BitAutoData(PlanType.TeamsMonthly, OrganizationUserType.Owner)]
|
||||
[BitAutoData(PlanType.TeamsMonthly2019, OrganizationUserType.Admin)]
|
||||
[BitAutoData(PlanType.TeamsMonthly2019, OrganizationUserType.Owner)]
|
||||
public async Task ConfirmUserToNonFree_AlreadyFreeAdminOrOwner_DoesNotThrow(PlanType planType, OrganizationUserType orgUserType, Organization org, OrganizationUser confirmingUser,
|
||||
[OrganizationUser(OrganizationUserStatusType.Accepted)] OrganizationUser orgUser, User user,
|
||||
string key, SutProvider<OrganizationService> sutProvider)
|
||||
@ -698,7 +699,7 @@ public class OrganizationServiceTests
|
||||
}
|
||||
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task ConfirmUser_SingleOrgPolicy(Organization org, OrganizationUser confirmingUser,
|
||||
[OrganizationUser(OrganizationUserStatusType.Accepted)] OrganizationUser orgUser, User user,
|
||||
OrganizationUser orgUserAnotherOrg, [Policy(PolicyType.SingleOrg)] Policy singleOrgPolicy,
|
||||
@ -725,7 +726,7 @@ public class OrganizationServiceTests
|
||||
Assert.Contains("User is a member of another organization.", exception.Message);
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task ConfirmUser_TwoFactorPolicy(Organization org, OrganizationUser confirmingUser,
|
||||
[OrganizationUser(OrganizationUserStatusType.Accepted)] OrganizationUser orgUser, User user,
|
||||
OrganizationUser orgUserAnotherOrg, [Policy(PolicyType.TwoFactorAuthentication)] Policy twoFactorPolicy,
|
||||
@ -751,7 +752,7 @@ public class OrganizationServiceTests
|
||||
Assert.Contains("User does not have two-step login enabled.", exception.Message);
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task ConfirmUser_Success(Organization org, OrganizationUser confirmingUser,
|
||||
[OrganizationUser(OrganizationUserStatusType.Accepted)] OrganizationUser orgUser, User user,
|
||||
[Policy(PolicyType.TwoFactorAuthentication)] Policy twoFactorPolicy,
|
||||
@ -775,7 +776,7 @@ public class OrganizationServiceTests
|
||||
await sutProvider.Sut.ConfirmUserAsync(orgUser.OrganizationId, orgUser.Id, key, confirmingUser.Id, userService);
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task ConfirmUsers_Success(Organization org,
|
||||
OrganizationUser confirmingUser,
|
||||
[OrganizationUser(OrganizationUserStatusType.Accepted)] OrganizationUser orgUser1,
|
||||
@ -815,7 +816,7 @@ public class OrganizationServiceTests
|
||||
Assert.Contains("User is a member of another organization.", result[2].Item2);
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task UpdateOrganizationKeysAsync_WithoutManageResetPassword_Throws(Guid orgId, string publicKey,
|
||||
string privateKey, SutProvider<OrganizationService> sutProvider)
|
||||
{
|
||||
@ -826,7 +827,7 @@ public class OrganizationServiceTests
|
||||
() => sutProvider.Sut.UpdateOrganizationKeysAsync(orgId, publicKey, privateKey));
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task UpdateOrganizationKeysAsync_KeysAlreadySet_Throws(Organization org, string publicKey,
|
||||
string privateKey, SutProvider<OrganizationService> sutProvider)
|
||||
{
|
||||
@ -841,7 +842,7 @@ public class OrganizationServiceTests
|
||||
Assert.Contains("Organization Keys already exist", exception.Message);
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task UpdateOrganizationKeysAsync_KeysAlreadySet_Success(Organization org, string publicKey,
|
||||
string privateKey, SutProvider<OrganizationService> sutProvider)
|
||||
{
|
||||
@ -858,10 +859,20 @@ public class OrganizationServiceTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlinePaidOrganizationAutoData(PlanType.EnterpriseAnnually, new object[] { "Cannot set max seat autoscaling below seat count", 1, 0, 2 })]
|
||||
[InlinePaidOrganizationAutoData(PlanType.EnterpriseAnnually, new object[] { "Cannot set max seat autoscaling below seat count", 4, -1, 6 })]
|
||||
[InlineFreeOrganizationAutoData("Your plan does not allow seat autoscaling", 10, 0, null)]
|
||||
public async Task UpdateSubscription_BadInputThrows(string expectedMessage,
|
||||
[PaidOrganizationCustomize(CheckedPlanType = PlanType.EnterpriseAnnually)]
|
||||
[BitAutoData("Cannot set max seat autoscaling below seat count", 1, 0, 2)]
|
||||
[BitAutoData("Cannot set max seat autoscaling below seat count", 4, -1, 6)]
|
||||
public async Task Enterprise_UpdateSubscription_BadInputThrows(string expectedMessage,
|
||||
int? maxAutoscaleSeats, int seatAdjustment, int? currentSeats, Organization organization, SutProvider<OrganizationService> sutProvider)
|
||||
=> await UpdateSubscription_BadInputThrows(expectedMessage, maxAutoscaleSeats, seatAdjustment, currentSeats, organization, sutProvider);
|
||||
[Theory]
|
||||
[FreeOrganizationCustomize]
|
||||
[BitAutoData("Your plan does not allow seat autoscaling", 10, 0, null)]
|
||||
public async Task Free_UpdateSubscription_BadInputThrows(string expectedMessage,
|
||||
int? maxAutoscaleSeats, int seatAdjustment, int? currentSeats, Organization organization, SutProvider<OrganizationService> sutProvider)
|
||||
=> await UpdateSubscription_BadInputThrows(expectedMessage, maxAutoscaleSeats, seatAdjustment, currentSeats, organization, sutProvider);
|
||||
|
||||
private async Task UpdateSubscription_BadInputThrows(string expectedMessage,
|
||||
int? maxAutoscaleSeats, int seatAdjustment, int? currentSeats, Organization organization, SutProvider<OrganizationService> sutProvider)
|
||||
{
|
||||
organization.Seats = currentSeats;
|
||||
@ -873,7 +884,7 @@ public class OrganizationServiceTests
|
||||
Assert.Contains(expectedMessage, exception.Message);
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task UpdateSubscription_NoOrganization_Throws(Guid organizationId, SutProvider<OrganizationService> sutProvider)
|
||||
{
|
||||
sutProvider.GetDependency<IOrganizationRepository>().GetByIdAsync(organizationId).Returns((Organization)null);
|
||||
@ -881,12 +892,12 @@ public class OrganizationServiceTests
|
||||
await Assert.ThrowsAsync<NotFoundException>(() => sutProvider.Sut.UpdateSubscription(organizationId, 0, null));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlinePaidOrganizationAutoData(0, 100, null, true, "")]
|
||||
[InlinePaidOrganizationAutoData(0, 100, 100, true, "")]
|
||||
[InlinePaidOrganizationAutoData(0, null, 100, true, "")]
|
||||
[InlinePaidOrganizationAutoData(1, 100, null, true, "")]
|
||||
[InlinePaidOrganizationAutoData(1, 100, 100, false, "Cannot invite new users. Seat limit has been reached")]
|
||||
[Theory, PaidOrganizationCustomize]
|
||||
[BitAutoData(0, 100, null, true, "")]
|
||||
[BitAutoData(0, 100, 100, true, "")]
|
||||
[BitAutoData(0, null, 100, true, "")]
|
||||
[BitAutoData(1, 100, null, true, "")]
|
||||
[BitAutoData(1, 100, 100, false, "Cannot invite new users. Seat limit has been reached")]
|
||||
public void CanScale(int seatsToAdd, int? currentSeats, int? maxAutoscaleSeats,
|
||||
bool expectedResult, string expectedFailureMessage, Organization organization,
|
||||
SutProvider<OrganizationService> sutProvider)
|
||||
@ -908,7 +919,7 @@ public class OrganizationServiceTests
|
||||
Assert.Equal(expectedResult, result);
|
||||
}
|
||||
|
||||
[Theory, PaidOrganizationAutoData]
|
||||
[Theory, PaidOrganizationCustomize, BitAutoData]
|
||||
public void CanScale_FailsOnSelfHosted(Organization organization,
|
||||
SutProvider<OrganizationService> sutProvider)
|
||||
{
|
||||
@ -919,7 +930,7 @@ public class OrganizationServiceTests
|
||||
Assert.Contains("Cannot autoscale on self-hosted instance", failureMessage);
|
||||
}
|
||||
|
||||
[Theory, PaidOrganizationAutoData]
|
||||
[Theory, PaidOrganizationCustomize, BitAutoData]
|
||||
public async Task Delete_Success(Organization organization, SutProvider<OrganizationService> sutProvider)
|
||||
{
|
||||
var organizationRepository = sutProvider.GetDependency<IOrganizationRepository>();
|
||||
@ -931,7 +942,7 @@ public class OrganizationServiceTests
|
||||
await applicationCacheService.Received().DeleteOrganizationAbilityAsync(organization.Id);
|
||||
}
|
||||
|
||||
[Theory, PaidOrganizationAutoData]
|
||||
[Theory, PaidOrganizationCustomize, BitAutoData]
|
||||
public async Task Delete_Fails_KeyConnector(Organization organization, SutProvider<OrganizationService> sutProvider,
|
||||
SsoConfig ssoConfig)
|
||||
{
|
||||
|
@ -7,15 +7,20 @@ using Bit.Core.Models.Data;
|
||||
using Bit.Core.Models.Data.Organizations.Policies;
|
||||
using Bit.Core.Repositories;
|
||||
using Bit.Core.Services;
|
||||
using Bit.Core.Test.AutoFixture.CurrentContextFixtures;
|
||||
using Bit.Core.Test.AutoFixture.SendFixtures;
|
||||
using Bit.Core.Test.Entities;
|
||||
using Bit.Test.Common.AutoFixture;
|
||||
using Bit.Test.Common.AutoFixture.Attributes;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using NSubstitute;
|
||||
using Xunit;
|
||||
|
||||
namespace Bit.Core.Test.Services;
|
||||
|
||||
[SutProviderCustomize]
|
||||
[CurrentContextCustomize]
|
||||
[UserSendCustomize]
|
||||
public class SendServiceTests
|
||||
{
|
||||
private void SaveSendAsync_Setup(SendType sendType, bool disableSendPolicyAppliesToUser,
|
||||
@ -31,8 +36,8 @@ public class SendServiceTests
|
||||
// Disable Send policy check
|
||||
|
||||
[Theory]
|
||||
[InlineUserSendAutoData(SendType.File)]
|
||||
[InlineUserSendAutoData(SendType.Text)]
|
||||
[BitAutoData(SendType.File)]
|
||||
[BitAutoData(SendType.Text)]
|
||||
public async void SaveSendAsync_DisableSend_Applies_throws(SendType sendType,
|
||||
SutProvider<SendService> sutProvider, Send send)
|
||||
{
|
||||
@ -42,8 +47,8 @@ public class SendServiceTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineUserSendAutoData(SendType.File)]
|
||||
[InlineUserSendAutoData(SendType.Text)]
|
||||
[BitAutoData(SendType.File)]
|
||||
[BitAutoData(SendType.Text)]
|
||||
public async void SaveSendAsync_DisableSend_DoesntApply_success(SendType sendType,
|
||||
SutProvider<SendService> sutProvider, Send send)
|
||||
{
|
||||
@ -78,8 +83,8 @@ public class SendServiceTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineUserSendAutoData(SendType.File)]
|
||||
[InlineUserSendAutoData(SendType.Text)]
|
||||
[BitAutoData(SendType.File)]
|
||||
[BitAutoData(SendType.Text)]
|
||||
public async void SaveSendAsync_DisableHideEmail_Applies_throws(SendType sendType,
|
||||
SutProvider<SendService> sutProvider, Send send, Policy policy)
|
||||
{
|
||||
@ -90,8 +95,8 @@ public class SendServiceTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineUserSendAutoData(SendType.File)]
|
||||
[InlineUserSendAutoData(SendType.Text)]
|
||||
[BitAutoData(SendType.File)]
|
||||
[BitAutoData(SendType.Text)]
|
||||
public async void SaveSendAsync_DisableHideEmail_DoesntApply_success(SendType sendType,
|
||||
SutProvider<SendService> sutProvider, Send send, Policy policy)
|
||||
{
|
||||
@ -104,8 +109,7 @@ public class SendServiceTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineUserSendAutoData]
|
||||
[InlineUserSendAutoData]
|
||||
[BitAutoData]
|
||||
public async void SaveSendAsync_ExistingSend_Updates(SutProvider<SendService> sutProvider,
|
||||
Send send)
|
||||
{
|
||||
@ -126,7 +130,7 @@ public class SendServiceTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineUserSendAutoData]
|
||||
[BitAutoData]
|
||||
public async void SaveFileSendAsync_TextType_ThrowsBadRequest(SutProvider<SendService> sutProvider,
|
||||
Send send)
|
||||
{
|
||||
@ -140,7 +144,7 @@ public class SendServiceTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineUserSendAutoData]
|
||||
[BitAutoData]
|
||||
public async void SaveFileSendAsync_EmptyFile_ThrowsBadRequest(SutProvider<SendService> sutProvider,
|
||||
Send send)
|
||||
{
|
||||
@ -154,7 +158,7 @@ public class SendServiceTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineUserSendAutoData]
|
||||
[BitAutoData]
|
||||
public async void SaveFileSendAsync_UserCannotAccessPremium_ThrowsBadRequest(SutProvider<SendService> sutProvider,
|
||||
Send send)
|
||||
{
|
||||
@ -182,7 +186,7 @@ public class SendServiceTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineUserSendAutoData]
|
||||
[BitAutoData]
|
||||
public async void SaveFileSendAsync_UserHasUnconfirmedEmail_ThrowsBadRequest(SutProvider<SendService> sutProvider,
|
||||
Send send)
|
||||
{
|
||||
@ -211,7 +215,7 @@ public class SendServiceTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineUserSendAutoData]
|
||||
[BitAutoData]
|
||||
public async void SaveFileSendAsync_UserCanAccessPremium_HasNoStorage_ThrowsBadRequest(SutProvider<SendService> sutProvider,
|
||||
Send send)
|
||||
{
|
||||
@ -243,7 +247,7 @@ public class SendServiceTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineUserSendAutoData]
|
||||
[BitAutoData]
|
||||
public async void SaveFileSendAsync_UserCanAccessPremium_StorageFull_ThrowsBadRequest(SutProvider<SendService> sutProvider,
|
||||
Send send)
|
||||
{
|
||||
@ -275,7 +279,7 @@ public class SendServiceTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineUserSendAutoData]
|
||||
[BitAutoData]
|
||||
public async void SaveFileSendAsync_UserCanAccessPremium_IsNotPremium_IsSelfHosted_GiantFile_ThrowsBadRequest(SutProvider<SendService> sutProvider,
|
||||
Send send)
|
||||
{
|
||||
@ -308,7 +312,7 @@ public class SendServiceTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineUserSendAutoData]
|
||||
[BitAutoData]
|
||||
public async void SaveFileSendAsync_UserCanAccessPremium_IsNotPremium_IsNotSelfHosted_TwoGigabyteFile_ThrowsBadRequest(SutProvider<SendService> sutProvider,
|
||||
Send send)
|
||||
{
|
||||
@ -341,7 +345,7 @@ public class SendServiceTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineUserSendAutoData]
|
||||
[BitAutoData]
|
||||
public async void SaveFileSendAsync_ThroughOrg_MaxStorageIsNull_ThrowsBadRequest(SutProvider<SendService> sutProvider,
|
||||
Send send)
|
||||
{
|
||||
@ -367,7 +371,7 @@ public class SendServiceTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineUserSendAutoData]
|
||||
[BitAutoData]
|
||||
public async void SaveFileSendAsync_ThroughOrg_MaxStorageIsNull_TwoGBFile_ThrowsBadRequest(SutProvider<SendService> sutProvider,
|
||||
Send send)
|
||||
{
|
||||
@ -393,7 +397,7 @@ public class SendServiceTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineUserSendAutoData]
|
||||
[BitAutoData]
|
||||
public async void SaveFileSendAsync_ThroughOrg_MaxStorageIsOneGB_TwoGBFile_ThrowsBadRequest(SutProvider<SendService> sutProvider,
|
||||
Send send)
|
||||
{
|
||||
@ -419,7 +423,7 @@ public class SendServiceTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineUserSendAutoData]
|
||||
[BitAutoData]
|
||||
public async void SaveFileSendAsync_HasEnouphStorage_Success(SutProvider<SendService> sutProvider,
|
||||
Send send)
|
||||
{
|
||||
@ -473,7 +477,7 @@ public class SendServiceTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineUserSendAutoData]
|
||||
[BitAutoData]
|
||||
public async void SaveFileSendAsync_HasEnouphStorage_SendFileThrows_CleansUp(SutProvider<SendService> sutProvider,
|
||||
Send send)
|
||||
{
|
||||
@ -531,7 +535,7 @@ public class SendServiceTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineUserSendAutoData]
|
||||
[BitAutoData]
|
||||
public async void UpdateFileToExistingSendAsync_SendNull_ThrowsBadRequest(SutProvider<SendService> sutProvider)
|
||||
{
|
||||
|
||||
@ -543,7 +547,7 @@ public class SendServiceTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineUserSendAutoData]
|
||||
[BitAutoData]
|
||||
public async void UpdateFileToExistingSendAsync_SendDataNull_ThrowsBadRequest(SutProvider<SendService> sutProvider,
|
||||
Send send)
|
||||
{
|
||||
@ -557,7 +561,7 @@ public class SendServiceTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineUserSendAutoData]
|
||||
[BitAutoData]
|
||||
public async void UpdateFileToExistingSendAsync_NotFileType_ThrowsBadRequest(SutProvider<SendService> sutProvider,
|
||||
Send send)
|
||||
{
|
||||
@ -569,7 +573,7 @@ public class SendServiceTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineUserSendAutoData]
|
||||
[BitAutoData]
|
||||
public async void UpdateFileToExistingSendAsync_Success(SutProvider<SendService> sutProvider,
|
||||
Send send)
|
||||
{
|
||||
@ -593,7 +597,7 @@ public class SendServiceTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineUserSendAutoData]
|
||||
[BitAutoData]
|
||||
public async void UpdateFileToExistingSendAsync_InvalidSize(SutProvider<SendService> sutProvider,
|
||||
Send send)
|
||||
{
|
||||
@ -618,7 +622,7 @@ public class SendServiceTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineUserSendAutoData]
|
||||
[BitAutoData]
|
||||
public void SendCanBeAccessed_Success(SutProvider<SendService> sutProvider, Send send)
|
||||
{
|
||||
var now = DateTime.UtcNow;
|
||||
@ -641,7 +645,7 @@ public class SendServiceTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineUserSendAutoData]
|
||||
[BitAutoData]
|
||||
public void SendCanBeAccessed_NullMaxAccess_Success(SutProvider<SendService> sutProvider,
|
||||
Send send)
|
||||
{
|
||||
@ -665,7 +669,7 @@ public class SendServiceTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineUserSendAutoData]
|
||||
[BitAutoData]
|
||||
public void SendCanBeAccessed_NullSend_DoesNotGrantAccess(SutProvider<SendService> sutProvider)
|
||||
{
|
||||
sutProvider.GetDependency<IPasswordHasher<User>>()
|
||||
@ -681,7 +685,7 @@ public class SendServiceTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineUserSendAutoData]
|
||||
[BitAutoData]
|
||||
public void SendCanBeAccessed_NullPassword_PasswordRequiredErrorReturnsTrue(SutProvider<SendService> sutProvider,
|
||||
Send send)
|
||||
{
|
||||
@ -706,7 +710,7 @@ public class SendServiceTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineUserSendAutoData]
|
||||
[BitAutoData]
|
||||
public void SendCanBeAccessed_RehashNeeded_RehashesPassword(SutProvider<SendService> sutProvider,
|
||||
Send send)
|
||||
{
|
||||
@ -735,7 +739,7 @@ public class SendServiceTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineUserSendAutoData]
|
||||
[BitAutoData]
|
||||
public void SendCanBeAccessed_VerifyFailed_PasswordInvalidReturnsTrue(SutProvider<SendService> sutProvider,
|
||||
Send send)
|
||||
{
|
||||
|
@ -11,9 +11,10 @@ using Xunit;
|
||||
|
||||
namespace Bit.Core.Test.Services;
|
||||
|
||||
[SutProviderCustomize]
|
||||
public class SsoConfigServiceTests
|
||||
{
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task SaveAsync_ExistingItem_UpdatesRevisionDateOnly(SutProvider<SsoConfigService> sutProvider,
|
||||
Organization organization)
|
||||
{
|
||||
@ -41,7 +42,7 @@ public class SsoConfigServiceTests
|
||||
Assert.True(ssoConfig.RevisionDate - utcNow < TimeSpan.FromSeconds(1));
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task SaveAsync_NewItem_UpdatesCreationAndRevisionDate(SutProvider<SsoConfigService> sutProvider,
|
||||
Organization organization)
|
||||
{
|
||||
@ -69,7 +70,7 @@ public class SsoConfigServiceTests
|
||||
Assert.True(ssoConfig.RevisionDate - utcNow < TimeSpan.FromSeconds(1));
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task SaveAsync_PreventDisablingKeyConnector(SutProvider<SsoConfigService> sutProvider,
|
||||
Organization organization)
|
||||
{
|
||||
@ -113,7 +114,7 @@ public class SsoConfigServiceTests
|
||||
.UpsertAsync(default);
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task SaveAsync_AllowDisablingKeyConnectorWhenNoUserIsUsingIt(
|
||||
SutProvider<SsoConfigService> sutProvider, Organization organization)
|
||||
{
|
||||
@ -151,7 +152,7 @@ public class SsoConfigServiceTests
|
||||
await sutProvider.Sut.SaveAsync(newSsoConfig, organization);
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task SaveAsync_KeyConnector_SingleOrgNotEnabled_Throws(SutProvider<SsoConfigService> sutProvider,
|
||||
Organization organization)
|
||||
{
|
||||
@ -179,7 +180,7 @@ public class SsoConfigServiceTests
|
||||
.UpsertAsync(default);
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task SaveAsync_KeyConnector_SsoPolicyNotEnabled_Throws(SutProvider<SsoConfigService> sutProvider,
|
||||
Organization organization)
|
||||
{
|
||||
@ -213,7 +214,7 @@ public class SsoConfigServiceTests
|
||||
.UpsertAsync(default);
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task SaveAsync_KeyConnector_SsoConfigNotEnabled_Throws(SutProvider<SsoConfigService> sutProvider,
|
||||
Organization organization)
|
||||
{
|
||||
@ -247,7 +248,7 @@ public class SsoConfigServiceTests
|
||||
.UpsertAsync(default);
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task SaveAsync_KeyConnector_KeyConnectorAbilityNotEnabled_Throws(SutProvider<SsoConfigService> sutProvider,
|
||||
Organization organization)
|
||||
{
|
||||
@ -282,7 +283,7 @@ public class SsoConfigServiceTests
|
||||
.UpsertAsync(default);
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task SaveAsync_KeyConnector_Success(SutProvider<SsoConfigService> sutProvider,
|
||||
Organization organization)
|
||||
{
|
||||
|
@ -14,16 +14,17 @@ using PaymentMethodType = Bit.Core.Enums.PaymentMethodType;
|
||||
|
||||
namespace Bit.Core.Test.Services;
|
||||
|
||||
[SutProviderCustomize]
|
||||
public class StripePaymentServiceTests
|
||||
{
|
||||
[Theory]
|
||||
[InlineCustomAutoData(new[] { typeof(SutProviderCustomization) }, PaymentMethodType.BitPay)]
|
||||
[InlineCustomAutoData(new[] { typeof(SutProviderCustomization) }, PaymentMethodType.BitPay)]
|
||||
[InlineCustomAutoData(new[] { typeof(SutProviderCustomization) }, PaymentMethodType.Credit)]
|
||||
[InlineCustomAutoData(new[] { typeof(SutProviderCustomization) }, PaymentMethodType.WireTransfer)]
|
||||
[InlineCustomAutoData(new[] { typeof(SutProviderCustomization) }, PaymentMethodType.AppleInApp)]
|
||||
[InlineCustomAutoData(new[] { typeof(SutProviderCustomization) }, PaymentMethodType.GoogleInApp)]
|
||||
[InlineCustomAutoData(new[] { typeof(SutProviderCustomization) }, PaymentMethodType.Check)]
|
||||
[BitAutoData(PaymentMethodType.BitPay)]
|
||||
[BitAutoData(PaymentMethodType.BitPay)]
|
||||
[BitAutoData(PaymentMethodType.Credit)]
|
||||
[BitAutoData(PaymentMethodType.WireTransfer)]
|
||||
[BitAutoData(PaymentMethodType.AppleInApp)]
|
||||
[BitAutoData(PaymentMethodType.GoogleInApp)]
|
||||
[BitAutoData(PaymentMethodType.Check)]
|
||||
public async void PurchaseOrganizationAsync_Invalid(PaymentMethodType paymentMethodType, SutProvider<StripePaymentService> sutProvider)
|
||||
{
|
||||
var exception = await Assert.ThrowsAsync<GatewayException>(
|
||||
@ -32,7 +33,7 @@ public class StripePaymentServiceTests
|
||||
Assert.Equal("Payment method is not supported at this time.", exception.Message);
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async void PurchaseOrganizationAsync_Stripe(SutProvider<StripePaymentService> sutProvider, Organization organization, string paymentToken, TaxInfo taxInfo)
|
||||
{
|
||||
var plan = StaticStore.Plans.First(p => p.Type == PlanType.EnterpriseAnnually);
|
||||
@ -81,7 +82,7 @@ public class StripePaymentServiceTests
|
||||
));
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async void PurchaseOrganizationAsync_Stripe_PM(SutProvider<StripePaymentService> sutProvider, Organization organization, string paymentToken, TaxInfo taxInfo)
|
||||
{
|
||||
var plan = StaticStore.Plans.First(p => p.Type == PlanType.EnterpriseAnnually);
|
||||
@ -131,7 +132,7 @@ public class StripePaymentServiceTests
|
||||
));
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async void PurchaseOrganizationAsync_Stripe_TaxRate(SutProvider<StripePaymentService> sutProvider, Organization organization, string paymentToken, TaxInfo taxInfo)
|
||||
{
|
||||
var plan = StaticStore.Plans.First(p => p.Type == PlanType.EnterpriseAnnually);
|
||||
@ -160,7 +161,7 @@ public class StripePaymentServiceTests
|
||||
));
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async void PurchaseOrganizationAsync_Stripe_Declined(SutProvider<StripePaymentService> sutProvider, Organization organization, string paymentToken, TaxInfo taxInfo)
|
||||
{
|
||||
var plan = StaticStore.Plans.First(p => p.Type == PlanType.EnterpriseAnnually);
|
||||
@ -193,7 +194,7 @@ public class StripePaymentServiceTests
|
||||
await stripeAdapter.Received(1).CustomerDeleteAsync("C-1");
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async void PurchaseOrganizationAsync_Stripe_RequiresAction(SutProvider<StripePaymentService> sutProvider, Organization organization, string paymentToken, TaxInfo taxInfo)
|
||||
{
|
||||
var plan = StaticStore.Plans.First(p => p.Type == PlanType.EnterpriseAnnually);
|
||||
@ -224,7 +225,7 @@ public class StripePaymentServiceTests
|
||||
Assert.False(organization.Enabled);
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async void PurchaseOrganizationAsync_Paypal(SutProvider<StripePaymentService> sutProvider, Organization organization, string paymentToken, TaxInfo taxInfo)
|
||||
{
|
||||
var plan = StaticStore.Plans.First(p => p.Type == PlanType.EnterpriseAnnually);
|
||||
@ -283,7 +284,7 @@ public class StripePaymentServiceTests
|
||||
));
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async void PurchaseOrganizationAsync_Paypal_FailedCreate(SutProvider<StripePaymentService> sutProvider, Organization organization, string paymentToken, TaxInfo taxInfo)
|
||||
{
|
||||
var plan = StaticStore.Plans.First(p => p.Type == PlanType.EnterpriseAnnually);
|
||||
@ -300,7 +301,7 @@ public class StripePaymentServiceTests
|
||||
Assert.Equal("Failed to create PayPal customer record.", exception.Message);
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async void PurchaseOrganizationAsync_PayPal_Declined(SutProvider<StripePaymentService> sutProvider, Organization organization, string paymentToken, TaxInfo taxInfo)
|
||||
{
|
||||
var plan = StaticStore.Plans.First(p => p.Type == PlanType.EnterpriseAnnually);
|
||||
@ -344,7 +345,7 @@ public class StripePaymentServiceTests
|
||||
await braintreeGateway.Customer.Received(1).DeleteAsync("Braintree-Id");
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async void UpgradeFreeOrganizationAsync_Success(SutProvider<StripePaymentService> sutProvider,
|
||||
Organization organization, TaxInfo taxInfo)
|
||||
{
|
||||
|
@ -16,9 +16,10 @@ using Xunit;
|
||||
|
||||
namespace Bit.Core.Test.Services;
|
||||
|
||||
[SutProviderCustomize]
|
||||
public class UserServiceTests
|
||||
{
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task UpdateLicenseAsync_Success(SutProvider<UserService> sutProvider,
|
||||
User user, UserLicense userLicense)
|
||||
{
|
||||
@ -55,7 +56,7 @@ public class UserServiceTests
|
||||
Assert.Equal(1, versionProp.GetInt32());
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task SendTwoFactorEmailAsync_Success(SutProvider<UserService> sutProvider, User user)
|
||||
{
|
||||
var email = user.Email.ToLowerInvariant();
|
||||
@ -86,7 +87,7 @@ public class UserServiceTests
|
||||
.SendTwoFactorEmailAsync(email, token);
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task SendTwoFactorEmailBecauseNewDeviceLoginAsync_Success(SutProvider<UserService> sutProvider, User user)
|
||||
{
|
||||
var email = user.Email.ToLowerInvariant();
|
||||
@ -117,7 +118,7 @@ public class UserServiceTests
|
||||
.SendNewDeviceLoginTwoFactorEmailAsync(email, token);
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task SendTwoFactorEmailAsync_ExceptionBecauseNoProviderOnUser(SutProvider<UserService> sutProvider, User user)
|
||||
{
|
||||
user.TwoFactorProviders = null;
|
||||
@ -125,7 +126,7 @@ public class UserServiceTests
|
||||
await Assert.ThrowsAsync<ArgumentNullException>("No email.", () => sutProvider.Sut.SendTwoFactorEmailAsync(user));
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task SendTwoFactorEmailAsync_ExceptionBecauseNoProviderMetadataOnUser(SutProvider<UserService> sutProvider, User user)
|
||||
{
|
||||
user.SetTwoFactorProviders(new Dictionary<TwoFactorProviderType, TwoFactorProvider>
|
||||
@ -140,7 +141,7 @@ public class UserServiceTests
|
||||
await Assert.ThrowsAsync<ArgumentNullException>("No email.", () => sutProvider.Sut.SendTwoFactorEmailAsync(user));
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task SendTwoFactorEmailAsync_ExceptionBecauseNoProviderEmailMetadataOnUser(SutProvider<UserService> sutProvider, User user)
|
||||
{
|
||||
user.SetTwoFactorProviders(new Dictionary<TwoFactorProviderType, TwoFactorProvider>
|
||||
@ -155,7 +156,7 @@ public class UserServiceTests
|
||||
await Assert.ThrowsAsync<ArgumentNullException>("No email.", () => sutProvider.Sut.SendTwoFactorEmailAsync(user));
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task Needs2FABecauseNewDeviceAsync_ReturnsTrue(SutProvider<UserService> sutProvider, User user)
|
||||
{
|
||||
user.EmailVerified = true;
|
||||
@ -177,7 +178,7 @@ public class UserServiceTests
|
||||
Assert.True(await sutProvider.Sut.Needs2FABecauseNewDeviceAsync(user, deviceIdToCheck, "password"));
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task Needs2FABecauseNewDeviceAsync_ReturnsFalse_When_GranType_Is_AuthorizationCode(SutProvider<UserService> sutProvider, User user)
|
||||
{
|
||||
user.EmailVerified = true;
|
||||
@ -195,7 +196,7 @@ public class UserServiceTests
|
||||
Assert.False(await sutProvider.Sut.Needs2FABecauseNewDeviceAsync(user, deviceIdToCheck, "authorization_code"));
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task Needs2FABecauseNewDeviceAsync_ReturnsFalse_When_Email_Is_Not_Verified(SutProvider<UserService> sutProvider, User user)
|
||||
{
|
||||
user.EmailVerified = false;
|
||||
@ -213,7 +214,7 @@ public class UserServiceTests
|
||||
Assert.False(await sutProvider.Sut.Needs2FABecauseNewDeviceAsync(user, deviceIdToCheck, "password"));
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task Needs2FABecauseNewDeviceAsync_ReturnsFalse_When_Is_The_First_Device(SutProvider<UserService> sutProvider, User user)
|
||||
{
|
||||
user.EmailVerified = true;
|
||||
@ -227,7 +228,7 @@ public class UserServiceTests
|
||||
Assert.False(await sutProvider.Sut.Needs2FABecauseNewDeviceAsync(user, deviceIdToCheck, "password"));
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task Needs2FABecauseNewDeviceAsync_ReturnsFalse_When_DeviceId_Is_Already_In_Repo(SutProvider<UserService> sutProvider, User user)
|
||||
{
|
||||
user.EmailVerified = true;
|
||||
@ -244,7 +245,7 @@ public class UserServiceTests
|
||||
Assert.False(await sutProvider.Sut.Needs2FABecauseNewDeviceAsync(user, deviceIdToCheck, "password"));
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task Needs2FABecauseNewDeviceAsync_ReturnsFalse_When_GlobalSettings_2FA_EmailOnNewDeviceLogin_Is_Disabled(SutProvider<UserService> sutProvider, User user)
|
||||
{
|
||||
user.EmailVerified = true;
|
||||
@ -264,7 +265,7 @@ public class UserServiceTests
|
||||
Assert.False(await sutProvider.Sut.Needs2FABecauseNewDeviceAsync(user, deviceIdToCheck, "password"));
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async Task Needs2FABecauseNewDeviceAsync_ReturnsFalse_When_UnknownDeviceVerification_Is_Disabled(SutProvider<UserService> sutProvider, User user)
|
||||
{
|
||||
user.EmailVerified = true;
|
||||
@ -285,7 +286,7 @@ public class UserServiceTests
|
||||
Assert.False(await sutProvider.Sut.Needs2FABecauseNewDeviceAsync(user, deviceIdToCheck, "password"));
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public void CanEditDeviceVerificationSettings_ReturnsTrue(SutProvider<UserService> sutProvider, User user)
|
||||
{
|
||||
user.EmailVerified = true;
|
||||
@ -296,7 +297,7 @@ public class UserServiceTests
|
||||
Assert.True(sutProvider.Sut.CanEditDeviceVerificationSettings(user));
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public void CanEditDeviceVerificationSettings_ReturnsFalse_When_GlobalSettings_2FA_EmailOnNewDeviceLogin_Is_Disabled(SutProvider<UserService> sutProvider, User user)
|
||||
{
|
||||
user.EmailVerified = true;
|
||||
@ -307,7 +308,7 @@ public class UserServiceTests
|
||||
Assert.False(sutProvider.Sut.CanEditDeviceVerificationSettings(user));
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public void CanEditDeviceVerificationSettings_ReturnsFalse_When_Email_Is_Not_Verified(SutProvider<UserService> sutProvider, User user)
|
||||
{
|
||||
user.EmailVerified = false;
|
||||
@ -318,7 +319,7 @@ public class UserServiceTests
|
||||
Assert.False(sutProvider.Sut.CanEditDeviceVerificationSettings(user));
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public void CanEditDeviceVerificationSettings_ReturnsFalse_When_User_Uses_Key_Connector(SutProvider<UserService> sutProvider, User user)
|
||||
{
|
||||
user.EmailVerified = true;
|
||||
@ -330,7 +331,7 @@ public class UserServiceTests
|
||||
Assert.False(sutProvider.Sut.CanEditDeviceVerificationSettings(user));
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public void CanEditDeviceVerificationSettings_ReturnsFalse_When_User_Has_A_2FA_Already_Set_Up(SutProvider<UserService> sutProvider, User user)
|
||||
{
|
||||
user.EmailVerified = true;
|
||||
@ -348,7 +349,7 @@ public class UserServiceTests
|
||||
Assert.False(sutProvider.Sut.CanEditDeviceVerificationSettings(user));
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async void HasPremiumFromOrganization_Returns_False_If_No_Orgs(SutProvider<UserService> sutProvider, User user)
|
||||
{
|
||||
sutProvider.GetDependency<IOrganizationUserRepository>().GetManyByUserAsync(user.Id).Returns(new List<OrganizationUser>());
|
||||
@ -357,8 +358,8 @@ public class UserServiceTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineCustomAutoData(new[] { typeof(SutProviderCustomization) }, false, true)]
|
||||
[InlineCustomAutoData(new[] { typeof(SutProviderCustomization) }, true, false)]
|
||||
[BitAutoData(false, true)]
|
||||
[BitAutoData(true, false)]
|
||||
public async void HasPremiumFromOrganization_Returns_False_If_Org_Not_Eligible(bool orgEnabled, bool orgUsersGetPremium, SutProvider<UserService> sutProvider, User user, OrganizationUser orgUser, Organization organization)
|
||||
{
|
||||
orgUser.OrganizationId = organization.Id;
|
||||
@ -372,7 +373,7 @@ public class UserServiceTests
|
||||
Assert.False(await sutProvider.Sut.HasPremiumFromOrganization(user));
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(SutProviderCustomization))]
|
||||
[Theory, BitAutoData]
|
||||
public async void HasPremiumFromOrganization_Returns_True_If_Org_Eligible(SutProvider<UserService> sutProvider, User user, OrganizationUser orgUser, Organization organization)
|
||||
{
|
||||
orgUser.OrganizationId = organization.Id;
|
||||
|
@ -286,7 +286,7 @@ public class CoreHelpersTests
|
||||
Assert.Equal("Contents of embeddedResource.txt\n", fileContents.Replace("\r\n", "\n"));
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(UserFixture))]
|
||||
[Theory, BitAutoData, UserCustomize]
|
||||
public void BuildIdentityClaims_BaseClaims_Success(User user, bool isPremium)
|
||||
{
|
||||
var expected = new Dictionary<string, string>
|
||||
@ -308,7 +308,7 @@ public class CoreHelpersTests
|
||||
Assert.Equal(expected.Count, actual.Count);
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(UserFixture))]
|
||||
[Theory, BitAutoData, UserCustomize]
|
||||
public void BuildIdentityClaims_NonCustomOrganizationUserType_Success(User user)
|
||||
{
|
||||
var fixture = new Fixture().WithAutoNSubstitutions();
|
||||
@ -324,7 +324,7 @@ public class CoreHelpersTests
|
||||
}
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(UserFixture))]
|
||||
[Theory, BitAutoData, UserCustomize]
|
||||
public void BuildIdentityClaims_CustomOrganizationUserClaims_Success(User user, CurrentContentOrganization org)
|
||||
{
|
||||
var fixture = new Fixture().WithAutoNSubstitutions();
|
||||
@ -346,7 +346,7 @@ public class CoreHelpersTests
|
||||
}
|
||||
}
|
||||
|
||||
[Theory, CustomAutoData(typeof(UserFixture))]
|
||||
[Theory, BitAutoData, UserCustomize]
|
||||
public void BuildIdentityClaims_ProviderClaims_Success(User user)
|
||||
{
|
||||
var fixture = new Fixture().WithAutoNSubstitutions();
|
||||
|
@ -96,24 +96,12 @@ internal class EfCipher : ICustomization
|
||||
}
|
||||
}
|
||||
|
||||
internal class EfUserCipherAutoDataAttribute : CustomAutoDataAttribute
|
||||
internal class EfUserCipherCustomizeAttribute : BitCustomizeAttribute
|
||||
{
|
||||
public EfUserCipherAutoDataAttribute() : base(new SutProviderCustomization(), new EfCipher())
|
||||
{ }
|
||||
public override ICustomization GetCustomization() => new EfCipher();
|
||||
}
|
||||
|
||||
internal class EfOrganizationCipherAutoDataAttribute : CustomAutoDataAttribute
|
||||
internal class EfOrganizationCipherCustomizeAttribute : BitCustomizeAttribute
|
||||
{
|
||||
public EfOrganizationCipherAutoDataAttribute() : base(new SutProviderCustomization(), new EfCipher()
|
||||
{
|
||||
OrganizationOwned = true,
|
||||
})
|
||||
{ }
|
||||
}
|
||||
|
||||
internal class InlineEfCipherAutoDataAttribute : InlineCustomAutoDataAttribute
|
||||
{
|
||||
public InlineEfCipherAutoDataAttribute(params object[] values) : base(new[] { typeof(SutProviderCustomization),
|
||||
typeof(EfCipher) }, values)
|
||||
{ }
|
||||
public override ICustomization GetCustomization() => new EfCipher();
|
||||
}
|
||||
|
@ -43,15 +43,7 @@ internal class EfCollection : ICustomization
|
||||
}
|
||||
}
|
||||
|
||||
internal class EfCollectionAutoDataAttribute : CustomAutoDataAttribute
|
||||
internal class EfCollectionCustomize : BitCustomizeAttribute
|
||||
{
|
||||
public EfCollectionAutoDataAttribute() : base(new SutProviderCustomization(), new EfCollection())
|
||||
{ }
|
||||
}
|
||||
|
||||
internal class InlineEfCollectionAutoDataAttribute : InlineCustomAutoDataAttribute
|
||||
{
|
||||
public InlineEfCollectionAutoDataAttribute(params object[] values) : base(new[] { typeof(SutProviderCustomization),
|
||||
typeof(EfCollection) }, values)
|
||||
{ }
|
||||
public override ICustomization GetCustomization() => new EfCollection();
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ using Bit.Core.Test.AutoFixture.Attributes;
|
||||
using Bit.Infrastructure.EFIntegration.Test.AutoFixture;
|
||||
using Bit.Infrastructure.EFIntegration.Test.Repositories.EqualityComparers;
|
||||
using Bit.Infrastructure.EntityFramework.Repositories.Queries;
|
||||
using Bit.Test.Common.AutoFixture.Attributes;
|
||||
using LinqToDB;
|
||||
using Xunit;
|
||||
using EfRepo = Bit.Infrastructure.EntityFramework.Repositories;
|
||||
@ -13,7 +14,7 @@ namespace Bit.Infrastructure.EFIntegration.Test.Repositories;
|
||||
|
||||
public class CipherRepositoryTests
|
||||
{
|
||||
[Theory(Skip = "Run ad-hoc"), EfUserCipherAutoData]
|
||||
[Theory(Skip = "Run ad-hoc"), EfUserCipherCustomize, BitAutoData]
|
||||
public async void RefreshDb(List<EfRepo.CipherRepository> suts)
|
||||
{
|
||||
foreach (var sut in suts)
|
||||
@ -22,8 +23,21 @@ public class CipherRepositoryTests
|
||||
}
|
||||
}
|
||||
|
||||
[CiSkippedTheory, EfUserCipherAutoData, EfOrganizationCipherAutoData]
|
||||
public async void CreateAsync_Works_DataMatches(Cipher cipher, User user, Organization org,
|
||||
[CiSkippedTheory, EfUserCipherCustomize, BitAutoData]
|
||||
public async void UserCipher_CreateAsync_Works_DataMatches(Cipher cipher, User user, Organization org,
|
||||
CipherCompare equalityComparer, List<EfRepo.CipherRepository> suts, List<EfRepo.UserRepository> efUserRepos,
|
||||
List<EfRepo.OrganizationRepository> efOrgRepos, SqlRepo.CipherRepository sqlCipherRepo,
|
||||
SqlRepo.UserRepository sqlUserRepo, SqlRepo.OrganizationRepository sqlOrgRepo) => CreateAsync_Works_DataMatches(
|
||||
cipher, user, org, equalityComparer, suts, efUserRepos, efOrgRepos, sqlCipherRepo, sqlUserRepo, sqlOrgRepo);
|
||||
|
||||
[CiSkippedTheory, EfOrganizationCipherCustomize, BitAutoData]
|
||||
public async void OrganizationCipher_CreateAsync_Works_DataMatches(Cipher cipher, User user, Organization org,
|
||||
CipherCompare equalityComparer, List<EfRepo.CipherRepository> suts, List<EfRepo.UserRepository> efUserRepos,
|
||||
List<EfRepo.OrganizationRepository> efOrgRepos, SqlRepo.CipherRepository sqlCipherRepo,
|
||||
SqlRepo.UserRepository sqlUserRepo, SqlRepo.OrganizationRepository sqlOrgRepo) => CreateAsync_Works_DataMatches(
|
||||
cipher, user, org, equalityComparer, suts, efUserRepos, efOrgRepos, sqlCipherRepo, sqlUserRepo, sqlOrgRepo);
|
||||
|
||||
private async void CreateAsync_Works_DataMatches(Cipher cipher, User user, Organization org,
|
||||
CipherCompare equalityComparer, List<EfRepo.CipherRepository> suts, List<EfRepo.UserRepository> efUserRepos,
|
||||
List<EfRepo.OrganizationRepository> efOrgRepos, SqlRepo.CipherRepository sqlCipherRepo,
|
||||
SqlRepo.UserRepository sqlUserRepo, SqlRepo.OrganizationRepository sqlOrgRepo)
|
||||
@ -68,7 +82,7 @@ public class CipherRepositoryTests
|
||||
Assert.True(!distinctItems.Skip(1).Any());
|
||||
}
|
||||
|
||||
[CiSkippedTheory, EfUserCipherAutoData]
|
||||
[CiSkippedTheory, EfUserCipherCustomize, BitAutoData]
|
||||
public async void CreateAsync_BumpsUserAccountRevisionDate(Cipher cipher, User user, List<EfRepo.CipherRepository> suts, List<EfRepo.UserRepository> efUserRepos)
|
||||
{
|
||||
var bumpedUsers = new List<User>();
|
||||
@ -91,7 +105,7 @@ public class CipherRepositoryTests
|
||||
Assert.True(bumpedUsers.All(u => u.AccountRevisionDate.ToShortDateString() == DateTime.UtcNow.ToShortDateString()));
|
||||
}
|
||||
|
||||
[CiSkippedTheory, EfOrganizationCipherAutoData]
|
||||
[CiSkippedTheory, EfOrganizationCipherCustomize, BitAutoData]
|
||||
public async void CreateAsync_BumpsOrgUserAccountRevisionDates(Cipher cipher, List<User> users,
|
||||
List<OrganizationUser> orgUsers, Collection collection, Organization org, List<EfRepo.CipherRepository> suts, List<EfRepo.UserRepository> efUserRepos, List<EfRepo.OrganizationRepository> efOrgRepos,
|
||||
List<EfRepo.OrganizationUserRepository> efOrgUserRepos, List<EfRepo.CollectionRepository> efCollectionRepos)
|
||||
@ -153,8 +167,26 @@ public class CipherRepositoryTests
|
||||
}
|
||||
}
|
||||
|
||||
[CiSkippedTheory, EfUserCipherAutoData, EfOrganizationCipherAutoData]
|
||||
public async void DeleteAsync_CipherIsDeleted(
|
||||
[CiSkippedTheory, EfUserCipherCustomize, BitAutoData]
|
||||
public async Task UserCipher_DeleteAsync_CipherIsDeleted(
|
||||
Cipher cipher,
|
||||
User user,
|
||||
Organization org,
|
||||
List<EfRepo.CipherRepository> suts,
|
||||
List<EfRepo.UserRepository> efUserRepos,
|
||||
List<EfRepo.OrganizationRepository> efOrgRepos
|
||||
) => await DeleteAsync_CipherIsDeleted(cipher, user, org, suts, efUserRepos, efOrgRepos);
|
||||
[CiSkippedTheory, EfOrganizationCipherCustomize, BitAutoData]
|
||||
public async Task OrganizationCipher_DeleteAsync_CipherIsDeleted(
|
||||
Cipher cipher,
|
||||
User user,
|
||||
Organization org,
|
||||
List<EfRepo.CipherRepository> suts,
|
||||
List<EfRepo.UserRepository> efUserRepos,
|
||||
List<EfRepo.OrganizationRepository> efOrgRepos
|
||||
) => DeleteAsync_CipherIsDeleted(cipher, user, org, suts, efUserRepos, efOrgRepos);
|
||||
|
||||
private async Task DeleteAsync_CipherIsDeleted(
|
||||
Cipher cipher,
|
||||
User user,
|
||||
Organization org,
|
||||
|
@ -2,15 +2,17 @@
|
||||
using Bit.Core.Test.AutoFixture.Attributes;
|
||||
using Bit.Infrastructure.EFIntegration.Test.AutoFixture;
|
||||
using Bit.Infrastructure.EFIntegration.Test.Repositories.EqualityComparers;
|
||||
using Bit.Test.Common.AutoFixture.Attributes;
|
||||
using Xunit;
|
||||
using EfRepo = Bit.Infrastructure.EntityFramework.Repositories;
|
||||
using SqlRepo = Bit.Infrastructure.Dapper.Repositories;
|
||||
|
||||
namespace Bit.Infrastructure.EFIntegration.Test.Repositories;
|
||||
|
||||
[EfCollectionCustomize]
|
||||
public class CollectionRepositoryTests
|
||||
{
|
||||
[CiSkippedTheory, EfCollectionAutoData]
|
||||
[CiSkippedTheory, BitAutoData]
|
||||
public async void CreateAsync_Works_DataMatches(
|
||||
Collection collection,
|
||||
Organization organization,
|
||||
|
Loading…
Reference in New Issue
Block a user