1
0
mirror of https://github.com/bitwarden/server.git synced 2025-04-16 02:28:13 -05:00

[PM-5052] Upgrade to .NET 8 (#3461)

* Upgrade to .NET 8

* Linting

* Clean up old JSON deserialization code

* More .NET 8-oriented linting

* Light feedback

* Get rid of old test we don't know the root issue for

* Fix a new test

* Remove now-unnecessary Renovate constraint

* Use Any()

* Somehow a 6.0 tooling config we don't need snuck back in

* Space out properties that always change per release

* Bump a few core packages since the last update
This commit is contained in:
Matt Bishop 2024-02-05 13:03:42 -05:00 committed by GitHub
parent 3c5e9ac1aa
commit ae1fdb0992
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
38 changed files with 82 additions and 132 deletions

View File

@ -7,7 +7,7 @@
"commands": ["swagger"] "commands": ["swagger"]
}, },
"dotnet-ef": { "dotnet-ef": {
"version": "7.0.15", "version": "8.0.0",
"commands": ["dotnet-ef"] "commands": ["dotnet-ef"]
} }
} }

View File

@ -1,8 +1,10 @@
<Project> <Project>
<PropertyGroup> <PropertyGroup>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net8.0</TargetFramework>
<Version>2024.2.0</Version> <Version>2024.2.0</Version>
<RootNamespace>Bit.$(MSBuildProjectName)</RootNamespace> <RootNamespace>Bit.$(MSBuildProjectName)</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion> <IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
@ -17,31 +19,31 @@
<!-- <!--
NuGet: https://www.nuget.org/packages/Microsoft.NET.Test.Sdk NuGet: https://www.nuget.org/packages/Microsoft.NET.Test.Sdk
--> -->
<MicrosoftNetTestSdkVersion>17.1.0</MicrosoftNetTestSdkVersion> <MicrosoftNetTestSdkVersion>17.8.0</MicrosoftNetTestSdkVersion>
<!-- <!--
NuGet: https://www.nuget.org/packages/xunit NuGet: https://www.nuget.org/packages/xunit
--> -->
<XUnitVersion>2.4.1</XUnitVersion> <XUnitVersion>2.6.6</XUnitVersion>
<!-- <!--
NuGet: https://www.nuget.org/packages/xunit NuGet: https://www.nuget.org/packages/xunit.runner.visualstudio
--> -->
<XUnitRunnerVisualStudioVersion>2.4.3</XUnitRunnerVisualStudioVersion> <XUnitRunnerVisualStudioVersion>2.5.6</XUnitRunnerVisualStudioVersion>
<!-- <!--
NuGet: https://www.nuget.org/packages/coverlet.collector/ NuGet: https://www.nuget.org/packages/coverlet.collector
--> -->
<CoverletCollectorVersion>3.1.2</CoverletCollectorVersion> <CoverletCollectorVersion>6.0.0</CoverletCollectorVersion>
<!-- <!--
NuGet: https://www.nuget.org/packages/NSubstitute/ NuGet: https://www.nuget.org/packages/NSubstitute
--> -->
<NSubstituteVersion>4.3.0</NSubstituteVersion> <NSubstituteVersion>5.1.0</NSubstituteVersion>
<!-- <!--
NuGet: https://www.nuget.org/packages/AutoFixture.Xunit2/ NuGet: https://www.nuget.org/packages/AutoFixture.Xunit2
--> -->
<AutoFixtureXUnit2Version>4.17.0</AutoFixtureXUnit2Version> <AutoFixtureXUnit2Version>4.18.1</AutoFixtureXUnit2Version>
<!-- <!--
NuGet: https://www.nuget.org/packages/AutoFixture.AutoNSubstitute/ NuGet: https://www.nuget.org/packages/AutoFixture.AutoNSubstitute
--> -->
<AutoFixtureAutoNSubstituteVersion>4.17.0</AutoFixtureAutoNSubstituteVersion> <AutoFixtureAutoNSubstituteVersion>4.18.1</AutoFixtureAutoNSubstituteVersion>
</PropertyGroup> </PropertyGroup>
<!-- <!--
@ -62,4 +64,4 @@
</ItemGroup> </ItemGroup>
</Target> </Target>
</Project> </Project>

