mirror of
https://github.com/bitwarden/server.git
synced 2024-12-04 14:13:28 +01:00
8262af3c53
* Fix typo in error message: 'Unkown' -> 'Unknown' * Fix typos in error message * Fix typo in example text: 'licence' -> 'license' * Fix typo in validation: 'Ooganization' -> 'Organization' * Fix typo in text string: 'compatibilty' -> 'compatibility' * Fix typo: 'ProviderDisllowedOrganizationTypes' -> 'ProviderDisallowedOrganizationTypes' * Fix typo: 'NSubstitueVersion' -> 'NSubstituteVersion' * Fix typo: 'CreateIntialInvite' -> 'CreateInitialInvite' * Fix typo: '_queuryScheme' -> '_queryScheme' * Fix typo: 'GetApplicationCacheServiceBusSubcriptionName' -> 'GetApplicationCacheServiceBusSubscriptionName' * Fix typo: 'metaDataRespository' -> 'metaDataRepository' * Fix typo: 'cipherAttachements' -> 'cipherAttachments' * Fix typo: 'savedEmergencyAccesss' -> 'savedEmergencyAccesses' * Fix typo: 'owerOrgUser' -> 'ownerOrgUser' * Fix typo: 'Organiation' -> 'Organization' * Fix typo: 'extistingUser' -> 'existingUser' * Fix typo: 'availibleAccess' -> 'availableAccess' * Fix typo: 'HasEnouphStorage' -> 'HasEnoughStorage' * Fix typo: 'extistingOrg' -> 'existingOrg' * Fix typo: 'subcriber' -> 'subscriber' * Fix typo: 'availibleCollections' -> 'availableCollections' * Fix typo: 'Succes' -> 'Success' * Fix typo: 'CreateAsync_UpdateWithCollecitons_Works' -> 'CreateAsync_UpdateWithCollections_Works' * Fix typo: 'BadInsallationId' -> 'BadInstallationId' * Fix typo: 'OrgNotFamiles' -> 'OrgNotFamilies' * Revert "Fix typo: 'Organiation' -> 'Organization'" This reverts commit8aadad1c25
. * Revert "Fix typos in error message" This reverts commit81d201fc09
. --------- Co-authored-by: Daniel James Smith <djsmith@web.de>
62 lines
2.4 KiB
C#
62 lines
2.4 KiB
C#
using Bit.Core.Auth.Entities;
|
|
using Bit.Core.Entities;
|
|
using Bit.Core.Test.AutoFixture.Attributes;
|
|
using Bit.Infrastructure.EFIntegration.Test.Auth.AutoFixture;
|
|
using Bit.Infrastructure.EFIntegration.Test.Auth.Repositories.EqualityComparers;
|
|
using Xunit;
|
|
using EfAuthRepo = Bit.Infrastructure.EntityFramework.Auth.Repositories;
|
|
using EfRepo = Bit.Infrastructure.EntityFramework.Repositories;
|
|
using SqlAuthRepo = Bit.Infrastructure.Dapper.Auth.Repositories;
|
|
using SqlRepo = Bit.Infrastructure.Dapper.Repositories;
|
|
|
|
namespace Bit.Infrastructure.EFIntegration.Test.Auth.Repositories;
|
|
|
|
public class EmergencyAccessRepositoryTests
|
|
{
|
|
[CiSkippedTheory, EfEmergencyAccessAutoData]
|
|
public async void CreateAsync_Works_DataMatches(
|
|
EmergencyAccess emergencyAccess,
|
|
List<User> users,
|
|
EmergencyAccessCompare equalityComparer,
|
|
List<EfAuthRepo.EmergencyAccessRepository> suts,
|
|
List<EfRepo.UserRepository> efUserRepos,
|
|
SqlAuthRepo.EmergencyAccessRepository sqlEmergencyAccessRepo,
|
|
SqlRepo.UserRepository sqlUserRepo
|
|
)
|
|
{
|
|
var savedEmergencyAccesses = new List<EmergencyAccess>();
|
|
foreach (var sut in suts)
|
|
{
|
|
var i = suts.IndexOf(sut);
|
|
|
|
for (int j = 0; j < users.Count; j++)
|
|
{
|
|
users[j] = await efUserRepos[i].CreateAsync(users[j]);
|
|
}
|
|
sut.ClearChangeTracking();
|
|
|
|
emergencyAccess.GrantorId = users[0].Id;
|
|
emergencyAccess.GranteeId = users[0].Id;
|
|
var postEfEmergencyAccess = await sut.CreateAsync(emergencyAccess);
|
|
sut.ClearChangeTracking();
|
|
|
|
var savedEmergencyAccess = await sut.GetByIdAsync(postEfEmergencyAccess.Id);
|
|
savedEmergencyAccesses.Add(savedEmergencyAccess);
|
|
}
|
|
|
|
for (int j = 0; j < users.Count; j++)
|
|
{
|
|
users[j] = await sqlUserRepo.CreateAsync(users[j]);
|
|
}
|
|
|
|
emergencyAccess.GrantorId = users[0].Id;
|
|
emergencyAccess.GranteeId = users[0].Id;
|
|
var sqlEmergencyAccess = await sqlEmergencyAccessRepo.CreateAsync(emergencyAccess);
|
|
var savedSqlEmergencyAccess = await sqlEmergencyAccessRepo.GetByIdAsync(sqlEmergencyAccess.Id);
|
|
savedEmergencyAccesses.Add(savedSqlEmergencyAccess);
|
|
|
|
var distinctItems = savedEmergencyAccesses.Distinct(equalityComparer);
|
|
Assert.True(!distinctItems.Skip(1).Any());
|
|
}
|
|
}
|