From 0553cdc70e1ff6e79bc0ab48ebd9e7d9186ac97b Mon Sep 17 00:00:00 2001 From: Nick Krantz Date: Thu, 5 Mar 2026 16:10:15 -0600 Subject: [PATCH 1/2] add cipher key on EF organization --- ...izationDetailsReadByOrganizationIdQuery.cs | 1 + .../Repositories/CipherRepositoryTests.cs | 43 +++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/src/Infrastructure.EntityFramework/Vault/Repositories/Queries/CipherOrganizationDetailsReadByOrganizationIdQuery.cs b/src/Infrastructure.EntityFramework/Vault/Repositories/Queries/CipherOrganizationDetailsReadByOrganizationIdQuery.cs index 0a39e5295771..1727ff4a0201 100644 --- a/src/Infrastructure.EntityFramework/Vault/Repositories/Queries/CipherOrganizationDetailsReadByOrganizationIdQuery.cs +++ b/src/Infrastructure.EntityFramework/Vault/Repositories/Queries/CipherOrganizationDetailsReadByOrganizationIdQuery.cs @@ -38,6 +38,7 @@ from o in o_g.DefaultIfEmpty() CreationDate = c.CreationDate, RevisionDate = c.RevisionDate, DeletedDate = c.DeletedDate, + Key = c.Key, OrganizationUseTotp = o.UseTotp, }; diff --git a/test/Infrastructure.EFIntegration.Test/Vault/Repositories/CipherRepositoryTests.cs b/test/Infrastructure.EFIntegration.Test/Vault/Repositories/CipherRepositoryTests.cs index a314d15ddab9..f37aa9e7a924 100644 --- a/test/Infrastructure.EFIntegration.Test/Vault/Repositories/CipherRepositoryTests.cs +++ b/test/Infrastructure.EFIntegration.Test/Vault/Repositories/CipherRepositoryTests.cs @@ -7,6 +7,7 @@ using Bit.Infrastructure.EFIntegration.Test.AutoFixture; using Bit.Infrastructure.EFIntegration.Test.Repositories.EqualityComparers; using Bit.Infrastructure.EntityFramework.Repositories.Queries; +using Bit.Infrastructure.EntityFramework.Repositories.Vault.Queries; using Bit.Test.Common.AutoFixture.Attributes; using LinqToDB; using Xunit; @@ -368,4 +369,46 @@ public async Task UnarchiveAsync_RemovesUserFromArchivesJsonAndBumpsUserAccountR Assert.Equal(DateTime.UtcNow.ToShortDateString(), bumpedUser.AccountRevisionDate.ToShortDateString()); } } + + [CiSkippedTheory, EfOrganizationCipherCustomize, BitAutoData] + public async Task CipherOrganizationDetailsReadByOrganizationIdQuery_ReturnsAllProperties( + Cipher cipher, + Organization org, + List suts, + List efOrgRepos) + { + foreach (var sut in suts) + { + var i = suts.IndexOf(sut); + + var efOrg = await efOrgRepos[i].CreateAsync(org); + efOrgRepos[i].ClearChangeTracking(); + + cipher.OrganizationId = efOrg.Id; + cipher.UserId = null; + + var createdCipher = await sut.CreateAsync(cipher); + sut.ClearChangeTracking(); + + var query = new CipherOrganizationDetailsReadByOrganizationIdQuery(efOrg.Id); + var result = await sut.Run(query).ToListAsync(); + + Assert.Single(result); + var resultCipher = result[0]; + + Assert.Equal(createdCipher.Id, resultCipher.Id); + Assert.Null(resultCipher.UserId); + Assert.Equal(efOrg.Id, resultCipher.OrganizationId); + Assert.Equal(createdCipher.Type, resultCipher.Type); + Assert.Equal(createdCipher.Data, resultCipher.Data); + Assert.Equal(createdCipher.Favorites, resultCipher.Favorites); + Assert.Equal(createdCipher.Folders, resultCipher.Folders); + Assert.Equal(createdCipher.Attachments, resultCipher.Attachments); + Assert.Equal(createdCipher.CreationDate, resultCipher.CreationDate); + Assert.Equal(createdCipher.RevisionDate, resultCipher.RevisionDate); + Assert.Equal(createdCipher.DeletedDate, resultCipher.DeletedDate); + Assert.Equal(createdCipher.Key, resultCipher.Key); + Assert.Equal(efOrg.UseTotp, resultCipher.OrganizationUseTotp); + } + } } From 40c0b8eefe55c006d82ccb33c89bed399996b7d7 Mon Sep 17 00:00:00 2001 From: Nick Krantz Date: Thu, 5 Mar 2026 19:32:48 -0600 Subject: [PATCH 2/2] add reprompt and additional mapping --- .../CipherOrganizationDetailsReadByIdQuery.cs | 2 + ...izationDetailsReadByOrganizationIdQuery.cs | 1 + .../Repositories/CipherRepositoryTests.cs | 45 +++++++++++++++++++ 3 files changed, 48 insertions(+) diff --git a/src/Infrastructure.EntityFramework/Vault/Repositories/Queries/CipherOrganizationDetailsReadByIdQuery.cs b/src/Infrastructure.EntityFramework/Vault/Repositories/Queries/CipherOrganizationDetailsReadByIdQuery.cs index f0ab4779e3aa..8ec3e5866b2a 100644 --- a/src/Infrastructure.EntityFramework/Vault/Repositories/Queries/CipherOrganizationDetailsReadByIdQuery.cs +++ b/src/Infrastructure.EntityFramework/Vault/Repositories/Queries/CipherOrganizationDetailsReadByIdQuery.cs @@ -33,6 +33,8 @@ from o in o_g.DefaultIfEmpty() CreationDate = c.CreationDate, RevisionDate = c.RevisionDate, DeletedDate = c.DeletedDate, + Key = c.Key, + Reprompt = c.Reprompt, OrganizationUseTotp = o.UseTotp, }; return query; diff --git a/src/Infrastructure.EntityFramework/Vault/Repositories/Queries/CipherOrganizationDetailsReadByOrganizationIdQuery.cs b/src/Infrastructure.EntityFramework/Vault/Repositories/Queries/CipherOrganizationDetailsReadByOrganizationIdQuery.cs index 1727ff4a0201..a9e4479e5be4 100644 --- a/src/Infrastructure.EntityFramework/Vault/Repositories/Queries/CipherOrganizationDetailsReadByOrganizationIdQuery.cs +++ b/src/Infrastructure.EntityFramework/Vault/Repositories/Queries/CipherOrganizationDetailsReadByOrganizationIdQuery.cs @@ -39,6 +39,7 @@ from o in o_g.DefaultIfEmpty() RevisionDate = c.RevisionDate, DeletedDate = c.DeletedDate, Key = c.Key, + Reprompt = c.Reprompt, OrganizationUseTotp = o.UseTotp, }; diff --git a/test/Infrastructure.EFIntegration.Test/Vault/Repositories/CipherRepositoryTests.cs b/test/Infrastructure.EFIntegration.Test/Vault/Repositories/CipherRepositoryTests.cs index f37aa9e7a924..02c65319db55 100644 --- a/test/Infrastructure.EFIntegration.Test/Vault/Repositories/CipherRepositoryTests.cs +++ b/test/Infrastructure.EFIntegration.Test/Vault/Repositories/CipherRepositoryTests.cs @@ -8,6 +8,7 @@ using Bit.Infrastructure.EFIntegration.Test.Repositories.EqualityComparers; using Bit.Infrastructure.EntityFramework.Repositories.Queries; using Bit.Infrastructure.EntityFramework.Repositories.Vault.Queries; +using Bit.Infrastructure.EntityFramework.Vault.Repositories.Queries; using Bit.Test.Common.AutoFixture.Attributes; using LinqToDB; using Xunit; @@ -408,6 +409,50 @@ public async Task CipherOrganizationDetailsReadByOrganizationIdQuery_ReturnsAllP Assert.Equal(createdCipher.RevisionDate, resultCipher.RevisionDate); Assert.Equal(createdCipher.DeletedDate, resultCipher.DeletedDate); Assert.Equal(createdCipher.Key, resultCipher.Key); + Assert.Equal(createdCipher.Reprompt, resultCipher.Reprompt); + Assert.Equal(efOrg.UseTotp, resultCipher.OrganizationUseTotp); + } + } + + [CiSkippedTheory, EfOrganizationCipherCustomize, BitAutoData] + public async Task CipherOrganizationDetailsReadByIdQuery_ReturnsAllProperties( + Cipher cipher, + Organization org, + List suts, + List efOrgRepos) + { + foreach (var sut in suts) + { + var i = suts.IndexOf(sut); + + var efOrg = await efOrgRepos[i].CreateAsync(org); + efOrgRepos[i].ClearChangeTracking(); + + cipher.OrganizationId = efOrg.Id; + cipher.UserId = null; + + var createdCipher = await sut.CreateAsync(cipher); + sut.ClearChangeTracking(); + + var query = new CipherOrganizationDetailsReadByIdQuery(createdCipher.Id); + var result = await sut.Run(query).ToListAsync(); + + Assert.Single(result); + var resultCipher = result[0]; + + Assert.Equal(createdCipher.Id, resultCipher.Id); + Assert.Null(resultCipher.UserId); + Assert.Equal(efOrg.Id, resultCipher.OrganizationId); + Assert.Equal(createdCipher.Type, resultCipher.Type); + Assert.Equal(createdCipher.Data, resultCipher.Data); + Assert.Equal(createdCipher.Favorites, resultCipher.Favorites); + Assert.Equal(createdCipher.Folders, resultCipher.Folders); + Assert.Equal(createdCipher.Attachments, resultCipher.Attachments); + Assert.Equal(createdCipher.CreationDate, resultCipher.CreationDate); + Assert.Equal(createdCipher.RevisionDate, resultCipher.RevisionDate); + Assert.Equal(createdCipher.DeletedDate, resultCipher.DeletedDate); + Assert.Equal(createdCipher.Key, resultCipher.Key); + Assert.Equal(createdCipher.Reprompt, resultCipher.Reprompt); Assert.Equal(efOrg.UseTotp, resultCipher.OrganizationUseTotp); } }