View File

@ -1,11 +1,11 @@
FROM mcr.microsoft.com/dotnet/aspnet:6.0 FROM mcr.microsoft.com/dotnet/aspnet:8.0
LABEL com.bitwarden.product="bitwarden" LABEL com.bitwarden.product="bitwarden"
RUN apt-get update \ RUN apt-get update \
&& apt-get install -y --no-install-recommends \ && apt-get install -y --no-install-recommends \
gosu \ gosu \
curl \ curl \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
ENV ASPNETCORE_URLS http://+:5000 ENV ASPNETCORE_URLS http://+:5000

View File

@ -1,11 +1,11 @@
FROM mcr.microsoft.com/dotnet/aspnet:6.0 FROM mcr.microsoft.com/dotnet/aspnet:8.0
LABEL com.bitwarden.product="bitwarden" LABEL com.bitwarden.product="bitwarden"
RUN apt-get update \ RUN apt-get update \
&& apt-get install -y --no-install-recommends \ && apt-get install -y --no-install-recommends \
gosu \ gosu \
curl \ curl \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
ENV ASPNETCORE_URLS http://+:5000 ENV ASPNETCORE_URLS http://+:5000

View File

@ -167,7 +167,7 @@ static class CommandResultExtensions
foreach (var h in commandResult.Headers) foreach (var h in commandResult.Headers)
{ {
httpContext.Response.Headers.Add(h.Key, h.Value); httpContext.Response.Headers.Append(h.Key, h.Value);
} }
if (!string.IsNullOrEmpty(commandResult.ClearCookieName)) if (!string.IsNullOrEmpty(commandResult.ClearCookieName))

View File

@ -90,12 +90,12 @@ public class ScimApplicationFactory : WebApplicationFactoryBase<Startup>
public async Task<HttpContext> GroupsPostAsync(Guid organizationId, ScimGroupRequestModel model) public async Task<HttpContext> GroupsPostAsync(Guid organizationId, ScimGroupRequestModel model)
{ {
return await Server.PostAsync($"/v2/{organizationId}/groups", GetStringContent(model), httpContext => httpContext.Request.Headers.Add(HeaderNames.UserAgent, "Okta")); return await Server.PostAsync($"/v2/{organizationId}/groups", GetStringContent(model), httpContext => httpContext.Request.Headers.Append(HeaderNames.UserAgent, "Okta"));
} }
public async Task<HttpContext> GroupsPutAsync(Guid organizationId, Guid id, ScimGroupRequestModel model) public async Task<HttpContext> GroupsPutAsync(Guid organizationId, Guid id, ScimGroupRequestModel model)
{ {
return await Server.PutAsync($"/v2/{organizationId}/groups/{id}", GetStringContent(model), httpContext => httpContext.Request.Headers.Add(HeaderNames.UserAgent, "Okta")); return await Server.PutAsync($"/v2/{organizationId}/groups/{id}", GetStringContent(model), httpContext => httpContext.Request.Headers.Append(HeaderNames.UserAgent, "Okta"));
} }
public async Task<HttpContext> GroupsPatchAsync(Guid organizationId, Guid id, ScimPatchModel model) public async Task<HttpContext> GroupsPatchAsync(Guid organizationId, Guid id, ScimPatchModel model)

View File

@ -1,6 +1,6 @@
{ {
"sdk": { "sdk": {
"version": "6.0.100", "version": "8.0.100",
"rollForward": "latestFeature" "rollForward": "latestFeature"
} }
} }

View File

@ -2,7 +2,6 @@
<PropertyGroup> <PropertyGroup>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
</PropertyGroup> </PropertyGroup>

