mirror of
https://github.com/bitwarden/server.git
synced 2025-04-05 21:18:13 -05:00
Fix tests (#1675)
* Fix SendServiceTests that arose from merge * Fixed SendService tests to be inline with spec * Reorder usings
This commit is contained in:
parent
d854332643
commit
114f58aa8e
@ -1,5 +1,8 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Text;
|
||||||
|
using System.Text.Json;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Bit.Core.Context;
|
using Bit.Core.Context;
|
||||||
using Bit.Core.Enums;
|
using Bit.Core.Enums;
|
||||||
@ -10,9 +13,9 @@ using Bit.Core.Repositories;
|
|||||||
using Bit.Core.Services;
|
using Bit.Core.Services;
|
||||||
using Bit.Core.Test.AutoFixture;
|
using Bit.Core.Test.AutoFixture;
|
||||||
using Bit.Core.Test.AutoFixture.SendFixtures;
|
using Bit.Core.Test.AutoFixture.SendFixtures;
|
||||||
|
using Microsoft.AspNetCore.Identity;
|
||||||
using NSubstitute;
|
using NSubstitute;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
using System.Text.Json;
|
|
||||||
|
|
||||||
namespace Bit.Core.Test.Services
|
namespace Bit.Core.Test.Services
|
||||||
{
|
{
|
||||||
@ -581,10 +584,11 @@ namespace Bit.Core.Test.Services
|
|||||||
{
|
{
|
||||||
Id = "TEST",
|
Id = "TEST",
|
||||||
Size = fileContents.Length,
|
Size = fileContents.Length,
|
||||||
|
Validated = false,
|
||||||
};
|
};
|
||||||
|
|
||||||
send.Type = SendType.File;
|
send.Type = SendType.File;
|
||||||
send.Data = JsonConvert.SerializeObject(sendFileData);
|
send.Data = JsonSerializer.Serialize(sendFileData);
|
||||||
|
|
||||||
sutProvider.GetDependency<ISendFileStorageService>()
|
sutProvider.GetDependency<ISendFileStorageService>()
|
||||||
.ValidateFileAsync(send, sendFileData.Id, sendFileData.Size, Arg.Any<long>())
|
.ValidateFileAsync(send, sendFileData.Id, sendFileData.Size, Arg.Any<long>())
|
||||||
@ -607,7 +611,7 @@ namespace Bit.Core.Test.Services
|
|||||||
};
|
};
|
||||||
|
|
||||||
send.Type = SendType.File;
|
send.Type = SendType.File;
|
||||||
send.Data = JsonConvert.SerializeObject(sendFileData);
|
send.Data = JsonSerializer.Serialize(sendFileData);
|
||||||
|
|
||||||
sutProvider.GetDependency<ISendFileStorageService>()
|
sutProvider.GetDependency<ISendFileStorageService>()
|
||||||
.ValidateFileAsync(send, sendFileData.Id, sendFileData.Size, Arg.Any<long>())
|
.ValidateFileAsync(send, sendFileData.Id, sendFileData.Size, Arg.Any<long>())
|
||||||
@ -616,8 +620,6 @@ namespace Bit.Core.Test.Services
|
|||||||
var badRequest = await Assert.ThrowsAsync<BadRequestException>(() =>
|
var badRequest = await Assert.ThrowsAsync<BadRequestException>(() =>
|
||||||
sutProvider.Sut.UploadFileToExistingSendAsync(new MemoryStream(Encoding.UTF8.GetBytes(fileContents)), send)
|
sutProvider.Sut.UploadFileToExistingSendAsync(new MemoryStream(Encoding.UTF8.GetBytes(fileContents)), send)
|
||||||
);
|
);
|
||||||
|
|
||||||
Assert.Contains("does not match", badRequest.Message, StringComparison.InvariantCultureIgnoreCase);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Theory]
|
[Theory]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user