diff --git a/.github/renovate.json5 b/.github/renovate.json5
index bc377ed46c..62a483f4d2 100644
--- a/.github/renovate.json5
+++ b/.github/renovate.json5
@@ -80,7 +80,7 @@
{
matchPackageNames: [
"AutoFixture.AutoNSubstitute",
- "AutoFixture.Xunit2",
+ "AutoFixture.Xunit3",
"BenchmarkDotNet",
"BitPay.Light",
"Braintree",
@@ -98,8 +98,7 @@
"Stripe.net",
"Swashbuckle.AspNetCore",
"Swashbuckle.AspNetCore.SwaggerGen",
- "xunit",
- "xunit.runner.visualstudio",
+ "xunit.v3",
],
description: "Billing owned dependencies",
commitMessagePrefix: "[deps] Billing:",
diff --git a/Directory.Build.props b/Directory.Build.props
index 3e55b8a8cc..73a51fac8b 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -11,23 +11,29 @@
annotations
enable
true
+ $(WarningsNotAsErrors);xUnit1051
+
+
+
+ Exe
+ true
+ true
-
-
+
17.8.0
-
- 2.6.6
-
- 2.5.6
-
+
+ 3.0.1
+
+ 3.1.4
+
6.0.0
-
+
5.1.0
-
- 4.18.1
-
+
+ 4.19.0
+
4.18.1
-
\ No newline at end of file
+
diff --git a/bitwarden_license/test/Commercial.Core.Test/AdminConsole/AutoFixture/ProviderUserFixtures.cs b/bitwarden_license/test/Commercial.Core.Test/AdminConsole/AutoFixture/ProviderUserFixtures.cs
index fc47e80c87..1651ba25e2 100644
--- a/bitwarden_license/test/Commercial.Core.Test/AdminConsole/AutoFixture/ProviderUserFixtures.cs
+++ b/bitwarden_license/test/Commercial.Core.Test/AdminConsole/AutoFixture/ProviderUserFixtures.cs
@@ -1,6 +1,6 @@
using System.Reflection;
using AutoFixture;
-using AutoFixture.Xunit2;
+using AutoFixture.Xunit3;
using Bit.Core.AdminConsole.Enums.Provider;
namespace Bit.Commercial.Core.Test.AdminConsole.AutoFixture;
diff --git a/bitwarden_license/test/Commercial.Core.Test/Commercial.Core.Test.csproj b/bitwarden_license/test/Commercial.Core.Test/Commercial.Core.Test.csproj
index 6c92db92b9..7249b441b9 100644
--- a/bitwarden_license/test/Commercial.Core.Test/Commercial.Core.Test.csproj
+++ b/bitwarden_license/test/Commercial.Core.Test/Commercial.Core.Test.csproj
@@ -5,12 +5,7 @@
-
-
-
- runtime; build; native; contentfiles; analyzers; buildtransitive
- all
-
+
runtime; build; native; contentfiles; analyzers; buildtransitive
all
diff --git a/bitwarden_license/test/Commercial.Core.Test/SecretsManager/Queries/AccessPolicies/ProjectServiceAccountsAccessPoliciesUpdatesQueryTests.cs b/bitwarden_license/test/Commercial.Core.Test/SecretsManager/Queries/AccessPolicies/ProjectServiceAccountsAccessPoliciesUpdatesQueryTests.cs
index ce11cde2b5..ec919d8ead 100644
--- a/bitwarden_license/test/Commercial.Core.Test/SecretsManager/Queries/AccessPolicies/ProjectServiceAccountsAccessPoliciesUpdatesQueryTests.cs
+++ b/bitwarden_license/test/Commercial.Core.Test/SecretsManager/Queries/AccessPolicies/ProjectServiceAccountsAccessPoliciesUpdatesQueryTests.cs
@@ -75,11 +75,11 @@ public class ProjectServiceAccountsAccessPoliciesUpdatesQueryTests
Assert.Equal(data.ProjectId, result.ProjectId);
Assert.Equal(data.OrganizationId, result.OrganizationId);
- Assert.Single(result.ServiceAccountAccessPolicyUpdates.Where(x =>
- x.Operation == AccessPolicyOperation.Delete && x.AccessPolicy == currentPolicyToDelete));
- Assert.Single(result.ServiceAccountAccessPolicyUpdates.Where(x =>
+ Assert.Single(result.ServiceAccountAccessPolicyUpdates, x =>
+ x.Operation == AccessPolicyOperation.Delete && x.AccessPolicy == currentPolicyToDelete);
+ Assert.Single(result.ServiceAccountAccessPolicyUpdates, x =>
x.Operation == AccessPolicyOperation.Update &&
- x.AccessPolicy.GrantedProjectId == updatePolicy.GrantedProjectId));
+ x.AccessPolicy.GrantedProjectId == updatePolicy.GrantedProjectId);
Assert.Equal(result.ServiceAccountAccessPolicyUpdates.Count() - 2,
result.ServiceAccountAccessPolicyUpdates.Count(x => x.Operation == AccessPolicyOperation.Create));
}
diff --git a/bitwarden_license/test/Commercial.Core.Test/SecretsManager/Queries/AccessPolicies/SecretAccessPoliciesUpdatesQueryTests.cs b/bitwarden_license/test/Commercial.Core.Test/SecretsManager/Queries/AccessPolicies/SecretAccessPoliciesUpdatesQueryTests.cs
index 0402a9086a..653218caa8 100644
--- a/bitwarden_license/test/Commercial.Core.Test/SecretsManager/Queries/AccessPolicies/SecretAccessPoliciesUpdatesQueryTests.cs
+++ b/bitwarden_license/test/Commercial.Core.Test/SecretsManager/Queries/AccessPolicies/SecretAccessPoliciesUpdatesQueryTests.cs
@@ -88,27 +88,27 @@ public class SecretAccessPoliciesUpdatesQueryTests
Assert.Equal(data.SecretId, result.SecretId);
Assert.Equal(data.OrganizationId, result.OrganizationId);
- Assert.Single(result.UserAccessPolicyUpdates.Where(x =>
- x.Operation == AccessPolicyOperation.Delete && x.AccessPolicy == userPolicyChanges.Delete));
- Assert.Single(result.UserAccessPolicyUpdates.Where(x =>
+ Assert.Single(result.UserAccessPolicyUpdates, x =>
+ x.Operation == AccessPolicyOperation.Delete && x.AccessPolicy == userPolicyChanges.Delete);
+ Assert.Single(result.UserAccessPolicyUpdates, x =>
x.Operation == AccessPolicyOperation.Update &&
- x.AccessPolicy.OrganizationUserId == userPolicyChanges.Update.OrganizationUserId));
+ x.AccessPolicy.OrganizationUserId == userPolicyChanges.Update.OrganizationUserId);
Assert.Equal(result.UserAccessPolicyUpdates.Count() - 2,
result.UserAccessPolicyUpdates.Count(x => x.Operation == AccessPolicyOperation.Create));
- Assert.Single(result.GroupAccessPolicyUpdates.Where(x =>
- x.Operation == AccessPolicyOperation.Delete && x.AccessPolicy == groupPolicyChanges.Delete));
- Assert.Single(result.GroupAccessPolicyUpdates.Where(x =>
+ Assert.Single(result.GroupAccessPolicyUpdates, x =>
+ x.Operation == AccessPolicyOperation.Delete && x.AccessPolicy == groupPolicyChanges.Delete);
+ Assert.Single(result.GroupAccessPolicyUpdates, x =>
x.Operation == AccessPolicyOperation.Update &&
- x.AccessPolicy.GroupId == groupPolicyChanges.Update.GroupId));
+ x.AccessPolicy.GroupId == groupPolicyChanges.Update.GroupId);
Assert.Equal(result.GroupAccessPolicyUpdates.Count() - 2,
result.GroupAccessPolicyUpdates.Count(x => x.Operation == AccessPolicyOperation.Create));
- Assert.Single(result.ServiceAccountAccessPolicyUpdates.Where(x =>
- x.Operation == AccessPolicyOperation.Delete && x.AccessPolicy == serviceAccountPolicyChanges.Delete));
- Assert.Single(result.ServiceAccountAccessPolicyUpdates.Where(x =>
+ Assert.Single(result.ServiceAccountAccessPolicyUpdates, x =>
+ x.Operation == AccessPolicyOperation.Delete && x.AccessPolicy == serviceAccountPolicyChanges.Delete);
+ Assert.Single(result.ServiceAccountAccessPolicyUpdates, x =>
x.Operation == AccessPolicyOperation.Update &&
- x.AccessPolicy.ServiceAccountId == serviceAccountPolicyChanges.Update.ServiceAccountId));
+ x.AccessPolicy.ServiceAccountId == serviceAccountPolicyChanges.Update.ServiceAccountId);
Assert.Equal(result.ServiceAccountAccessPolicyUpdates.Count() - 2,
result.ServiceAccountAccessPolicyUpdates.Count(x => x.Operation == AccessPolicyOperation.Create));
}
diff --git a/bitwarden_license/test/Commercial.Core.Test/SecretsManager/Queries/AccessPolicies/ServiceAccountGrantedPolicyUpdatesQueryTests.cs b/bitwarden_license/test/Commercial.Core.Test/SecretsManager/Queries/AccessPolicies/ServiceAccountGrantedPolicyUpdatesQueryTests.cs
index 64ee4cd34e..835baa0c0c 100644
--- a/bitwarden_license/test/Commercial.Core.Test/SecretsManager/Queries/AccessPolicies/ServiceAccountGrantedPolicyUpdatesQueryTests.cs
+++ b/bitwarden_license/test/Commercial.Core.Test/SecretsManager/Queries/AccessPolicies/ServiceAccountGrantedPolicyUpdatesQueryTests.cs
@@ -75,11 +75,11 @@ public class ServiceAccountGrantedPolicyUpdatesQueryTests
Assert.Equal(data.ServiceAccountId, result.ServiceAccountId);
Assert.Equal(data.OrganizationId, result.OrganizationId);
- Assert.Single(result.ProjectGrantedPolicyUpdates.Where(x =>
- x.Operation == AccessPolicyOperation.Delete && x.AccessPolicy == currentPolicyToDelete));
- Assert.Single(result.ProjectGrantedPolicyUpdates.Where(x =>
+ Assert.Single(result.ProjectGrantedPolicyUpdates, x =>
+ x.Operation == AccessPolicyOperation.Delete && x.AccessPolicy == currentPolicyToDelete);
+ Assert.Single(result.ProjectGrantedPolicyUpdates, x =>
x.Operation == AccessPolicyOperation.Update &&
- x.AccessPolicy.GrantedProjectId == updatePolicy.GrantedProjectId));
+ x.AccessPolicy.GrantedProjectId == updatePolicy.GrantedProjectId);
Assert.Equal(result.ProjectGrantedPolicyUpdates.Count() - 2,
result.ProjectGrantedPolicyUpdates.Count(x => x.Operation == AccessPolicyOperation.Create));
}
diff --git a/bitwarden_license/test/SSO.Test/Controllers/AccountControllerTest.cs b/bitwarden_license/test/SSO.Test/Controllers/AccountControllerTest.cs
index c04948e21f..aeba01fa80 100644
--- a/bitwarden_license/test/SSO.Test/Controllers/AccountControllerTest.cs
+++ b/bitwarden_license/test/SSO.Test/Controllers/AccountControllerTest.cs
@@ -23,7 +23,6 @@ using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;
using NSubstitute;
-using Xunit.Abstractions;
using AuthenticationOptions = Duende.IdentityServer.Configuration.AuthenticationOptions;
namespace Bit.SSO.Test.Controllers;
diff --git a/bitwarden_license/test/SSO.Test/SSO.Test.csproj b/bitwarden_license/test/SSO.Test/SSO.Test.csproj
index 4b509c9a50..260f9ece02 100644
--- a/bitwarden_license/test/SSO.Test/SSO.Test.csproj
+++ b/bitwarden_license/test/SSO.Test/SSO.Test.csproj
@@ -10,12 +10,7 @@
-
-
-
- runtime; build; native; contentfiles; analyzers; buildtransitive
- all
-
+
runtime; build; native; contentfiles; analyzers; buildtransitive
all
diff --git a/bitwarden_license/test/Scim.IntegrationTest/Controllers/v2/GroupsControllerPatchTests.cs b/bitwarden_license/test/Scim.IntegrationTest/Controllers/v2/GroupsControllerPatchTests.cs
index 66ce386d07..014a5813b9 100644
--- a/bitwarden_license/test/Scim.IntegrationTest/Controllers/v2/GroupsControllerPatchTests.cs
+++ b/bitwarden_license/test/Scim.IntegrationTest/Controllers/v2/GroupsControllerPatchTests.cs
@@ -16,15 +16,15 @@ public class GroupsControllerPatchTests : IClassFixture,
_factory = factory;
}
- public Task InitializeAsync()
+ public ValueTask InitializeAsync()
{
var databaseContext = _factory.GetDatabaseContext();
_factory.ReinitializeDbForTests(databaseContext);
- return Task.CompletedTask;
+ return ValueTask.CompletedTask;
}
- Task IAsyncLifetime.DisposeAsync() => Task.CompletedTask;
+ ValueTask IAsyncDisposable.DisposeAsync() => ValueTask.CompletedTask;
[Fact]
public async Task Patch_ReplaceDisplayName_Success()
diff --git a/bitwarden_license/test/Scim.IntegrationTest/Controllers/v2/GroupsControllerTests.cs b/bitwarden_license/test/Scim.IntegrationTest/Controllers/v2/GroupsControllerTests.cs
index 5f562a30c5..f276515f54 100644
--- a/bitwarden_license/test/Scim.IntegrationTest/Controllers/v2/GroupsControllerTests.cs
+++ b/bitwarden_license/test/Scim.IntegrationTest/Controllers/v2/GroupsControllerTests.cs
@@ -16,14 +16,14 @@ public class GroupsControllerTests : IClassFixture, IAsy
_factory = factory;
}
- public Task InitializeAsync()
+ public ValueTask InitializeAsync()
{
var databaseContext = _factory.GetDatabaseContext();
_factory.ReinitializeDbForTests(databaseContext);
- return Task.CompletedTask;
+ return ValueTask.CompletedTask;
}
- Task IAsyncLifetime.DisposeAsync() => Task.CompletedTask;
+ ValueTask IAsyncDisposable.DisposeAsync() => ValueTask.CompletedTask;
[Fact]
public async Task Get_Success()
diff --git a/bitwarden_license/test/Scim.IntegrationTest/Controllers/v2/UsersControllerTests.cs b/bitwarden_license/test/Scim.IntegrationTest/Controllers/v2/UsersControllerTests.cs
index 1f86d99b63..a1237db3c8 100644
--- a/bitwarden_license/test/Scim.IntegrationTest/Controllers/v2/UsersControllerTests.cs
+++ b/bitwarden_license/test/Scim.IntegrationTest/Controllers/v2/UsersControllerTests.cs
@@ -22,14 +22,14 @@ public class UsersControllerTests : IClassFixture, IAsyn
_factory = factory;
}
- public Task InitializeAsync()
+ public ValueTask InitializeAsync()
{
var databaseContext = _factory.GetDatabaseContext();
_factory.ReinitializeDbForTests(databaseContext);
- return Task.CompletedTask;
+ return ValueTask.CompletedTask;
}
- Task IAsyncLifetime.DisposeAsync() => Task.CompletedTask;
+ ValueTask IAsyncDisposable.DisposeAsync() => ValueTask.CompletedTask;
[Fact]
public async Task Get_Success()
diff --git a/bitwarden_license/test/Scim.IntegrationTest/Scim.IntegrationTest.csproj b/bitwarden_license/test/Scim.IntegrationTest/Scim.IntegrationTest.csproj
index 4fc79f2025..270a970701 100644
--- a/bitwarden_license/test/Scim.IntegrationTest/Scim.IntegrationTest.csproj
+++ b/bitwarden_license/test/Scim.IntegrationTest/Scim.IntegrationTest.csproj
@@ -10,14 +10,9 @@
all
-
-
-
- runtime; build; native; contentfiles; analyzers; buildtransitive
- all
-
-
+
+
diff --git a/bitwarden_license/test/Scim.Test/Scim.Test.csproj b/bitwarden_license/test/Scim.Test/Scim.Test.csproj
index 2950103e7d..8ad2d23ecf 100644
--- a/bitwarden_license/test/Scim.Test/Scim.Test.csproj
+++ b/bitwarden_license/test/Scim.Test/Scim.Test.csproj
@@ -5,12 +5,7 @@
-
-
-
- runtime; build; native; contentfiles; analyzers; buildtransitive
- all
-
+
runtime; build; native; contentfiles; analyzers; buildtransitive
all
@@ -22,4 +17,4 @@
-
\ No newline at end of file
+
diff --git a/test/Admin.Test/Admin.Test.csproj b/test/Admin.Test/Admin.Test.csproj
index 585da019d0..19772fe8fc 100644
--- a/test/Admin.Test/Admin.Test.csproj
+++ b/test/Admin.Test/Admin.Test.csproj
@@ -8,13 +8,7 @@
runtime; build; native; contentfiles; analyzers; buildtransitive
all
-
-
-
- all
- runtime; build; native; contentfiles; analyzers
-
+
diff --git a/test/Api.IntegrationTest/AdminConsole/Controllers/OrganizationUserControllerTests.cs b/test/Api.IntegrationTest/AdminConsole/Controllers/OrganizationUserControllerTests.cs
index 7c61a88bd8..eedb4f8ed0 100644
--- a/test/Api.IntegrationTest/AdminConsole/Controllers/OrganizationUserControllerTests.cs
+++ b/test/Api.IntegrationTest/AdminConsole/Controllers/OrganizationUserControllerTests.cs
@@ -213,7 +213,7 @@ public class OrganizationUserControllerTests : IClassFixture CreateTestDataAsync()
diff --git a/test/Api.IntegrationTest/AdminConsole/Controllers/OrganizationUsersControllerPerformanceTests.cs b/test/Api.IntegrationTest/AdminConsole/Controllers/OrganizationUsersControllerPerformanceTests.cs
index d77a41f52e..2283a31f4d 100644
--- a/test/Api.IntegrationTest/AdminConsole/Controllers/OrganizationUsersControllerPerformanceTests.cs
+++ b/test/Api.IntegrationTest/AdminConsole/Controllers/OrganizationUsersControllerPerformanceTests.cs
@@ -3,7 +3,6 @@ using System.Net.Http.Headers;
using Bit.Api.IntegrationTest.Factories;
using Bit.Seeder.Recipes;
using Xunit;
-using Xunit.Abstractions;
namespace Bit.Api.IntegrationTest.AdminConsole.Controllers;
diff --git a/test/Api.IntegrationTest/AdminConsole/Controllers/OrganizationUsersControllerPutResetPasswordTests.cs b/test/Api.IntegrationTest/AdminConsole/Controllers/OrganizationUsersControllerPutResetPasswordTests.cs
index cf842d1568..f802f24da0 100644
--- a/test/Api.IntegrationTest/AdminConsole/Controllers/OrganizationUsersControllerPutResetPasswordTests.cs
+++ b/test/Api.IntegrationTest/AdminConsole/Controllers/OrganizationUsersControllerPutResetPasswordTests.cs
@@ -42,7 +42,7 @@ public class OrganizationUsersControllerPutResetPasswordTests : IClassFixture
diff --git a/test/Api.IntegrationTest/AdminConsole/Controllers/PoliciesControllerTests.cs b/test/Api.IntegrationTest/AdminConsole/Controllers/PoliciesControllerTests.cs
index e4098ce9a9..54fca1fd39 100644
--- a/test/Api.IntegrationTest/AdminConsole/Controllers/PoliciesControllerTests.cs
+++ b/test/Api.IntegrationTest/AdminConsole/Controllers/PoliciesControllerTests.cs
@@ -39,7 +39,7 @@ public class PoliciesControllerTests : IClassFixture, IAs
_loginHelper = new LoginHelper(_factory, _client);
}
- public async Task InitializeAsync()
+ public async ValueTask InitializeAsync()
{
_ownerEmail = $"integration-test{Guid.NewGuid()}@bitwarden.com";
await _factory.LoginWithNewAccount(_ownerEmail);
@@ -50,10 +50,10 @@ public class PoliciesControllerTests : IClassFixture, IAs
await _loginHelper.LoginAsync(_ownerEmail);
}
- public Task DisposeAsync()
+ public ValueTask DisposeAsync()
{
_client.Dispose();
- return Task.CompletedTask;
+ return ValueTask.CompletedTask;
}
[Fact]
diff --git a/test/Api.IntegrationTest/AdminConsole/Import/ImportOrganizationUsersAndGroupsCommandTests.cs b/test/Api.IntegrationTest/AdminConsole/Import/ImportOrganizationUsersAndGroupsCommandTests.cs
index 32c7f75a2b..08df8640d4 100644
--- a/test/Api.IntegrationTest/AdminConsole/Import/ImportOrganizationUsersAndGroupsCommandTests.cs
+++ b/test/Api.IntegrationTest/AdminConsole/Import/ImportOrganizationUsersAndGroupsCommandTests.cs
@@ -26,7 +26,7 @@ public class ImportOrganizationUsersAndGroupsCommandTests : IClassFixture, IAsy
_loginHelper = new LoginHelper(_factory, _client);
}
- public async Task InitializeAsync()
+ public async ValueTask InitializeAsync()
{
// Create the owner account
_ownerEmail = $"integration-test{Guid.NewGuid()}@bitwarden.com";
@@ -46,10 +46,10 @@ public class MembersControllerTests : IClassFixture, IAsy
await _loginHelper.LoginWithOrganizationApiKeyAsync(_organization.Id);
}
- public Task DisposeAsync()
+ public ValueTask DisposeAsync()
{
_client.Dispose();
- return Task.CompletedTask;
+ return ValueTask.CompletedTask;
}
[Fact]
diff --git a/test/Api.IntegrationTest/AdminConsole/Public/Controllers/PoliciesControllerTests.cs b/test/Api.IntegrationTest/AdminConsole/Public/Controllers/PoliciesControllerTests.cs
index 0b5ab660b9..3fe1727a9e 100644
--- a/test/Api.IntegrationTest/AdminConsole/Public/Controllers/PoliciesControllerTests.cs
+++ b/test/Api.IntegrationTest/AdminConsole/Public/Controllers/PoliciesControllerTests.cs
@@ -32,7 +32,7 @@ public class PoliciesControllerTests : IClassFixture, IAs
_loginHelper = new LoginHelper(_factory, _client);
}
- public async Task InitializeAsync()
+ public async ValueTask InitializeAsync()
{
// Create the owner account
_ownerEmail = $"integration-test{Guid.NewGuid()}@bitwarden.com";
@@ -46,10 +46,10 @@ public class PoliciesControllerTests : IClassFixture, IAs
await _loginHelper.LoginWithOrganizationApiKeyAsync(_organization.Id);
}
- public Task DisposeAsync()
+ public ValueTask DisposeAsync()
{
_client.Dispose();
- return Task.CompletedTask;
+ return ValueTask.CompletedTask;
}
[Fact]
diff --git a/test/Api.IntegrationTest/Api.IntegrationTest.csproj b/test/Api.IntegrationTest/Api.IntegrationTest.csproj
index a9d7fd502e..58d5eb50e3 100644
--- a/test/Api.IntegrationTest/Api.IntegrationTest.csproj
+++ b/test/Api.IntegrationTest/Api.IntegrationTest.csproj
@@ -4,12 +4,7 @@
-
-
-
- runtime; build; native; contentfiles; analyzers; buildtransitive
- all
-
+
runtime; build; native; contentfiles; analyzers; buildtransitive
all
diff --git a/test/Api.IntegrationTest/Controllers/AccountsControllerTest.cs b/test/Api.IntegrationTest/Controllers/AccountsControllerTest.cs
index 09ec5b010f..ad8f88bff6 100644
--- a/test/Api.IntegrationTest/Controllers/AccountsControllerTest.cs
+++ b/test/Api.IntegrationTest/Controllers/AccountsControllerTest.cs
@@ -51,16 +51,16 @@ public class AccountsControllerTest : IClassFixture, IAsy
_passwordHasher = _factory.GetService>();
}
- public async Task InitializeAsync()
+ public async ValueTask InitializeAsync()
{
_ownerEmail = $"integration-test{Guid.NewGuid()}@bitwarden.com";
await _factory.LoginWithNewAccount(_ownerEmail);
}
- public Task DisposeAsync()
+ public ValueTask DisposeAsync()
{
_client.Dispose();
- return Task.CompletedTask;
+ return ValueTask.CompletedTask;
}
[Fact]
diff --git a/test/Api.IntegrationTest/Controllers/ConfigControllerTests.cs b/test/Api.IntegrationTest/Controllers/ConfigControllerTests.cs
index 73fa3aba7d..bfe4c3201b 100644
--- a/test/Api.IntegrationTest/Controllers/ConfigControllerTests.cs
+++ b/test/Api.IntegrationTest/Controllers/ConfigControllerTests.cs
@@ -21,7 +21,7 @@ public class ConfigControllerTests : IClassFixture, IAsyn
_client = _factory.CreateClient();
}
- public async Task InitializeAsync()
+ public async ValueTask InitializeAsync()
{
_email = $"integration-test{Guid.NewGuid()}@bitwarden.com";
@@ -29,10 +29,10 @@ public class ConfigControllerTests : IClassFixture, IAsyn
_client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tokens.Token);
}
- public Task DisposeAsync()
+ public ValueTask DisposeAsync()
{
_client.Dispose();
- return Task.CompletedTask;
+ return ValueTask.CompletedTask;
}
private async Task LoginAsync()
diff --git a/test/Api.IntegrationTest/KeyManagement/Controllers/AccountsKeyManagementControllerTests.cs b/test/Api.IntegrationTest/KeyManagement/Controllers/AccountsKeyManagementControllerTests.cs
index 1630bc0dc0..125d62b242 100644
--- a/test/Api.IntegrationTest/KeyManagement/Controllers/AccountsKeyManagementControllerTests.cs
+++ b/test/Api.IntegrationTest/KeyManagement/Controllers/AccountsKeyManagementControllerTests.cs
@@ -58,16 +58,16 @@ public class AccountsKeyManagementControllerTests : IClassFixture();
}
- public async Task InitializeAsync()
+ public async ValueTask InitializeAsync()
{
_ownerEmail = $"integration-test{Guid.NewGuid()}@bitwarden.com";
await _factory.LoginWithNewAccount(_ownerEmail);
}
- public Task DisposeAsync()
+ public ValueTask DisposeAsync()
{
_client.Dispose();
- return Task.CompletedTask;
+ return ValueTask.CompletedTask;
}
[Theory]
diff --git a/test/Api.IntegrationTest/NotificationCenter/Controllers/NotificationsControllerTests.cs b/test/Api.IntegrationTest/NotificationCenter/Controllers/NotificationsControllerTests.cs
index ca04c9775d..ca1da061b2 100644
--- a/test/Api.IntegrationTest/NotificationCenter/Controllers/NotificationsControllerTests.cs
+++ b/test/Api.IntegrationTest/NotificationCenter/Controllers/NotificationsControllerTests.cs
@@ -49,7 +49,7 @@ public class NotificationsControllerTests : IClassFixture
_userRepository = _factory.GetService();
}
- public async Task InitializeAsync()
+ public async ValueTask InitializeAsync()
{
// Create the owner account
_ownerEmail = $"integration-test{Guid.NewGuid()}@bitwarden.com";
@@ -63,7 +63,7 @@ public class NotificationsControllerTests : IClassFixture
_notificationsWithStatuses = await CreateNotificationsWithStatusesAsync();
}
- public Task DisposeAsync()
+ public ValueTask DisposeAsync()
{
_client.Dispose();
@@ -72,7 +72,7 @@ public class NotificationsControllerTests : IClassFixture
_notificationRepository.DeleteAsync(notification);
}
- return Task.CompletedTask;
+ return ValueTask.CompletedTask;
}
[Theory]
@@ -220,7 +220,7 @@ public class NotificationsControllerTests : IClassFixture
}
[Fact]
- private async void MarkAsDeletedAsync_NotLoggedIn_Unauthorized()
+ private async Task MarkAsDeletedAsync_NotLoggedIn_Unauthorized()
{
var url = $"/notifications/{Guid.NewGuid().ToString()}/delete";
var response = await _client.PatchAsync(url, new StringContent(""));
@@ -228,7 +228,7 @@ public class NotificationsControllerTests : IClassFixture
}
[Fact]
- private async void MarkAsDeletedAsync_NonExistentNotificationId_NotFound()
+ private async Task MarkAsDeletedAsync_NonExistentNotificationId_NotFound()
{
await _loginHelper.LoginAsync(_ownerEmail);
@@ -238,7 +238,7 @@ public class NotificationsControllerTests : IClassFixture
}
[Fact]
- private async void MarkAsDeletedAsync_UserIdNotMatching_NotFound()
+ private async Task MarkAsDeletedAsync_UserIdNotMatching_NotFound()
{
var email = $"integration-test{Guid.NewGuid()}@bitwarden.com";
await _factory.LoginWithNewAccount(email);
@@ -253,7 +253,7 @@ public class NotificationsControllerTests : IClassFixture
}
[Fact]
- private async void MarkAsDeletedAsync_OrganizationIdNotMatchingUserNotPartOfOrganization_NotFound()
+ private async Task MarkAsDeletedAsync_OrganizationIdNotMatchingUserNotPartOfOrganization_NotFound()
{
var email = $"integration-test{Guid.NewGuid()}@bitwarden.com";
await _factory.LoginWithNewAccount(email);
@@ -268,7 +268,7 @@ public class NotificationsControllerTests : IClassFixture
}
[Fact]
- private async void MarkAsDeletedAsync_OrganizationIdNotMatchingUserPartOfDifferentOrganization_NotFound()
+ private async Task MarkAsDeletedAsync_OrganizationIdNotMatchingUserPartOfDifferentOrganization_NotFound()
{
var (organization, _) = await OrganizationTestHelpers.SignUpAsync(_factory,
plan: PlanType.EnterpriseAnnually, ownerEmail: _ownerEmail, passwordManagerSeats: 10,
@@ -287,7 +287,7 @@ public class NotificationsControllerTests : IClassFixture
}
[Fact]
- private async void MarkAsDeletedAsync_NotificationStatusNotExisting_Created()
+ private async Task MarkAsDeletedAsync_NotificationStatusNotExisting_Created()
{
var notifications = await CreateNotificationsAsync(_organizationUserOwner.UserId);
@@ -308,7 +308,7 @@ public class NotificationsControllerTests : IClassFixture
[Theory]
[InlineData(false)]
[InlineData(true)]
- private async void MarkAsDeletedAsync_NotificationStatusExisting_Updated(bool deletedDateNull)
+ private async Task MarkAsDeletedAsync_NotificationStatusExisting_Updated(bool deletedDateNull)
{
var notifications = await CreateNotificationsAsync(_organizationUserOwner.UserId);
await _notificationStatusRepository.CreateAsync(new NotificationStatus
@@ -334,7 +334,7 @@ public class NotificationsControllerTests : IClassFixture
}
[Fact]
- private async void MarkAsReadAsync_NotLoggedIn_Unauthorized()
+ private async Task MarkAsReadAsync_NotLoggedIn_Unauthorized()
{
var url = $"/notifications/{Guid.NewGuid().ToString()}/read";
var response = await _client.PatchAsync(url, new StringContent(""));
@@ -342,7 +342,7 @@ public class NotificationsControllerTests : IClassFixture
}
[Fact]
- private async void MarkAsReadAsync_NonExistentNotificationId_NotFound()
+ private async Task MarkAsReadAsync_NonExistentNotificationId_NotFound()
{
await _loginHelper.LoginAsync(_ownerEmail);
@@ -352,7 +352,7 @@ public class NotificationsControllerTests : IClassFixture
}
[Fact]
- private async void MarkAsReadAsync_UserIdNotMatching_NotFound()
+ private async Task MarkAsReadAsync_UserIdNotMatching_NotFound()
{
var email = $"integration-test{Guid.NewGuid()}@bitwarden.com";
await _factory.LoginWithNewAccount(email);
@@ -367,7 +367,7 @@ public class NotificationsControllerTests : IClassFixture
}
[Fact]
- private async void MarkAsReadAsync_OrganizationIdNotMatchingUserNotPartOfOrganization_NotFound()
+ private async Task MarkAsReadAsync_OrganizationIdNotMatchingUserNotPartOfOrganization_NotFound()
{
var email = $"integration-test{Guid.NewGuid()}@bitwarden.com";
await _factory.LoginWithNewAccount(email);
@@ -382,7 +382,7 @@ public class NotificationsControllerTests : IClassFixture
}
[Fact]
- private async void MarkAsReadAsync_OrganizationIdNotMatchingUserPartOfDifferentOrganization_NotFound()
+ private async Task MarkAsReadAsync_OrganizationIdNotMatchingUserPartOfDifferentOrganization_NotFound()
{
var (organization, _) = await OrganizationTestHelpers.SignUpAsync(_factory,
plan: PlanType.EnterpriseAnnually, ownerEmail: _ownerEmail, passwordManagerSeats: 10,
@@ -401,7 +401,7 @@ public class NotificationsControllerTests : IClassFixture
}
[Fact]
- private async void MarkAsReadAsync_NotificationStatusNotExisting_Created()
+ private async Task MarkAsReadAsync_NotificationStatusNotExisting_Created()
{
var notifications = await CreateNotificationsAsync(_organizationUserOwner.UserId);
@@ -422,7 +422,7 @@ public class NotificationsControllerTests : IClassFixture
[Theory]
[InlineData(false)]
[InlineData(true)]
- private async void MarkAsReadAsync_NotificationStatusExisting_Updated(bool readDateNull)
+ private async Task MarkAsReadAsync_NotificationStatusExisting_Updated(bool readDateNull)
{
var notifications = await CreateNotificationsAsync(_organizationUserOwner.UserId);
await _notificationStatusRepository.CreateAsync(new NotificationStatus
diff --git a/test/Api.IntegrationTest/SecretsManager/Controllers/AccessPoliciesControllerTests.cs b/test/Api.IntegrationTest/SecretsManager/Controllers/AccessPoliciesControllerTests.cs
index 77614574c1..6a1619a416 100644
--- a/test/Api.IntegrationTest/SecretsManager/Controllers/AccessPoliciesControllerTests.cs
+++ b/test/Api.IntegrationTest/SecretsManager/Controllers/AccessPoliciesControllerTests.cs
@@ -44,17 +44,17 @@ public class AccessPoliciesControllerTests : IClassFixture, IAsyn
}
- public async Task InitializeAsync()
+ public async ValueTask InitializeAsync()
{
_email = $"integration-test{Guid.NewGuid()}@bitwarden.com";
await _factory.LoginWithNewAccount(_email);
_organizationHelper = new SecretsManagerOrganizationHelper(_factory, _email);
}
- public Task DisposeAsync()
+ public ValueTask DisposeAsync()
{
_client.Dispose();
- return Task.CompletedTask;
+ return ValueTask.CompletedTask;
}
[Theory]
diff --git a/test/Api.IntegrationTest/SecretsManager/Controllers/ProjectsControllerTests.cs b/test/Api.IntegrationTest/SecretsManager/Controllers/ProjectsControllerTests.cs
index 099dde5127..8f75a6d8f4 100644
--- a/test/Api.IntegrationTest/SecretsManager/Controllers/ProjectsControllerTests.cs
+++ b/test/Api.IntegrationTest/SecretsManager/Controllers/ProjectsControllerTests.cs
@@ -37,17 +37,17 @@ public class ProjectsControllerTests : IClassFixture, IAs
_loginHelper = new LoginHelper(_factory, _client);
}
- public async Task InitializeAsync()
+ public async ValueTask InitializeAsync()
{
_email = $"integration-test{Guid.NewGuid()}@bitwarden.com";
await _factory.LoginWithNewAccount(_email);
_organizationHelper = new SecretsManagerOrganizationHelper(_factory, _email);
}
- public Task DisposeAsync()
+ public ValueTask DisposeAsync()
{
_client.Dispose();
- return Task.CompletedTask;
+ return ValueTask.CompletedTask;
}
[Theory]
diff --git a/test/Api.IntegrationTest/SecretsManager/Controllers/SecretsControllerTests.cs b/test/Api.IntegrationTest/SecretsManager/Controllers/SecretsControllerTests.cs
index be95c0dc1e..966dd9d544 100644
--- a/test/Api.IntegrationTest/SecretsManager/Controllers/SecretsControllerTests.cs
+++ b/test/Api.IntegrationTest/SecretsManager/Controllers/SecretsControllerTests.cs
@@ -41,17 +41,17 @@ public class SecretsControllerTests : IClassFixture, IAsy
_loginHelper = new LoginHelper(_factory, _client);
}
- public async Task InitializeAsync()
+ public async ValueTask InitializeAsync()
{
_email = $"integration-test{Guid.NewGuid()}@bitwarden.com";
await _factory.LoginWithNewAccount(_email);
_organizationHelper = new SecretsManagerOrganizationHelper(_factory, _email);
}
- public Task DisposeAsync()
+ public ValueTask DisposeAsync()
{
_client.Dispose();
- return Task.CompletedTask;
+ return ValueTask.CompletedTask;
}
[Theory]
diff --git a/test/Api.IntegrationTest/SecretsManager/Controllers/SecretsManagerEventsControllerTests.cs b/test/Api.IntegrationTest/SecretsManager/Controllers/SecretsManagerEventsControllerTests.cs
index 036e307d39..6e0e1bacd6 100644
--- a/test/Api.IntegrationTest/SecretsManager/Controllers/SecretsManagerEventsControllerTests.cs
+++ b/test/Api.IntegrationTest/SecretsManager/Controllers/SecretsManagerEventsControllerTests.cs
@@ -28,17 +28,17 @@ public class SecretsManagerEventsControllerTests : IClassFixture();
}
- public async Task InitializeAsync()
+ public async ValueTask InitializeAsync()
{
_email = $"integration-test{Guid.NewGuid()}@bitwarden.com";
await _factory.LoginWithNewAccount(_email);
_organizationHelper = new SecretsManagerOrganizationHelper(_factory, _email);
}
- public Task DisposeAsync()
+ public ValueTask DisposeAsync()
{
_client.Dispose();
- return Task.CompletedTask;
+ return ValueTask.CompletedTask;
}
private async Task LoginAsync(string email)
diff --git a/test/Api.IntegrationTest/SecretsManager/Controllers/SecretsManagerPortingControllerTests.cs b/test/Api.IntegrationTest/SecretsManager/Controllers/SecretsManagerPortingControllerTests.cs
index ba41c1e862..86d5adf451 100644
--- a/test/Api.IntegrationTest/SecretsManager/Controllers/SecretsManagerPortingControllerTests.cs
+++ b/test/Api.IntegrationTest/SecretsManager/Controllers/SecretsManagerPortingControllerTests.cs
@@ -22,17 +22,17 @@ public class SecretsManagerPortingControllerTests : IClassFixture,
_loginHelper = new LoginHelper(_factory, _client);
}
- public async Task InitializeAsync()
+ public async ValueTask InitializeAsync()
{
_email = $"integration-test{Guid.NewGuid()}@bitwarden.com";
await _factory.LoginWithNewAccount(_email);
_organizationHelper = new SecretsManagerOrganizationHelper(_factory, _email);
}
- public Task DisposeAsync()
+ public ValueTask DisposeAsync()
{
_client.Dispose();
- return Task.CompletedTask;
+ return ValueTask.CompletedTask;
}
[Theory]
diff --git a/test/Api.IntegrationTest/SecretsManager/Controllers/ServiceAccountsControllerTests.cs b/test/Api.IntegrationTest/SecretsManager/Controllers/ServiceAccountsControllerTests.cs
index 6884de5b26..6556ffa2bd 100644
--- a/test/Api.IntegrationTest/SecretsManager/Controllers/ServiceAccountsControllerTests.cs
+++ b/test/Api.IntegrationTest/SecretsManager/Controllers/ServiceAccountsControllerTests.cs
@@ -48,17 +48,17 @@ public class ServiceAccountsControllerTests : IClassFixture, IAsyncL
_userRepository = _factory.GetService();
}
- public async Task InitializeAsync()
+ public async ValueTask InitializeAsync()
{
_ownerEmail = $"integration-test{Guid.NewGuid()}@bitwarden.com";
await _factory.LoginWithNewAccount(_ownerEmail);
}
- public Task DisposeAsync()
+ public ValueTask DisposeAsync()
{
_client.Dispose();
- return Task.CompletedTask;
+ return ValueTask.CompletedTask;
}
[Fact]
diff --git a/test/Api.Test/AdminConsole/Authorization/HttpContextExtensionsTests.cs b/test/Api.Test/AdminConsole/Authorization/HttpContextExtensionsTests.cs
index 428726aaac..57b8d2d7a4 100644
--- a/test/Api.Test/AdminConsole/Authorization/HttpContextExtensionsTests.cs
+++ b/test/Api.Test/AdminConsole/Authorization/HttpContextExtensionsTests.cs
@@ -1,4 +1,4 @@
-using AutoFixture.Xunit2;
+using AutoFixture.Xunit3;
using Bit.Api.AdminConsole.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Routing;
diff --git a/test/Api.Test/AdminConsole/Controllers/OrganizationsControllerTests.cs b/test/Api.Test/AdminConsole/Controllers/OrganizationsControllerTests.cs
index 00fd3c3b4e..b06231f242 100644
--- a/test/Api.Test/AdminConsole/Controllers/OrganizationsControllerTests.cs
+++ b/test/Api.Test/AdminConsole/Controllers/OrganizationsControllerTests.cs
@@ -1,5 +1,5 @@
using System.Security.Claims;
-using AutoFixture.Xunit2;
+using AutoFixture.Xunit3;
using Bit.Api.AdminConsole.Controllers;
using Bit.Api.Auth.Models.Request.Accounts;
using Bit.Api.Models.Request.Organizations;
diff --git a/test/Api.Test/Api.Test.csproj b/test/Api.Test/Api.Test.csproj
index fb75246d4f..9e3496e94a 100644
--- a/test/Api.Test/Api.Test.csproj
+++ b/test/Api.Test/Api.Test.csproj
@@ -9,14 +9,9 @@
runtime; build; native; contentfiles; analyzers; buildtransitive
all
-
-
-
- all
- runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
+
+
diff --git a/test/Api.Test/Billing/Controllers/OrganizationsControllerTests.cs b/test/Api.Test/Billing/Controllers/OrganizationsControllerTests.cs
index a776bbea22..ceacd9d465 100644
--- a/test/Api.Test/Billing/Controllers/OrganizationsControllerTests.cs
+++ b/test/Api.Test/Billing/Controllers/OrganizationsControllerTests.cs
@@ -1,5 +1,5 @@
using System.Security.Claims;
-using AutoFixture.Xunit2;
+using AutoFixture.Xunit3;
using Bit.Api.AdminConsole.Models.Request.Organizations;
using Bit.Api.Billing.Controllers;
using Bit.Api.Models.Request.Organizations;
diff --git a/test/Api.Test/Controllers/ConfigControllerTests.cs b/test/Api.Test/Controllers/ConfigControllerTests.cs
index 4df3520947..6abbccee14 100644
--- a/test/Api.Test/Controllers/ConfigControllerTests.cs
+++ b/test/Api.Test/Controllers/ConfigControllerTests.cs
@@ -1,4 +1,4 @@
-using AutoFixture.Xunit2;
+using AutoFixture.Xunit3;
using Bit.Api.Controllers;
using Bit.Core.Services;
using Bit.Core.Settings;
diff --git a/test/Api.Test/Tools/Controllers/SendsControllerTests.cs b/test/Api.Test/Tools/Controllers/SendsControllerTests.cs
index 7210bddebb..8fcb3bfbe8 100644
--- a/test/Api.Test/Tools/Controllers/SendsControllerTests.cs
+++ b/test/Api.Test/Tools/Controllers/SendsControllerTests.cs
@@ -1,5 +1,5 @@
using System.Text.Json;
-using AutoFixture.Xunit2;
+using AutoFixture.Xunit3;
using Bit.Api.Tools.Controllers;
using Bit.Api.Tools.Models.Request;
using Bit.Api.Tools.Models.Response;
diff --git a/test/Billing.Test/Billing.Test.csproj b/test/Billing.Test/Billing.Test.csproj
index 4d7f887c90..d56128e0ef 100644
--- a/test/Billing.Test/Billing.Test.csproj
+++ b/test/Billing.Test/Billing.Test.csproj
@@ -5,19 +5,13 @@
-
-
-
-
- runtime; build; native; contentfiles; analyzers; buildtransitive
- all
-
+
runtime; build; native; contentfiles; analyzers; buildtransitive
all
-
+
diff --git a/test/Billing.Test/Controllers/PayPalControllerTests.cs b/test/Billing.Test/Controllers/PayPalControllerTests.cs
index 7ec17bd85a..f03d84e63a 100644
--- a/test/Billing.Test/Controllers/PayPalControllerTests.cs
+++ b/test/Billing.Test/Controllers/PayPalControllerTests.cs
@@ -8,24 +8,26 @@ using Bit.Core.Entities;
using Bit.Core.Enums;
using Bit.Core.Repositories;
using Bit.Core.Services;
-using Divergic.Logging.Xunit;
+using Bit.Test.Common;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Infrastructure;
+using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
+using Microsoft.Extensions.Logging.Testing;
using Microsoft.Extensions.Options;
using Microsoft.Extensions.Primitives;
using NSubstitute;
using NSubstitute.ReturnsExtensions;
using Xunit;
-using Xunit.Abstractions;
using Transaction = Bit.Core.Entities.Transaction;
namespace Bit.Billing.Test.Controllers;
public class PayPalControllerTests
{
- private readonly ITestOutputHelper _testOutputHelper;
+ private readonly ILogger _logger;
+ private readonly FakeLogCollector _fakeLogCollector;
private readonly IOptions _billingSettings = Substitute.For>();
private readonly IMailService _mailService = Substitute.For();
@@ -38,68 +40,68 @@ public class PayPalControllerTests
private const string _defaultWebhookKey = "webhook-key";
- public PayPalControllerTests(ITestOutputHelper testOutputHelper)
+ public PayPalControllerTests()
{
- _testOutputHelper = testOutputHelper;
+ var services = new ServiceCollection()
+ .AddLogging(b =>
+ {
+ b.AddProvider(new XUnitLoggerProvider());
+ b.AddFakeLogging();
+ })
+ .BuildServiceProvider();
+ _logger = services.GetRequiredService>();
+ _fakeLogCollector = services.GetFakeLogCollector();
}
[Fact]
public async Task PostIpn_NullKey_BadRequest()
{
- var logger = _testOutputHelper.BuildLoggerFor();
-
- var controller = ConfigureControllerContextWith(logger, null, null);
+ var controller = ConfigureControllerContextWith(null, null);
var result = await controller.PostIpn();
HasStatusCode(result, 400);
- LoggedError(logger, "PayPal IPN: Key is missing");
+ LoggedError("PayPal IPN: Key is missing");
}
[Fact]
public async Task PostIpn_IncorrectKey_BadRequest()
{
- var logger = _testOutputHelper.BuildLoggerFor();
-
_billingSettings.Value.Returns(new BillingSettings
{
PayPal = { WebhookKey = "INCORRECT" }
});
- var controller = ConfigureControllerContextWith(logger, _defaultWebhookKey, null);
+ var controller = ConfigureControllerContextWith(_defaultWebhookKey, null);
var result = await controller.PostIpn();
HasStatusCode(result, 400);
- LoggedError(logger, "PayPal IPN: Key is incorrect");
+ LoggedError("PayPal IPN: Key is incorrect");
}
[Fact]
public async Task PostIpn_EmptyIPNBody_BadRequest()
{
- var logger = _testOutputHelper.BuildLoggerFor();
-
_billingSettings.Value.Returns(new BillingSettings
{
PayPal = { WebhookKey = _defaultWebhookKey }
});
- var controller = ConfigureControllerContextWith(logger, _defaultWebhookKey, null);
+ var controller = ConfigureControllerContextWith(_defaultWebhookKey, null);
var result = await controller.PostIpn();
HasStatusCode(result, 400);
- LoggedError(logger, "PayPal IPN: Request body is null or empty");
+ LoggedError("PayPal IPN: Request body is null or empty");
}
[Fact]
public async Task PostIpn_IPNHasNoEntityId_BadRequest()
{
- var logger = _testOutputHelper.BuildLoggerFor();
-
_billingSettings.Value.Returns(new BillingSettings
{
PayPal = { WebhookKey = _defaultWebhookKey }
@@ -107,20 +109,18 @@ public class PayPalControllerTests
var ipnBody = await PayPalTestIPN.GetAsync(IPNBody.TransactionMissingEntityIds);
- var controller = ConfigureControllerContextWith(logger, _defaultWebhookKey, ipnBody);
+ var controller = ConfigureControllerContextWith(_defaultWebhookKey, ipnBody);
var result = await controller.PostIpn();
HasStatusCode(result, 400);
- LoggedError(logger, "PayPal IPN (2PK15573S8089712Y): 'custom' did not contain a User ID or Organization ID or provider ID");
+ LoggedError("PayPal IPN (2PK15573S8089712Y): 'custom' did not contain a User ID or Organization ID or provider ID");
}
[Fact]
public async Task PostIpn_OtherTransactionType_Unprocessed_Ok()
{
- var logger = _testOutputHelper.BuildLoggerFor();
-
_billingSettings.Value.Returns(new BillingSettings
{
PayPal = { WebhookKey = _defaultWebhookKey }
@@ -130,20 +130,18 @@ public class PayPalControllerTests
var ipnBody = await PayPalTestIPN.GetAsync(IPNBody.UnsupportedTransactionType);
- var controller = ConfigureControllerContextWith(logger, _defaultWebhookKey, ipnBody);
+ var controller = ConfigureControllerContextWith(_defaultWebhookKey, ipnBody);
var result = await controller.PostIpn();
HasStatusCode(result, 200);
- LoggedWarning(logger, "PayPal IPN (2PK15573S8089712Y): Transaction type (other) not supported for payments");
+ LoggedWarning("PayPal IPN (2PK15573S8089712Y): Transaction type (other) not supported for payments");
}
[Fact]
public async Task PostIpn_MismatchedReceiverID_Unprocessed_Ok()
{
- var logger = _testOutputHelper.BuildLoggerFor();
-
_billingSettings.Value.Returns(new BillingSettings
{
PayPal =
@@ -157,20 +155,18 @@ public class PayPalControllerTests
var ipnBody = await PayPalTestIPN.GetAsync(IPNBody.SuccessfulPayment);
- var controller = ConfigureControllerContextWith(logger, _defaultWebhookKey, ipnBody);
+ var controller = ConfigureControllerContextWith(_defaultWebhookKey, ipnBody);
var result = await controller.PostIpn();
HasStatusCode(result, 200);
- LoggedWarning(logger, "PayPal IPN (2PK15573S8089712Y): Receiver ID (NHDYKLQ3L4LWL) does not match Bitwarden business ID (INCORRECT)");
+ LoggedWarning("PayPal IPN (2PK15573S8089712Y): Receiver ID (NHDYKLQ3L4LWL) does not match Bitwarden business ID (INCORRECT)");
}
[Fact]
public async Task PostIpn_RefundMissingParent_Unprocessed_Ok()
{
- var logger = _testOutputHelper.BuildLoggerFor();
-
_billingSettings.Value.Returns(new BillingSettings
{
PayPal =
@@ -184,20 +180,18 @@ public class PayPalControllerTests
var ipnBody = await PayPalTestIPN.GetAsync(IPNBody.RefundMissingParentTransaction);
- var controller = ConfigureControllerContextWith(logger, _defaultWebhookKey, ipnBody);
+ var controller = ConfigureControllerContextWith(_defaultWebhookKey, ipnBody);
var result = await controller.PostIpn();
HasStatusCode(result, 200);
- LoggedWarning(logger, "PayPal IPN (2PK15573S8089712Y): Parent transaction ID is required for refund");
+ LoggedWarning("PayPal IPN (2PK15573S8089712Y): Parent transaction ID is required for refund");
}
[Fact]
public async Task PostIpn_eCheckPayment_Unprocessed_Ok()
{
- var logger = _testOutputHelper.BuildLoggerFor();
-
_billingSettings.Value.Returns(new BillingSettings
{
PayPal =
@@ -211,20 +205,18 @@ public class PayPalControllerTests
var ipnBody = await PayPalTestIPN.GetAsync(IPNBody.ECheckPayment);
- var controller = ConfigureControllerContextWith(logger, _defaultWebhookKey, ipnBody);
+ var controller = ConfigureControllerContextWith(_defaultWebhookKey, ipnBody);
var result = await controller.PostIpn();
HasStatusCode(result, 200);
- LoggedWarning(logger, "PayPal IPN (2PK15573S8089712Y): Transaction was an eCheck payment");
+ LoggedWarning("PayPal IPN (2PK15573S8089712Y): Transaction was an eCheck payment");
}
[Fact]
public async Task PostIpn_NonUSD_Unprocessed_Ok()
{
- var logger = _testOutputHelper.BuildLoggerFor();
-
_billingSettings.Value.Returns(new BillingSettings
{
PayPal =
@@ -238,20 +230,18 @@ public class PayPalControllerTests
var ipnBody = await PayPalTestIPN.GetAsync(IPNBody.NonUSDPayment);
- var controller = ConfigureControllerContextWith(logger, _defaultWebhookKey, ipnBody);
+ var controller = ConfigureControllerContextWith(_defaultWebhookKey, ipnBody);
var result = await controller.PostIpn();
HasStatusCode(result, 200);
- LoggedWarning(logger, "PayPal IPN (2PK15573S8089712Y): Transaction was not in USD (CAD)");
+ LoggedWarning("PayPal IPN (2PK15573S8089712Y): Transaction was not in USD (CAD)");
}
[Fact]
public async Task PostIpn_Completed_ExistingTransaction_Unprocessed_Ok()
{
- var logger = _testOutputHelper.BuildLoggerFor();
-
_billingSettings.Value.Returns(new BillingSettings
{
PayPal =
@@ -269,20 +259,18 @@ public class PayPalControllerTests
GatewayType.PayPal,
"2PK15573S8089712Y").Returns(new Transaction());
- var controller = ConfigureControllerContextWith(logger, _defaultWebhookKey, ipnBody);
+ var controller = ConfigureControllerContextWith(_defaultWebhookKey, ipnBody);
var result = await controller.PostIpn();
HasStatusCode(result, 200);
- LoggedWarning(logger, "PayPal IPN (2PK15573S8089712Y): Already processed this completed transaction");
+ LoggedWarning("PayPal IPN (2PK15573S8089712Y): Already processed this completed transaction");
}
[Fact]
public async Task PostIpn_Completed_CreatesTransaction_Ok()
{
- var logger = _testOutputHelper.BuildLoggerFor();
-
_billingSettings.Value.Returns(new BillingSettings
{
PayPal =
@@ -300,7 +288,7 @@ public class PayPalControllerTests
GatewayType.PayPal,
"2PK15573S8089712Y").ReturnsNull();
- var controller = ConfigureControllerContextWith(logger, _defaultWebhookKey, ipnBody);
+ var controller = ConfigureControllerContextWith(_defaultWebhookKey, ipnBody);
var result = await controller.PostIpn();
@@ -314,8 +302,6 @@ public class PayPalControllerTests
[Fact]
public async Task PostIpn_Completed_CreatesTransaction_CreditsOrganizationAccount_Ok()
{
- var logger = _testOutputHelper.BuildLoggerFor();
-
_billingSettings.Value.Returns(new BillingSettings
{
PayPal =
@@ -341,7 +327,7 @@ public class PayPalControllerTests
_paymentService.CreditAccountAsync(organization, 48M).Returns(true);
- var controller = ConfigureControllerContextWith(logger, _defaultWebhookKey, ipnBody);
+ var controller = ConfigureControllerContextWith(_defaultWebhookKey, ipnBody);
var result = await controller.PostIpn();
@@ -362,8 +348,6 @@ public class PayPalControllerTests
[Fact]
public async Task PostIpn_Completed_CreatesTransaction_CreditsUserAccount_Ok()
{
- var logger = _testOutputHelper.BuildLoggerFor();
-
_billingSettings.Value.Returns(new BillingSettings
{
PayPal =
@@ -387,7 +371,7 @@ public class PayPalControllerTests
_userRepository.GetByIdAsync(userId).Returns(user);
- var controller = ConfigureControllerContextWith(logger, _defaultWebhookKey, ipnBody);
+ var controller = ConfigureControllerContextWith(_defaultWebhookKey, ipnBody);
var result = await controller.PostIpn();
@@ -406,8 +390,6 @@ public class PayPalControllerTests
[Fact]
public async Task PostIpn_Refunded_ExistingTransaction_Unprocessed_Ok()
{
- var logger = _testOutputHelper.BuildLoggerFor();
-
_billingSettings.Value.Returns(new BillingSettings
{
PayPal =
@@ -425,13 +407,13 @@ public class PayPalControllerTests
GatewayType.PayPal,
"2PK15573S8089712Y").Returns(new Transaction());
- var controller = ConfigureControllerContextWith(logger, _defaultWebhookKey, ipnBody);
+ var controller = ConfigureControllerContextWith(_defaultWebhookKey, ipnBody);
var result = await controller.PostIpn();
HasStatusCode(result, 200);
- LoggedWarning(logger, "PayPal IPN (2PK15573S8089712Y): Already processed this refunded transaction");
+ LoggedWarning("PayPal IPN (2PK15573S8089712Y): Already processed this refunded transaction");
await _transactionRepository.DidNotReceiveWithAnyArgs().ReplaceAsync(Arg.Any());
@@ -441,8 +423,6 @@ public class PayPalControllerTests
[Fact]
public async Task PostIpn_Refunded_MissingParentTransaction_Ok()
{
- var logger = _testOutputHelper.BuildLoggerFor();
-
_billingSettings.Value.Returns(new BillingSettings
{
PayPal =
@@ -464,13 +444,13 @@ public class PayPalControllerTests
GatewayType.PayPal,
"PARENT").ReturnsNull();
- var controller = ConfigureControllerContextWith(logger, _defaultWebhookKey, ipnBody);
+ var controller = ConfigureControllerContextWith(_defaultWebhookKey, ipnBody);
var result = await controller.PostIpn();
HasStatusCode(result, 200);
- LoggedWarning(logger, "PayPal IPN (2PK15573S8089712Y): Could not find parent transaction");
+ LoggedWarning("PayPal IPN (2PK15573S8089712Y): Could not find parent transaction");
await _transactionRepository.DidNotReceiveWithAnyArgs().ReplaceAsync(Arg.Any());
@@ -480,8 +460,6 @@ public class PayPalControllerTests
[Fact]
public async Task PostIpn_Refunded_ReplacesParent_CreatesTransaction_Ok()
{
- var logger = _testOutputHelper.BuildLoggerFor();
-
_billingSettings.Value.Returns(new BillingSettings
{
PayPal =
@@ -511,7 +489,7 @@ public class PayPalControllerTests
GatewayType.PayPal,
"PARENT").Returns(parentTransaction);
- var controller = ConfigureControllerContextWith(logger, _defaultWebhookKey, ipnBody);
+ var controller = ConfigureControllerContextWith(_defaultWebhookKey, ipnBody);
var result = await controller.PostIpn();
@@ -530,13 +508,12 @@ public class PayPalControllerTests
}
private PayPalController ConfigureControllerContextWith(
- ILogger logger,
string webhookKey,
string ipnBody)
{
var controller = new PayPalController(
_billingSettings,
- logger,
+ _logger,
_mailService,
_organizationRepository,
_paymentService,
@@ -578,16 +555,18 @@ public class PayPalControllerTests
Assert.Equal(statusCode, statusCodeActionResult.StatusCode);
}
- private static void Logged(ICacheLogger logger, LogLevel logLevel, string message)
+ private void Logged(LogLevel logLevel, string message)
{
- Assert.NotNull(logger.Last);
- Assert.Equal(logLevel, logger.Last!.LogLevel);
- Assert.Equal(message, logger.Last!.Message);
+ var snapshot = _fakeLogCollector.GetSnapshot(true);
+ Assert.NotEmpty(snapshot);
+ var last = snapshot[^1];
+ Assert.Equal(logLevel, last.Level);
+ Assert.Equal(message, last.Message);
}
- private static void LoggedError(ICacheLogger logger, string message)
- => Logged(logger, LogLevel.Error, message);
+ private void LoggedError(string message)
+ => Logged(LogLevel.Error, message);
- private static void LoggedWarning(ICacheLogger logger, string message)
- => Logged(logger, LogLevel.Warning, message);
+ private void LoggedWarning(string message)
+ => Logged(LogLevel.Warning, message);
}
diff --git a/test/Common/AutoFixture/Attributes/BitAutoDataAttribute.cs b/test/Common/AutoFixture/Attributes/BitAutoDataAttribute.cs
index 03a8cb466f..8752b96e8d 100644
--- a/test/Common/AutoFixture/Attributes/BitAutoDataAttribute.cs
+++ b/test/Common/AutoFixture/Attributes/BitAutoDataAttribute.cs
@@ -1,13 +1,12 @@
-#nullable enable
-
-using System.Reflection;
+using System.Reflection;
using AutoFixture;
using Bit.Test.Common.Helpers;
+using Xunit;
using Xunit.Sdk;
+using Xunit.v3;
namespace Bit.Test.Common.AutoFixture.Attributes;
-[DataDiscoverer("AutoFixture.Xunit2.NoPreDiscoveryDataDiscoverer", "AutoFixture.Xunit2")]
public class BitAutoDataAttribute : DataAttribute
{
private readonly Func _createFixture;
@@ -26,6 +25,23 @@ public class BitAutoDataAttribute : DataAttribute
_fixedTestParameters = fixedTestParameters;
}
- public override IEnumerable