View File

@ -1,11 +1,11 @@
FROM mcr.microsoft.com/dotnet/aspnet:6.0 FROM mcr.microsoft.com/dotnet/aspnet:8.0
LABEL com.bitwarden.product="bitwarden" LABEL com.bitwarden.product="bitwarden"
RUN apt-get update \ RUN apt-get update \
&& apt-get install -y --no-install-recommends \ && apt-get install -y --no-install-recommends \
gosu \ gosu \
curl \ curl \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
ENV ASPNETCORE_URLS http://+:5000 ENV ASPNETCORE_URLS http://+:5000

View File

@ -67,14 +67,14 @@ public class AzureQueueMailHostedService : IHostedService
if (root.ValueKind == JsonValueKind.Array) if (root.ValueKind == JsonValueKind.Array)
{ {
foreach (var mailQueueMessage in root.ToObject<List<MailQueueMessage>>()) foreach (var mailQueueMessage in root.Deserialize<List<MailQueueMessage>>())
{ {
await _mailService.SendEnqueuedMailMessageAsync(mailQueueMessage); await _mailService.SendEnqueuedMailMessageAsync(mailQueueMessage);
} }
} }
else if (root.ValueKind == JsonValueKind.Object) else if (root.ValueKind == JsonValueKind.Object)
{ {
var mailQueueMessage = root.ToObject<MailQueueMessage>(); var mailQueueMessage = root.Deserialize<MailQueueMessage>();
await _mailService.SendEnqueuedMailMessageAsync(mailQueueMessage); await _mailService.SendEnqueuedMailMessageAsync(mailQueueMessage);
} }
} }

View File

@ -31,7 +31,7 @@ public class OrganizationConnectionRequestModel<T> : OrganizationConnectionReque
try try
{ {
ParsedConfig = model.Config.ToObject<T>(JsonHelpers.IgnoreCase); ParsedConfig = model.Config.Deserialize<T>(JsonHelpers.IgnoreCase);
} }
catch (JsonException) catch (JsonException)
{ {

View File

@ -1,11 +1,11 @@
FROM mcr.microsoft.com/dotnet/aspnet:6.0 FROM mcr.microsoft.com/dotnet/aspnet:8.0
LABEL com.bitwarden.product="bitwarden" LABEL com.bitwarden.product="bitwarden"
RUN apt-get update \ RUN apt-get update \
&& apt-get install -y --no-install-recommends \ && apt-get install -y --no-install-recommends \
gosu \ gosu \
curl \ curl \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
ENV ASPNETCORE_URLS http://+:5000 ENV ASPNETCORE_URLS http://+:5000

View File

@ -1,11 +1,11 @@
FROM mcr.microsoft.com/dotnet/aspnet:6.0 FROM mcr.microsoft.com/dotnet/aspnet:8.0
LABEL com.bitwarden.product="bitwarden" LABEL com.bitwarden.product="bitwarden"
RUN apt-get update \ RUN apt-get update \
&& apt-get install -y --no-install-recommends \ && apt-get install -y --no-install-recommends \
gosu \ gosu \
curl \ curl \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
ENV ASPNETCORE_URLS http://+:5000 ENV ASPNETCORE_URLS http://+:5000

View File

@ -59,7 +59,7 @@ public class CreateOrganizationDomainCommand : ICreateOrganizationDomainCommand
} }
catch (Exception e) catch (Exception e)
{ {
_logger.LogError("Error verifying Organization domain.", e); _logger.LogError(e, "Error verifying Organization domain.");
} }
organizationDomain.SetNextRunDate(_globalSettings.DomainVerification.VerificationInterval); organizationDomain.SetNextRunDate(_globalSettings.DomainVerification.VerificationInterval);

View File

