Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ from o in o_g.DefaultIfEmpty()
CreationDate = c.CreationDate,
RevisionDate = c.RevisionDate,
DeletedDate = c.DeletedDate,
Key = c.Key,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎨 Reprompt is also not being mapped/grabbed here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch! 40c0b8e

Reprompt = c.Reprompt,
OrganizationUseTotp = o.UseTotp,
};

Expand Down
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

πŸ‘ Thanks for the tests as always!

Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
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.Infrastructure.EntityFramework.Vault.Repositories.Queries;
using Bit.Test.Common.AutoFixture.Attributes;
using LinqToDB;
using Xunit;
Expand Down Expand Up @@ -368,4 +370,90 @@ 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<EfVaultRepo.CipherRepository> suts,
List<EfRepo.OrganizationRepository> 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(createdCipher.Reprompt, resultCipher.Reprompt);
Assert.Equal(efOrg.UseTotp, resultCipher.OrganizationUseTotp);
}
}

[CiSkippedTheory, EfOrganizationCipherCustomize, BitAutoData]
public async Task CipherOrganizationDetailsReadByIdQuery_ReturnsAllProperties(
Cipher cipher,
Organization org,
List<EfVaultRepo.CipherRepository> suts,
List<EfRepo.OrganizationRepository> 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);
}
}
}
Loading