mirror of
https://github.com/bitwarden/server.git
synced 2025-06-30 07:36:14 -05:00
Ps 976 moving of read only organization collection items to different folder not possible (#2257)
* PS-976 - update PutPartial endpoint to return cipher info, update Cipher_Move sproc to allow users to update a cipher's folder even if they don't have edit permissions * PS-976- fix formatting errors * PS-976 - per cr feedback updated EF query to match cipher_move sproc update, and updated cipher tests to align with existing tests
This commit is contained in:
45
test/Api.Test/Controllers/CiphersControllerTests.cs
Normal file
45
test/Api.Test/Controllers/CiphersControllerTests.cs
Normal file
@ -0,0 +1,45 @@
|
||||
using System.Security.Claims;
|
||||
using Bit.Api.Controllers;
|
||||
using Bit.Api.Models.Request;
|
||||
using Bit.Core.Repositories;
|
||||
using Bit.Core.Services;
|
||||
using Bit.Test.Common.AutoFixture;
|
||||
using Bit.Test.Common.AutoFixture.Attributes;
|
||||
using Core.Models.Data;
|
||||
using NSubstitute;
|
||||
using Xunit;
|
||||
|
||||
namespace Bit.Api.Test.Controllers;
|
||||
|
||||
[ControllerCustomize(typeof(CiphersController))]
|
||||
[SutProviderCustomize]
|
||||
public class CiphersControllerTests
|
||||
{
|
||||
[Theory, BitAutoData]
|
||||
public async Task PutPartialShouldReturnCipherWithGivenFolderAndFavoriteValues(Guid userId, Guid folderId, SutProvider<CiphersController> sutProvider)
|
||||
{
|
||||
var isFavorite = true;
|
||||
var cipherId = Guid.NewGuid();
|
||||
|
||||
sutProvider.GetDependency<IUserService>()
|
||||
.GetProperUserId(Arg.Any<ClaimsPrincipal>())
|
||||
.Returns(userId);
|
||||
|
||||
var cipherDetails = new CipherDetails
|
||||
{
|
||||
Favorite = isFavorite,
|
||||
FolderId = folderId,
|
||||
Type = Core.Enums.CipherType.SecureNote,
|
||||
Data = "{}"
|
||||
};
|
||||
|
||||
sutProvider.GetDependency<ICipherRepository>()
|
||||
.GetByIdAsync(cipherId, userId)
|
||||
.Returns(Task.FromResult(cipherDetails));
|
||||
|
||||
var result = await sutProvider.Sut.PutPartial(cipherId.ToString(), new CipherPartialRequestModel { Favorite = isFavorite, FolderId = folderId.ToString() });
|
||||
|
||||
Assert.Equal(folderId.ToString(), result.FolderId);
|
||||
Assert.Equal(isFavorite, result.Favorite);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user