@ -88,7 +88,7 @@ public class ValidateSponsorshipCommand : CancelSponsorshipCommand, IValidateSpo
} }
catch (Exception e) catch (Exception e)
{ {
_logger.LogError("Error sending Family sponsorship removed email.", e); _logger.LogError(e, "Error sending Family sponsorship removed email.");
} }
} }
await base.DeleteSponsorshipAsync(sponsorship); await base.DeleteSponsorshipAsync(sponsorship);

View File

@ -45,18 +45,6 @@ public static class JsonHelpers
}; };
} }
[Obsolete("This is built into .NET 6, it SHOULD be removed when we upgrade")]
public static T ToObject<T>(this JsonElement element, JsonSerializerOptions options = null)
{
return JsonSerializer.Deserialize<T>(element.GetRawText(), options ?? Default);
}
[Obsolete("This is built into .NET 6, it SHOULD be removed when we upgrade")]
public static T ToObject<T>(this JsonDocument document, JsonSerializerOptions options = null)
{
return JsonSerializer.Deserialize<T>(document.RootElement.GetRawText(), options ?? default);
}
public static T DeserializeOrNew<T>(string json, JsonSerializerOptions options = null) public static T DeserializeOrNew<T>(string json, JsonSerializerOptions options = null)
where T : new() where T : new()
{ {

View File

@ -15,13 +15,13 @@ public sealed class SecurityHeadersMiddleware
public Task Invoke(HttpContext context) public Task Invoke(HttpContext context)
{ {
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options
context.Response.Headers.Add("x-frame-options", new StringValues("SAMEORIGIN")); context.Response.Headers.Append("x-frame-options", new StringValues("SAMEORIGIN"));
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-XSS-Protection // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-XSS-Protection
context.Response.Headers.Add("x-xss-protection", new StringValues("1; mode=block")); context.Response.Headers.Append("x-xss-protection", new StringValues("1; mode=block"));
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Content-Type-Options // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Content-Type-Options
context.Response.Headers.Add("x-content-type-options", new StringValues("nosniff")); context.Response.Headers.Append("x-content-type-options", new StringValues("nosniff"));
return _next(context); return _next(context);
} }

View File

@ -18,21 +18,4 @@ public static class SpanExtensions
rest = input[++splitIndex..]; rest = input[++splitIndex..];
return true; return true;
} }
// Replace with the implementation from .NET 8 when we upgrade
// Ref: https://github.com/dotnet/runtime/issues/59466
public static int Count<T>(this ReadOnlySpan<T> span, T value)
where T : IEquatable<T>
{
var count = 0;
int pos;
while ((pos = span.IndexOf(value)) >= 0)
{
span = span[++pos..];
count++;
}
return count;
}
} }

View File

@ -1,11 +1,11 @@
FROM mcr.microsoft.com/dotnet/aspnet:6.0 FROM mcr.microsoft.com/dotnet/aspnet:8.0
LABEL com.bitwarden.product="bitwarden" LABEL com.bitwarden.product="bitwarden"
RUN apt-get update \ RUN apt-get update \
&& apt-get install -y --no-install-recommends \ && apt-get install -y --no-install-recommends \
gosu \ gosu \
curl \ curl \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
ENV ASPNETCORE_URLS http://+:5000 ENV ASPNETCORE_URLS http://+:5000

View File

@ -104,13 +104,13 @@ public class AzureQueueHostedService : IHostedService, IDisposable
var root = jsonDocument.RootElement; var root = jsonDocument.RootElement;
if (root.ValueKind == JsonValueKind.Array) if (root.ValueKind == JsonValueKind.Array)
{ {
var indexedEntities = root.ToObject<List<EventMessage>>() var indexedEntities = root.Deserialize<List<EventMessage>>()
.SelectMany(e => EventTableEntity.IndexEvent(e)); .SelectMany(e => EventTableEntity.IndexEvent(e));
events.AddRange(indexedEntities); events.AddRange(indexedEntities);
} }
else if (root.ValueKind == JsonValueKind.Object) else if (root.ValueKind == JsonValueKind.Object)
{ {
var eventMessage = root.ToObject<EventMessage>(); var eventMessage = root.Deserialize<EventMessage>();
events.AddRange(EventTableEntity.IndexEvent(eventMessage)); events.AddRange(EventTableEntity.IndexEvent(eventMessage));
} }

