Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to .NET 8.0, NuGet packages, Caddy 2.7 #671

Merged
merged 6 commits into from
Jan 13, 2024
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0.x
dotnet-version: 8.0.x

- name: Install wasm-tools
run: dotnet workload install wasm-tools
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0.x
dotnet-version: 8.0.x

- name: Install wasm-tools
run: dotnet workload install wasm-tools
Expand Down
9 changes: 5 additions & 4 deletions Crypter.API/Crypter.API.csproj
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>disable</ImplicitUsings>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<LangVersion>12</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(RunConfiguration)' == 'crypterAPI' " />
<ItemGroup>
Expand All @@ -17,15 +18,15 @@
<ProjectReference Include="..\Crypter.Core\Crypter.Core.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.11">
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.11">
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="7.0.11" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.1" />
</ItemGroup>
</Project>
23 changes: 16 additions & 7 deletions Crypter.API/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,30 @@
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /source/

RUN dotnet tool install --global dotnet-references
RUN dotnet tool install --global dotnet-ef --version 7.0.*
RUN dotnet tool install --global dotnet-ef --version 8.0.*
ENV PATH="${PATH}:/root/.dotnet/tools"

COPY ../*.sln ./
COPY ../*/*.csproj ./
COPY ../Crypter.API/*.csproj ./Crypter.API/
COPY ../Crypter.Common/*.csproj ./Crypter.Common/
COPY ../Crypter.Core/*.csproj ./Crypter.Core/
COPY ../Crypter.Crypto.Common/*.csproj ./Crypter.Crypto.Common/
COPY ../Crypter.Crypto.Providers.Default/*.csproj ./Crypter.Crypto.Providers.Default/
COPY ../Crypter.DataAccess/*.csproj ./Crypter.DataAccess/

RUN dotnet-references fix --entry-point ./Crypter.sln --working-directory ./ --remove-unreferenced-project-files
RUN dotnet restore Crypter.API --runtime linux-x64

COPY ./ ./
COPY Crypter.API/. ./Crypter.API/
COPY Crypter.Common/. ./Crypter.Common/
COPY Crypter.Core/. ./Crypter.Core/
COPY Crypter.Crypto.Common/. ./Crypter.Crypto.Common/
COPY Crypter.Crypto.Providers.Default/. ./Crypter.Crypto.Providers.Default/
COPY Crypter.DataAccess/. ./Crypter.DataAccess/

RUN dotnet publish Crypter.API --configuration release --no-self-contained /p:TreatWarningsAsErrors=true /warnaserror --output /app/
RUN dotnet-ef migrations bundle --project Crypter.DataAccess --startup-project Crypter.API --configuration release --no-build --target-runtime linux-x64 --output /app/efbundle --verbose

FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS runtime
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS runtime
WORKDIR /app
COPY --from=build /app ./
CMD ["dotnet", "Crypter.API.dll"]
5 changes: 3 additions & 2 deletions Crypter.Benchmarks/Crypter.Benchmarks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>enable</Nullable>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<LangVersion>12</LangVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.9" />
<PackageReference Include="BenchmarkDotNet" Version="0.13.12" />
</ItemGroup>

<ItemGroup>
Expand Down
3 changes: 2 additions & 1 deletion Crypter.Common.Client/Crypter.Common.Client.csproj
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>enable</Nullable>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<LangVersion>12</LangVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
5 changes: 3 additions & 2 deletions Crypter.Common/Crypter.Common.csproj
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<Nullable>enable</Nullable>
<LangVersion>12</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="EasyMonads" Version="2.0.0" />
<PackageReference Include="Microsoft.IdentityModel.Tokens" Version="7.0.2" />
<PackageReference Include="Microsoft.IdentityModel.Tokens" Version="7.2.0" />
<PackageReference Include="ValueOf" Version="2.0.31" />
</ItemGroup>
</Project>
19 changes: 10 additions & 9 deletions Crypter.Core/Crypter.Core.csproj
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Nullable>disable</Nullable>
<ImplicitUsings>disable</ImplicitUsings>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<LangVersion>12</LangVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Hangfire.AspNetCore" Version="1.8.5" />
<PackageReference Include="Hangfire.Core" Version="1.8.5" />
<PackageReference Include="Hangfire.PostgreSql" Version="1.20.3" />
<PackageReference Include="Hangfire.AspNetCore" Version="1.8.7" />
<PackageReference Include="Hangfire.Core" Version="1.8.7" />
<PackageReference Include="Hangfire.PostgreSql" Version="1.20.5" />
<PackageReference Include="Hashids.net" Version="1.7.0" />
<PackageReference Include="MailKit" Version="4.2.0" />
<PackageReference Include="MailKit" Version="4.3.0" />
<PackageReference Include="MediatR" Version="12.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Cryptography.KeyDerivation" Version="7.0.11" />
<PackageReference Include="MimeKit" Version="4.2.0" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.11" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="7.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Cryptography.KeyDerivation" Version="8.0.1" />
<PackageReference Include="MimeKit" Version="4.3.0" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.0" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="7.2.0" />
</ItemGroup>

<ItemGroup>
Expand Down
3 changes: 2 additions & 1 deletion Crypter.Crypto.Common/Crypter.Crypto.Common.csproj
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>disable</Nullable>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<LangVersion>12</LangVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>disable</Nullable>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<LangVersion>12</LangVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BlazorSodium" Version="1.2.0" />
<PackageReference Include="BlazorSodium" Version="1.3.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>disable</Nullable>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<LangVersion>12</LangVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Geralt" Version="3.0.0" />
<PackageReference Include="Geralt" Version="3.0.1" />
</ItemGroup>

<ItemGroup>
Expand Down
9 changes: 5 additions & 4 deletions Crypter.DataAccess/Crypter.DataAccess.csproj
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<LangVersion>12</LangVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.11" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="7.0.11" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.11" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="8.0.1" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,47 +42,47 @@ public void Setup()
public void Code_Encoding_Is_Consistent()
{
Guid code = new Guid("adec7c67-dfb6-4b9f-9a1f-04c0b0f4643c");
string knownEncoding = "Z3zsrbbfn0uaHwTAsPRkPA";
const string knownEncoding = "Z3zsrbbfn0uaHwTAsPRkPA";
string newEncoding = UrlSafeEncoder.EncodeGuidUrlSafe(code);
Assert.AreEqual(knownEncoding, newEncoding);
Assert.That(newEncoding, Is.EqualTo(knownEncoding));
}

[Test]
public void Code_Decoding_Is_Consistent()
{
string encoding = "Z3zsrbbfn0uaHwTAsPRkPA";
const string encoding = "Z3zsrbbfn0uaHwTAsPRkPA";
Guid knownCode = new Guid("adec7c67-dfb6-4b9f-9a1f-04c0b0f4643c");
Guid newCode = UrlSafeEncoder.DecodeGuidFromUrlSafe(encoding);
Assert.AreEqual(knownCode, newCode);
Assert.That(newCode, Is.EqualTo(knownCode));
}

[Test]
public void Signature_Encoding_Is_Consistent()
{
byte[] bytes = new byte[]
{
byte[] bytes =
[
0x8b, 0x6f, 0xa0, 0x13, 0x13, 0xce, 0x51, 0xaf,
0xc0, 0x9e, 0x61, 0x0f, 0x81, 0x92, 0x50, 0xda,
0x50, 0x17, 0x78, 0xad, 0x36, 0x3c, 0xba, 0x4f,
0x9e, 0x31, 0x2a, 0x6e, 0xc8, 0x23, 0xd4, 0x2a
};
string knownEncoding = "i2-gExPOUa_AnmEPgZJQ2lAXeK02PLpPnjEqbsgj1Co";
];
const string knownEncoding = "i2-gExPOUa_AnmEPgZJQ2lAXeK02PLpPnjEqbsgj1Co";
string newEncoding = UrlSafeEncoder.EncodeBytesUrlSafe(bytes);
Assert.AreEqual(knownEncoding, newEncoding);
Assert.That(newEncoding, Is.EqualTo(knownEncoding));
}

[Test]
public void Signature_Decoding_Is_Consistent()
{
string encoding = "i2-gExPOUa_AnmEPgZJQ2lAXeK02PLpPnjEqbsgj1Co";
byte[] knownBytes = new byte[]
{
const string encoding = "i2-gExPOUa_AnmEPgZJQ2lAXeK02PLpPnjEqbsgj1Co";
byte[] knownBytes =
[
0x8b, 0x6f, 0xa0, 0x13, 0x13, 0xce, 0x51, 0xaf,
0xc0, 0x9e, 0x61, 0x0f, 0x81, 0x92, 0x50, 0xda,
0x50, 0x17, 0x78, 0xad, 0x36, 0x3c, 0xba, 0x4f,
0x9e, 0x31, 0x2a, 0x6e, 0xc8, 0x23, 0xd4, 0x2a
};
];
byte[] newSignature = UrlSafeEncoder.DecodeBytesFromUrlSafe(encoding);
Assert.AreEqual(knownBytes, newSignature);
Assert.That(newSignature, Is.EqualTo(knownBytes));
}
}
33 changes: 16 additions & 17 deletions Crypter.Test/Common_Tests/Primitive_Tests/Base64String_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,9 @@ public class Base64String_Tests
public void Null_Value_Is_Invalid(string value)
{
Assert.Throws<ValueNullException>(() => Base64String.From(value));

bool shouldBeFalse = Base64String.TryFrom(value, out var shouldBeNull);
Assert.IsFalse(shouldBeFalse);
Assert.IsNull(shouldBeNull);
bool shouldBeFalse = Base64String.TryFrom(value, out Base64String shouldBeNull);
Assert.That(shouldBeFalse, Is.False);
Assert.That(shouldBeNull, Is.Null);
}

[TestCase("")]
Expand All @@ -51,9 +50,9 @@ public void Empty_Values_Are_Invalid(string value)
{
Assert.Throws<ValueEmptyException>(() => Base64String.From(value));

bool shouldBeFalse = Base64String.TryFrom(value, out var shouldBeNull);
Assert.IsFalse(shouldBeFalse);
Assert.IsNull(shouldBeNull);
bool shouldBeFalse = Base64String.TryFrom(value, out Base64String shouldBeNull);
Assert.That(shouldBeFalse, Is.False);
Assert.That(shouldBeNull, Is.Null);
}

[TestCase("jellyfish")]
Expand All @@ -63,9 +62,9 @@ public void Invalid_Base64_Strings_Are_Invalid(string value)
{
Assert.Throws<ValueInvalidException>(() => Base64String.From(value));

bool shouldBeFalse = Base64String.TryFrom(value, out var shouldBeNull);
Assert.IsFalse(shouldBeFalse);
Assert.IsNull(shouldBeNull);
bool shouldBeFalse = Base64String.TryFrom(value, out Base64String shouldBeNull);
Assert.That(shouldBeFalse, Is.False);
Assert.That(shouldBeNull, Is.Null);
}

[TestCase("amVsbHlmaXNo")]
Expand All @@ -74,13 +73,13 @@ public void Invalid_Base64_Strings_Are_Invalid(string value)
public void Valid_Base64_Strings_Are_Valid(string value)
{
Assert.DoesNotThrow(() => Base64String.From(value));
var validBase64 = Base64String.From(value);
Assert.IsNotNull(validBase64);
Assert.AreEqual(value, validBase64.Value);
Base64String validBase64 = Base64String.From(value);
Assert.That(validBase64, Is.Not.Null);
Assert.That(validBase64.Value, Is.EqualTo(value));

bool shouldBeTrue = Base64String.TryFrom(value, out var newValidBase64);
Assert.IsTrue(shouldBeTrue);
Assert.IsNotNull(newValidBase64);
Assert.AreEqual(value, newValidBase64.Value);
bool shouldBeTrue = Base64String.TryFrom(value, out Base64String newValidBase64);
Assert.That(shouldBeTrue, Is.True);
Assert.That(newValidBase64, Is.Not.Null);
Assert.That(newValidBase64.Value, Is.EqualTo(value));
}
}
Loading
Loading