Skip to content

Commit 79648b3

Browse files
authored
[PM-3555] Remove ClearTracker() (#3213)
* Remove ClearTracker * Remove from CipherRepositoryTests
1 parent b2af73f commit 79648b3

File tree

6 files changed

+9
-75
lines changed

6 files changed

+9
-75
lines changed

test/Infrastructure.IntegrationTest/Auth/Repositories/AuthRequestRepositoryTests.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ public class AuthRequestRepositoryTests
1515
[DatabaseTheory, DatabaseData]
1616
public async Task DeleteExpiredAsync_Works(
1717
IAuthRequestRepository authRequestRepository,
18-
IUserRepository userRepository,
19-
ITestDatabaseHelper helper)
18+
IUserRepository userRepository)
2019
{
2120
var user = await userRepository.CreateAsync(new User
2221
{
@@ -54,8 +53,6 @@ public async Task DeleteExpiredAsync_Works(
5453
var notExpiredApprovedAdminApprovalRequest = await authRequestRepository.CreateAsync(
5554
CreateAuthRequest(user.Id, AuthRequestType.AdminApproval, DateTime.UtcNow.AddDays(7), true, DateTime.UtcNow.AddHours(11)));
5655

57-
helper.ClearTracker();
58-
5956
var numberOfDeleted = await authRequestRepository.DeleteExpiredAsync(_userRequestExpiration, _adminRequestExpiration, _afterAdminApprovalExpiration);
6057

6158
// Ensure all the AuthRequests that should have been deleted, have been deleted.

test/Infrastructure.IntegrationTest/Auth/Repositories/EmergencyAccessRepositoryTests.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ public class EmergencyAccessRepositoriesTests
1010
{
1111
[DatabaseTheory, DatabaseData]
1212
public async Task DeleteAsync_UpdatesRevisionDate(IUserRepository userRepository,
13-
IEmergencyAccessRepository emergencyAccessRepository,
14-
ITestDatabaseHelper helper)
13+
IEmergencyAccessRepository emergencyAccessRepository)
1514
{
1615
var grantorUser = await userRepository.CreateAsync(new User
1716
{
@@ -36,8 +35,6 @@ public async Task DeleteAsync_UpdatesRevisionDate(IUserRepository userRepository
3635
Status = EmergencyAccessStatusType.Confirmed,
3736
});
3837

39-
helper.ClearTracker();
40-
4138
await emergencyAccessRepository.DeleteAsync(emergencyAccess);
4239

4340
var updatedGrantee = await userRepository.GetByIdAsync(granteeUser.Id);

test/Infrastructure.IntegrationTest/DatabaseDataAttribute.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using Bit.Core.Settings;
44
using Bit.Infrastructure.Dapper;
55
using Bit.Infrastructure.EntityFramework;
6-
using Bit.Infrastructure.EntityFramework.Repositories;
76
using Microsoft.Extensions.Configuration;
87
using Microsoft.Extensions.DependencyInjection;
98
using Microsoft.Extensions.Logging;
@@ -65,7 +64,7 @@ private IEnumerable<IServiceProvider> GetDatabaseProviders(IConfiguration config
6564
};
6665
dapperSqlServerCollection.AddSingleton(globalSettings);
6766
dapperSqlServerCollection.AddSingleton<IGlobalSettings>(globalSettings);
68-
dapperSqlServerCollection.AddSingleton<ITestDatabaseHelper>(_ => new DapperSqlServerTestDatabaseHelper(database));
67+
dapperSqlServerCollection.AddSingleton(database);
6968
dapperSqlServerCollection.AddDataProtection();
7069
yield return dapperSqlServerCollection.BuildServiceProvider();
7170
}
@@ -75,7 +74,7 @@ private IEnumerable<IServiceProvider> GetDatabaseProviders(IConfiguration config
7574
efCollection.AddLogging(configureLogging);
7675
efCollection.SetupEntityFramework(database.ConnectionString, database.Type);
7776
efCollection.AddPasswordManagerEFRepositories(SelfHosted);
78-
efCollection.AddTransient<ITestDatabaseHelper>(sp => new EfTestDatabaseHelper(sp.GetRequiredService<DatabaseContext>(), database));
77+
efCollection.AddSingleton(database);
7978
efCollection.AddDataProtection();
8079
yield return efCollection.BuildServiceProvider();
8180
}

test/Infrastructure.IntegrationTest/Repositories/OrganizationUserRepositoryTests.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ public class OrganizationUserRepositoryTests
1010
[DatabaseTheory, DatabaseData]
1111
public async Task DeleteAsync_Works(IUserRepository userRepository,
1212
IOrganizationRepository organizationRepository,
13-
IOrganizationUserRepository organizationUserRepository,
14-
ITestDatabaseHelper helper)
13+
IOrganizationUserRepository organizationUserRepository)
1514
{
1615
var user = await userRepository.CreateAsync(new User
1716
{
@@ -35,8 +34,6 @@ public async Task DeleteAsync_Works(IUserRepository userRepository,
3534
Status = OrganizationUserStatusType.Confirmed,
3635
});
3736

38-
helper.ClearTracker();
39-
4037
await organizationUserRepository.DeleteAsync(orgUser);
4138

4239
var newUser = await userRepository.GetByIdAsync(user.Id);
@@ -46,8 +43,7 @@ public async Task DeleteAsync_Works(IUserRepository userRepository,
4643
[DatabaseTheory, DatabaseData]
4744
public async Task DeleteManyAsync_Works(IUserRepository userRepository,
4845
IOrganizationRepository organizationRepository,
49-
IOrganizationUserRepository organizationUserRepository,
50-
ITestDatabaseHelper helper)
46+
IOrganizationUserRepository organizationUserRepository)
5147
{
5248
var user1 = await userRepository.CreateAsync(new User
5349
{
@@ -86,8 +82,6 @@ public async Task DeleteManyAsync_Works(IUserRepository userRepository,
8682
Status = OrganizationUserStatusType.Confirmed,
8783
});
8884

89-
helper.ClearTracker();
90-
9185
await organizationUserRepository.DeleteManyAsync(new List<Guid>
9286
{
9387
orgUser1.Id,

test/Infrastructure.IntegrationTest/TestDatabaseHelpers.cs

Lines changed: 0 additions & 42 deletions
This file was deleted.

test/Infrastructure.IntegrationTest/Vault/Repositories/CipherRepositoryTests.cs

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ public class CipherRepositoryTests
1616
[DatabaseTheory, DatabaseData]
1717
public async Task DeleteAsync_UpdatesUserRevisionDate(
1818
IUserRepository userRepository,
19-
ICipherRepository cipherRepository,
20-
ITestDatabaseHelper helper)
19+
ICipherRepository cipherRepository)
2120
{
2221
var user = await userRepository.CreateAsync(new User
2322
{
@@ -34,8 +33,6 @@ public async Task DeleteAsync_UpdatesUserRevisionDate(
3433
Data = "", // TODO: EF does not enforce this as NOT NULL
3534
});
3635

37-
helper.ClearTracker();
38-
3936
await cipherRepository.DeleteAsync(cipher);
4037

4138
var deletedCipher = await cipherRepository.GetByIdAsync(cipher.Id);
@@ -52,8 +49,7 @@ public async Task CreateAsync_UpdateWithCollections_Works(
5249
IOrganizationUserRepository organizationUserRepository,
5350
ICollectionRepository collectionRepository,
5451
ICipherRepository cipherRepository,
55-
ICollectionCipherRepository collectionCipherRepository,
56-
ITestDatabaseHelper helper)
52+
ICollectionCipherRepository collectionCipherRepository)
5753
{
5854
var user = await userRepository.CreateAsync(new User
5955
{
@@ -63,8 +59,6 @@ public async Task CreateAsync_UpdateWithCollections_Works(
6359
SecurityStamp = "stamp",
6460
});
6561

66-
helper.ClearTracker();
67-
6862
user = await userRepository.GetByIdAsync(user.Id);
6963

7064
var organization = await organizationRepository.CreateAsync(new Organization
@@ -100,8 +94,6 @@ await collectionRepository.UpdateUsersAsync(collection.Id, new[]
10094
},
10195
});
10296

103-
helper.ClearTracker();
104-
10597
await Task.Delay(100);
10698

10799
await cipherRepository.CreateAsync(new CipherDetails
@@ -128,8 +120,7 @@ public async Task ReplaceAsync_SuccessfullyMovesCipherToOrganization(IUserReposi
128120
ICipherRepository cipherRepository,
129121
IOrganizationRepository organizationRepository,
130122
IOrganizationUserRepository organizationUserRepository,
131-
IFolderRepository folderRepository,
132-
ITestDatabaseHelper helper)
123+
IFolderRepository folderRepository)
133124
{
134125
// This tests what happens when a cipher is moved into an organizations
135126
var user = await userRepository.CreateAsync(new User
@@ -171,8 +162,6 @@ public async Task ReplaceAsync_SuccessfullyMovesCipherToOrganization(IUserReposi
171162
UserId = user.Id,
172163
});
173164

174-
helper.ClearTracker();
175-
176165
// Move cipher to organization vault
177166
await cipherRepository.ReplaceAsync(new CipherDetails
178167
{

0 commit comments

Comments
 (0)