View File

@ -1,11 +1,11 @@
FROM mcr.microsoft.com/dotnet/aspnet:6.0 FROM mcr.microsoft.com/dotnet/aspnet:8.0
LABEL com.bitwarden.product="bitwarden" LABEL com.bitwarden.product="bitwarden"
RUN apt-get update \ RUN apt-get update \
&& apt-get install -y --no-install-recommends \ && apt-get install -y --no-install-recommends \
gosu \ gosu \
curl \ curl \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
ENV ASPNETCORE_URLS http://+:5000 ENV ASPNETCORE_URLS http://+:5000

View File

@ -1,11 +1,11 @@
FROM mcr.microsoft.com/dotnet/aspnet:6.0 FROM mcr.microsoft.com/dotnet/aspnet:8.0
LABEL com.bitwarden.product="bitwarden" LABEL com.bitwarden.product="bitwarden"
RUN apt-get update \ RUN apt-get update \
&& apt-get install -y --no-install-recommends \ && apt-get install -y --no-install-recommends \
gosu \ gosu \
curl \ curl \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
ENV ASPNETCORE_URLS http://+:5000 ENV ASPNETCORE_URLS http://+:5000

View File

@ -1,11 +1,11 @@
FROM mcr.microsoft.com/dotnet/aspnet:6.0 FROM mcr.microsoft.com/dotnet/aspnet:8.0
LABEL com.bitwarden.product="bitwarden" LABEL com.bitwarden.product="bitwarden"
RUN apt-get update \ RUN apt-get update \
&& apt-get install -y --no-install-recommends \ && apt-get install -y --no-install-recommends \
gosu \ gosu \
curl \ curl \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
ENV ASPNETCORE_URLS http://+:5000 ENV ASPNETCORE_URLS http://+:5000

View File

@ -1,11 +1,11 @@
FROM mcr.microsoft.com/dotnet/aspnet:6.0 FROM mcr.microsoft.com/dotnet/aspnet:8.0
LABEL com.bitwarden.product="bitwarden" LABEL com.bitwarden.product="bitwarden"
RUN apt-get update \ RUN apt-get update \
&& apt-get install -y --no-install-recommends \ && apt-get install -y --no-install-recommends \
gosu \ gosu \
curl \ curl \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
ENV ASPNETCORE_URLS http://+:5000 ENV ASPNETCORE_URLS http://+:5000

View File

@ -96,7 +96,7 @@ public class OrganizationServiceTests
await sutProvider.GetDependency<IOrganizationUserRepository>().DidNotReceiveWithAnyArgs() await sutProvider.GetDependency<IOrganizationUserRepository>().DidNotReceiveWithAnyArgs()
.UpsertAsync(default); .UpsertAsync(default);
await sutProvider.GetDependency<IOrganizationUserRepository>().Received(1) await sutProvider.GetDependency<IOrganizationUserRepository>().Received(1)
.UpsertManyAsync(Arg.Is<IEnumerable<OrganizationUser>>(users => users.Count() == 0)); .UpsertManyAsync(Arg.Is<IEnumerable<OrganizationUser>>(users => !users.Any()));
await sutProvider.GetDependency<IOrganizationUserRepository>().DidNotReceiveWithAnyArgs() await sutProvider.GetDependency<IOrganizationUserRepository>().DidNotReceiveWithAnyArgs()
.CreateAsync(default); .CreateAsync(default);

View File

@ -41,7 +41,7 @@ public class DeviceServiceTests
} }
/// <summary> /// <summary>
/// Story: A user choosed to keep trust in one of their current trusted devices, but not in another one of their /// Story: A user chose to keep trust in one of their current trusted devices, but not in another one of their
/// devices. We will rotate the trust of the currently signed in device as well as the device they chose but will /// devices. We will rotate the trust of the currently signed in device as well as the device they chose but will
/// remove the trust of the device they didn't give new keys for. /// remove the trust of the device they didn't give new keys for.
/// </summary> /// </summary>
@ -117,8 +117,7 @@ public class DeviceServiceTests
.Received(3) .Received(3)
.UpsertAsync(Arg.Any<Device>()); .UpsertAsync(Arg.Any<Device>());
// TODO: .NET 8: Use nameof for parameter name. static void SetupOldTrust(Device device, [CallerArgumentExpression(nameof(device))] string expression = null)
static void SetupOldTrust(Device device, [CallerArgumentExpression("device")] string expression = null)
{ {
device.EncryptedPublicKey = $"old_public_{expression}"; device.EncryptedPublicKey = $"old_public_{expression}";
device.EncryptedPrivateKey = $"old_private_{expression}"; device.EncryptedPrivateKey = $"old_private_{expression}";

View File

@ -31,22 +31,4 @@ public class SpanExtensionsTests
Assert.True(splitChunk.IsEmpty); Assert.True(splitChunk.IsEmpty);
Assert.Equal(fullString, rest.ToString()); Assert.Equal(fullString, rest.ToString());
} }
[Theory]
[InlineData("11111", '1', 5)]
[InlineData("Text", 'z', 0)]
[InlineData("1", '1', 1)]
public void Count_ReturnsCount(string text, char countChar, int expectedInstances)
{
Assert.Equal(expectedInstances, text.AsSpan().Count(countChar));
}
[Theory]
[InlineData(new[] { 5, 4 }, 5, 1)]
[InlineData(new[] { 1 }, 5, 0)]
[InlineData(new[] { 5, 5, 5 }, 5, 3)]
public void CountIntegers_ReturnsCount(int[] array, int countNumber, int expectedInstances)
{
Assert.Equal(expectedInstances, ((ReadOnlySpan<int>)array.AsSpan()).Count(countNumber));
}
} }

View File

@ -15,7 +15,6 @@ using Bit.Core.Vault.Repositories;
using Bit.Core.Vault.Services; using Bit.Core.Vault.Services;
using Bit.Test.Common.AutoFixture; using Bit.Test.Common.AutoFixture;
using Bit.Test.Common.AutoFixture.Attributes; using Bit.Test.Common.AutoFixture.Attributes;
using Castle.Core.Internal;
using NSubstitute; using NSubstitute;
using Xunit; using Xunit;
@ -75,7 +74,7 @@ public class CipherServiceTests
!cols.Any(c => c.Id == collections[0].Id) && // Check that the collection that already existed in the organization was not added !cols.Any(c => c.Id == collections[0].Id) && // Check that the collection that already existed in the organization was not added
cols.All(c => collections.Any(x => c.Name == x.Name))), cols.All(c => collections.Any(x => c.Name == x.Name))),
Arg.Is<IEnumerable<CollectionCipher>>(c => c.Count() == ciphers.Count), Arg.Is<IEnumerable<CollectionCipher>>(c => c.Count() == ciphers.Count),
Arg.Is<IEnumerable<CollectionUser>>(i => i.IsNullOrEmpty())); Arg.Is<IEnumerable<CollectionUser>>(i => !i.Any()));
await sutProvider.GetDependency<IPushNotificationService>().Received(1).PushSyncVaultAsync(importingUserId); await sutProvider.GetDependency<IPushNotificationService>().Received(1).PushSyncVaultAsync(importingUserId);
await sutProvider.GetDependency<IReferenceEventService>().Received(1).RaiseEventAsync( await sutProvider.GetDependency<IReferenceEventService>().Received(1).RaiseEventAsync(
Arg.Is<ReferenceEvent>(e => e.Type == ReferenceEventType.VaultImported)); Arg.Is<ReferenceEvent>(e => e.Type == ReferenceEventType.VaultImported));
@ -683,7 +682,7 @@ public class CipherServiceTests
await sutProvider.Sut.ShareManyAsync(cipherInfos, organization.Id, collectionIds, sharingUserId); await sutProvider.Sut.ShareManyAsync(cipherInfos, organization.Id, collectionIds, sharingUserId);
await sutProvider.GetDependency<ICipherRepository>().Received(1).UpdateCiphersAsync(sharingUserId, await sutProvider.GetDependency<ICipherRepository>().Received(1).UpdateCiphersAsync(sharingUserId,
Arg.Is<IEnumerable<Cipher>>(arg => arg.Except(ciphers).IsNullOrEmpty())); Arg.Is<IEnumerable<Cipher>>(arg => !arg.Except(ciphers).Any()));
} }
[Theory] [Theory]
@ -839,7 +838,7 @@ public class CipherServiceTests
await sutProvider.Sut.ShareManyAsync(cipherInfos, organizationId, collectionIds, sharingUserId); await sutProvider.Sut.ShareManyAsync(cipherInfos, organizationId, collectionIds, sharingUserId);
await sutProvider.GetDependency<ICipherRepository>().Received(1).UpdateCiphersAsync(sharingUserId, await sutProvider.GetDependency<ICipherRepository>().Received(1).UpdateCiphersAsync(sharingUserId,
Arg.Is<IEnumerable<Cipher>>(arg => arg.Except(ciphers).IsNullOrEmpty())); Arg.Is<IEnumerable<Cipher>>(arg => !arg.Except(ciphers).Any()));
} }
private async Task AssertNoActionsAsync(SutProvider<CipherService> sutProvider) private async Task AssertNoActionsAsync(SutProvider<CipherService> sutProvider)

View File

@ -68,11 +68,11 @@ public class IconLinkTests
} }
[Fact] [Fact]
public void FetchAsync_Unvalidated_ReturnsNull() public async Task FetchAsync_Unvalidated_ReturnsNull()
{ {
var result = new IconLink(_element, _uri, _baseUrlPath).FetchAsync(_logger, _httpClientFactory, _uriService); var result = await new IconLink(_element, _uri, _baseUrlPath).FetchAsync(_logger, _httpClientFactory, _uriService);
Assert.Null(result.Result); Assert.Null(result);
} }
private void SetAttributeValue(string attribute, string value) private void SetAttributeValue(string attribute, string value)

View File

@ -11,9 +11,8 @@ public class IconFetchingServiceTests : ServiceTestBase<IconFetchingService>
[InlineData("neverssl.com")] // http site [InlineData("neverssl.com")] // http site
[InlineData("neopets.com")] // uses favicon.ico [InlineData("neopets.com")] // uses favicon.ico
[InlineData("hopin.com")] // uses svg+xml format [InlineData("hopin.com")] // uses svg+xml format
[InlineData("ameritrade.com")] // redirects to tdameritrace.com [InlineData("ameritrade.com")] // redirects to tdameritrade.com
[InlineData("icloud.com")] [InlineData("icloud.com")]
[InlineData("bofa.com", Skip = "Broken in pipeline for .NET 6. Tracking link: https://bitwarden.atlassian.net/browse/PS-982")]
public async Task GetIconAsync_Success(string domain) public async Task GetIconAsync_Success(string domain)
{ {
var sut = BuildSut(); var sut = BuildSut();

View File

@ -106,7 +106,7 @@ public class IdentityServerTests : IClassFixture<IdentityApplicationFactory>
MasterPasswordHash = "master_password_hash", MasterPasswordHash = "master_password_hash",
}); });
var context = await PostLoginAsync(_factory.Server, username, deviceId, context => context.Request.Headers.Add("Auth-Email", "bad_value")); var context = await PostLoginAsync(_factory.Server, username, deviceId, context => context.Request.Headers.Append("Auth-Email", "bad_value"));
Assert.Equal(StatusCodes.Status400BadRequest, context.Response.StatusCode); Assert.Equal(StatusCodes.Status400BadRequest, context.Response.StatusCode);

View File

@ -183,7 +183,7 @@ public class OrganizationRepositoryTests
Assert.Equal(efOrgRepos.Count, efList.Count); Assert.Equal(efOrgRepos.Count, efList.Count);
Assert.True(efList.All(o => o.Name == org.Name)); Assert.True(efList.All(o => o.Name == org.Name));
Assert.Equal(1, sqlResult.Count); Assert.Single(sqlResult);
Assert.True(sqlResult.All(o => o.Name == org.Name)); Assert.True(sqlResult.All(o => o.Name == org.Name));
} }
} }

View File

@ -35,7 +35,7 @@ public class IdentityApplicationFactory : WebApplicationFactoryBase<Startup>
{ "grant_type", "password" }, { "grant_type", "password" },
{ "username", username }, { "username", username },
{ "password", password }, { "password", password },
}), context => context.Request.Headers.Add("Auth-Email", CoreHelpers.Base64UrlEncodeString(username))); }), context => context.Request.Headers.Append("Auth-Email", CoreHelpers.Base64UrlEncodeString(username)));
using var body = await AssertHelper.AssertResponseTypeIs<JsonDocument>(context); using var body = await AssertHelper.AssertResponseTypeIs<JsonDocument>(context);
var root = body.RootElement; var root = body.RootElement;

View File

@ -28,7 +28,7 @@ public static class WebApplicationFactoryExtensions
{ {
foreach (var header in content.Headers) foreach (var header in content.Headers)
{ {
httpContext.Request.Headers.Add(header.Key, new StringValues(header.Value.ToArray())); httpContext.Request.Headers.Append(header.Key, new StringValues(header.Value.ToArray()));
} }
httpContext.Request.Body = content.ReadAsStream(); httpContext.Request.Body = content.ReadAsStream();
@ -64,7 +64,7 @@ public static class WebApplicationFactoryExtensions
public static HttpContext SetAuthEmail(this HttpContext context, string username) public static HttpContext SetAuthEmail(this HttpContext context, string username)
{ {
context.Request.Headers.Add("Auth-Email", CoreHelpers.Base64UrlEncodeString(username)); context.Request.Headers.Append("Auth-Email", CoreHelpers.Base64UrlEncodeString(username));
return context; return context;
} }

View File

@ -1,4 +1,4 @@
FROM mcr.microsoft.com/dotnet/aspnet:6.0 FROM mcr.microsoft.com/dotnet/aspnet:8.0
LABEL com.bitwarden.product="bitwarden" LABEL com.bitwarden.product="bitwarden"

View File

@ -1,4 +1,4 @@
FROM mcr.microsoft.com/dotnet/aspnet:6.0 FROM mcr.microsoft.com/dotnet/aspnet:8.0
LABEL com.bitwarden.product="bitwarden" LABEL com.bitwarden.product="bitwarden"

View File

@ -1,12 +1,12 @@
FROM mcr.microsoft.com/dotnet/aspnet:6.0 FROM mcr.microsoft.com/dotnet/aspnet:8.0
LABEL com.bitwarden.product="bitwarden" com.bitwarden.project="setup" LABEL com.bitwarden.product="bitwarden" com.bitwarden.project="setup"
RUN apt-get update \ RUN apt-get update \
&& apt-get install -y --no-install-recommends \ && apt-get install -y --no-install-recommends \
openssl \ openssl \
gosu \ gosu \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
WORKDIR /app WORKDIR /app
COPY obj/build-output/publish . COPY obj/build-output/publish .

View File

@ -1,7 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
</PropertyGroup> </PropertyGroup>