From 275a9ba629ade6561c05c896b84306ce54345dba Mon Sep 17 00:00:00 2001 From: Johnny Brenes Date: Wed, 27 Mar 2024 09:03:53 -0600 Subject: [PATCH 01/17] net 8 Migration projects --- .../EdFi.Ods.AdminApi.DBTests.csproj | 68 +++++++++---------- .../EdFi.Ods.AdminApi.UnitTests.csproj | 8 +-- .../EdFi.Ods.AdminApi.csproj | 17 ++--- 3 files changed, 39 insertions(+), 54 deletions(-) diff --git a/Application/EdFi.Ods.AdminApi.DBTests/EdFi.Ods.AdminApi.DBTests.csproj b/Application/EdFi.Ods.AdminApi.DBTests/EdFi.Ods.AdminApi.DBTests.csproj index 17f748ea6..264afa554 100644 --- a/Application/EdFi.Ods.AdminApi.DBTests/EdFi.Ods.AdminApi.DBTests.csproj +++ b/Application/EdFi.Ods.AdminApi.DBTests/EdFi.Ods.AdminApi.DBTests.csproj @@ -1,38 +1,32 @@ - - - net6.0 - - - - - - - - - - - - - - - - - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - - Always - - - + + net8.0 + + + + + + + + + + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + Always + + + \ No newline at end of file diff --git a/Application/EdFi.Ods.AdminApi.UnitTests/EdFi.Ods.AdminApi.UnitTests.csproj b/Application/EdFi.Ods.AdminApi.UnitTests/EdFi.Ods.AdminApi.UnitTests.csproj index d43feb191..15c224cc2 100644 --- a/Application/EdFi.Ods.AdminApi.UnitTests/EdFi.Ods.AdminApi.UnitTests.csproj +++ b/Application/EdFi.Ods.AdminApi.UnitTests/EdFi.Ods.AdminApi.UnitTests.csproj @@ -1,11 +1,9 @@ - - net6.0 + net8.0 Debug;Release Copyright © 2023 Ed-Fi Alliance - @@ -20,9 +18,7 @@ - - - + \ No newline at end of file diff --git a/Application/EdFi.Ods.AdminApi/EdFi.Ods.AdminApi.csproj b/Application/EdFi.Ods.AdminApi/EdFi.Ods.AdminApi.csproj index af26b9894..dfba25536 100644 --- a/Application/EdFi.Ods.AdminApi/EdFi.Ods.AdminApi.csproj +++ b/Application/EdFi.Ods.AdminApi/EdFi.Ods.AdminApi.csproj @@ -1,7 +1,6 @@ - - net6.0 + net8.0 enable enable true @@ -13,13 +12,11 @@ .env adminapi-dev - - @@ -35,12 +32,7 @@ - - - - - @@ -48,6 +40,9 @@ + + + + - - + \ No newline at end of file From 81e472362615f2f1161d705f948c715d0c415090 Mon Sep 17 00:00:00 2001 From: Johnny Brenes Date: Wed, 27 Mar 2024 09:31:07 -0600 Subject: [PATCH 02/17] Update Edfi packages --- .../EdFi.Ods.AdminApi.DBTests.csproj | 6 +++--- .../EdFi.Ods.AdminApi.UnitTests.csproj | 4 ++-- Application/EdFi.Ods.AdminApi/EdFi.Ods.AdminApi.csproj | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Application/EdFi.Ods.AdminApi.DBTests/EdFi.Ods.AdminApi.DBTests.csproj b/Application/EdFi.Ods.AdminApi.DBTests/EdFi.Ods.AdminApi.DBTests.csproj index 264afa554..30e5024e4 100644 --- a/Application/EdFi.Ods.AdminApi.DBTests/EdFi.Ods.AdminApi.DBTests.csproj +++ b/Application/EdFi.Ods.AdminApi.DBTests/EdFi.Ods.AdminApi.DBTests.csproj @@ -7,9 +7,9 @@ - - - + + + diff --git a/Application/EdFi.Ods.AdminApi.UnitTests/EdFi.Ods.AdminApi.UnitTests.csproj b/Application/EdFi.Ods.AdminApi.UnitTests/EdFi.Ods.AdminApi.UnitTests.csproj index 15c224cc2..9d6c4657d 100644 --- a/Application/EdFi.Ods.AdminApi.UnitTests/EdFi.Ods.AdminApi.UnitTests.csproj +++ b/Application/EdFi.Ods.AdminApi.UnitTests/EdFi.Ods.AdminApi.UnitTests.csproj @@ -6,8 +6,8 @@ - - + + diff --git a/Application/EdFi.Ods.AdminApi/EdFi.Ods.AdminApi.csproj b/Application/EdFi.Ods.AdminApi/EdFi.Ods.AdminApi.csproj index dfba25536..8281d8e30 100644 --- a/Application/EdFi.Ods.AdminApi/EdFi.Ods.AdminApi.csproj +++ b/Application/EdFi.Ods.AdminApi/EdFi.Ods.AdminApi.csproj @@ -27,8 +27,8 @@ - - + + From 413d626eb3c4c6068f3483857c3d7c41c9442d49 Mon Sep 17 00:00:00 2001 From: Johnny Brenes Date: Wed, 27 Mar 2024 13:32:25 -0600 Subject: [PATCH 03/17] updating other packages and make build works --- .github/workflows/on-prerelease.yml | 5 - .github/workflows/on-pullrequest.yml | 4 - .../EdFi.Ods.AdminApi.DBTests.csproj | 1 - .../MockExtensions.cs | 57 --------- .../TestDbAsyncEnumerator.cs | 111 ------------------ .../EdFi.Ods.AdminApi.csproj | 7 +- .../EdFi.Ods.AdminApi/appsettings.json | 12 +- 7 files changed, 10 insertions(+), 187 deletions(-) delete mode 100644 Application/EdFi.Ods.AdminApi.DBTests/MockExtensions.cs delete mode 100644 Application/EdFi.Ods.AdminApi.DBTests/TestDbAsyncEnumerator.cs diff --git a/.github/workflows/on-prerelease.yml b/.github/workflows/on-prerelease.yml index 9626b3b07..f417bc64f 100644 --- a/.github/workflows/on-prerelease.yml +++ b/.github/workflows/on-prerelease.yml @@ -53,11 +53,6 @@ jobs: # SemVer "admin-api-semver=$($apiVersion -Replace $apiPrefix)" >> $env:GITHUB_OUTPUT - - name: Setup .NET - uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a # v3.0.3 - with: - dotnet-version: 6.0.x - - name: Publish .NET Assemblies run: | $apiVersion = "${{ steps.versions.outputs.admin-api-semver }}" diff --git a/.github/workflows/on-pullrequest.yml b/.github/workflows/on-pullrequest.yml index 33c66d126..57df65431 100644 --- a/.github/workflows/on-pullrequest.yml +++ b/.github/workflows/on-pullrequest.yml @@ -41,10 +41,6 @@ jobs: steps: - name: Checkout the Repo uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - - name: Setup .NET - uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a # v3.0.3 - with: - dotnet-version: 6.0.x - name: Build run: ./build.ps1 -Command Build -Configuration Debug diff --git a/Application/EdFi.Ods.AdminApi.DBTests/EdFi.Ods.AdminApi.DBTests.csproj b/Application/EdFi.Ods.AdminApi.DBTests/EdFi.Ods.AdminApi.DBTests.csproj index 30e5024e4..0682be199 100644 --- a/Application/EdFi.Ods.AdminApi.DBTests/EdFi.Ods.AdminApi.DBTests.csproj +++ b/Application/EdFi.Ods.AdminApi.DBTests/EdFi.Ods.AdminApi.DBTests.csproj @@ -10,7 +10,6 @@ - diff --git a/Application/EdFi.Ods.AdminApi.DBTests/MockExtensions.cs b/Application/EdFi.Ods.AdminApi.DBTests/MockExtensions.cs deleted file mode 100644 index 405dbe394..000000000 --- a/Application/EdFi.Ods.AdminApi.DBTests/MockExtensions.cs +++ /dev/null @@ -1,57 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -// Licensed to the Ed-Fi Alliance under one or more agreements. -// The Ed-Fi Alliance licenses this file to you under the Apache License, Version 2.0. -// See the LICENSE and NOTICES files in the project root for more information. - -using System; -using System.Collections.Generic; -using System.Data.Entity; -using System.Data.Entity.Infrastructure; -using System.Linq; -using Moq; - -namespace EdFi.Ods.AdminApi.DBTests -{ - public static class MockExtensions - { - public static Mock> MockDbSet(List underlyingData) where T : class - { - var mockSet = new Mock>(); - mockSet.ConfigureDbSetWithData(underlyingData); - - return mockSet; - } - - public static Mock> EmptyMockDbSet() where T : class - { - var mockSet = new Mock>(); - var underlyingData = new List(); - - ConfigureDbSetWithData(mockSet, underlyingData); - - return mockSet; - } - - public static Mock> ConfigureDbSetWithData(this Mock> mockSet, List underlyingData) where T : class - { - mockSet.As>() - .Setup(m => m.GetAsyncEnumerator()) - .Returns(() => new TestDbAsyncEnumerator(underlyingData.GetEnumerator())); - - mockSet.As>() - .Setup(m => m.Provider) - .Returns(() => new TestDbAsyncQueryProvider(underlyingData.AsQueryable().Provider)); - - mockSet.As>().Setup(m => m.Expression).Returns(() => underlyingData.AsQueryable().Expression); - mockSet.As>().Setup(m => m.ElementType).Returns(() => underlyingData.AsQueryable().ElementType); - mockSet.As>().Setup(m => m.GetEnumerator()).Returns(() => underlyingData.AsQueryable().GetEnumerator()); - - mockSet.Setup(m => m.Add(It.IsAny())).Callback((T x) => underlyingData.Add(x)); - mockSet.Setup(m => m.AddRange(It.IsAny>())).Callback((IEnumerable x) => underlyingData.AddRange(x)); - mockSet.Setup(m => m.Remove(It.IsAny())).Callback((T x) => underlyingData.Remove(x)); - mockSet.Setup(m => m.RemoveRange(It.IsAny>())).Callback((IEnumerable x) => underlyingData.RemoveAll(x.Contains)); - - return mockSet; - } - } -} diff --git a/Application/EdFi.Ods.AdminApi.DBTests/TestDbAsyncEnumerator.cs b/Application/EdFi.Ods.AdminApi.DBTests/TestDbAsyncEnumerator.cs deleted file mode 100644 index 3853e6499..000000000 --- a/Application/EdFi.Ods.AdminApi.DBTests/TestDbAsyncEnumerator.cs +++ /dev/null @@ -1,111 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -// Licensed to the Ed-Fi Alliance under one or more agreements. -// The Ed-Fi Alliance licenses this file to you under the Apache License, Version 2.0. -// See the LICENSE and NOTICES files in the project root for more information. - -using System.Collections.Generic; -using System.Data.Entity.Infrastructure; -using System.Linq; -using System.Linq.Expressions; -using System.Threading; -using System.Threading.Tasks; - -namespace EdFi.Ods.AdminApi.DBTests; - -//Classes to assist with mocking a DBSet -- see https://msdn.microsoft.com/en-us/library/dn314429.aspx - -internal class TestDbAsyncQueryProvider : IDbAsyncQueryProvider -{ - private readonly IQueryProvider _inner; - - internal TestDbAsyncQueryProvider(IQueryProvider inner) - { - _inner = inner; - } - - public IQueryable CreateQuery(Expression expression) - { - return new TestDbAsyncEnumerable(expression); - } - - public IQueryable CreateQuery(Expression expression) - { - return new TestDbAsyncEnumerable(expression); - } - - public object Execute(Expression expression) - { - return _inner.Execute(expression); - } - - public TResult Execute(Expression expression) - { - return _inner.Execute(expression); - } - - public Task ExecuteAsync(Expression expression, CancellationToken cancellationToken) - { - return Task.FromResult(Execute(expression)); - } - - public Task ExecuteAsync(Expression expression, CancellationToken cancellationToken) - { - return Task.FromResult(Execute(expression)); - } -} - -internal class TestDbAsyncEnumerable : EnumerableQuery, IDbAsyncEnumerable, IQueryable -{ - public TestDbAsyncEnumerable(IEnumerable enumerable) - : base(enumerable) - { } - - public TestDbAsyncEnumerable(Expression expression) - : base(expression) - { } - - public IDbAsyncEnumerator GetAsyncEnumerator() - { - return new TestDbAsyncEnumerator(this.AsEnumerable().GetEnumerator()); - } - - IDbAsyncEnumerator IDbAsyncEnumerable.GetAsyncEnumerator() - { - return GetAsyncEnumerator(); - } - - IQueryProvider IQueryable.Provider - { - get { return new TestDbAsyncQueryProvider(this); } - } -} - -internal class TestDbAsyncEnumerator : IDbAsyncEnumerator -{ - private readonly IEnumerator _inner; - - public TestDbAsyncEnumerator(IEnumerator inner) - { - _inner = inner; - } - - public void Dispose() - { - _inner.Dispose(); - } - - public Task MoveNextAsync(CancellationToken cancellationToken) - { - return Task.FromResult(_inner.MoveNext()); - } - - public T Current - { - get { return _inner.Current; } - } - - object IDbAsyncEnumerator.Current - { - get { return Current; } - } -} diff --git a/Application/EdFi.Ods.AdminApi/EdFi.Ods.AdminApi.csproj b/Application/EdFi.Ods.AdminApi/EdFi.Ods.AdminApi.csproj index 8281d8e30..80714347a 100644 --- a/Application/EdFi.Ods.AdminApi/EdFi.Ods.AdminApi.csproj +++ b/Application/EdFi.Ods.AdminApi/EdFi.Ods.AdminApi.csproj @@ -18,7 +18,7 @@ - + @@ -34,8 +34,8 @@ - - + + @@ -43,6 +43,7 @@ + \ No newline at end of file diff --git a/Application/EdFi.Ods.AdminApi/appsettings.json b/Application/EdFi.Ods.AdminApi/appsettings.json index 03c4da066..a1017e423 100644 --- a/Application/EdFi.Ods.AdminApi/appsettings.json +++ b/Application/EdFi.Ods.AdminApi/appsettings.json @@ -7,9 +7,9 @@ "MultiTenancy": false }, "Authentication": { - "Authority": "", - "IssuerUrl": "", - "SigningKey": "", + "Authority": "https://desktop-orf770q/WebApi", + "IssuerUrl": "https://desktop-orf770q/WebApi", + "SigningKey": "YS1sb25nLXNhbXBsZQ==", "AllowRegistration": false }, "SwaggerSettings": { @@ -18,8 +18,8 @@ }, "EnableDockerEnvironment": false, "ConnectionStrings": { - "EdFi_Admin": "Data Source=.\\;Initial Catalog=EdFi_Admin;Integrated Security=True", - "EdFi_Security": "Data Source=.\\;Initial Catalog=EdFi_Security;Integrated Security=True" + "EdFi_Admin": "Data Source=.\\;Initial Catalog=EdFi_Admin;Integrated Security=True;Encrypt=False", + "EdFi_Security": "Data Source=.\\;Initial Catalog=EdFi_Security;Integrated Security=True;Encrypt=False" }, "Log4NetCore": { "Log4NetConfigFileName": "log4net\\log4net.config" @@ -46,7 +46,7 @@ { "Endpoint": "POST:/Connect/Register", "Period": "1m", - "Limit": 3 + "Limit": 1000 } ] } From d848ec0db675ce20c55666293f765b48d855fa83 Mon Sep 17 00:00:00 2001 From: Johnny Brenes Date: Wed, 27 Mar 2024 14:19:55 -0600 Subject: [PATCH 04/17] docker files --- .../EdFi.Ods.AdminApi/appsettings.Docker.json | 3 ++- Docker/Settings/DB-Admin/pgsql/Dockerfile | 11 +++++--- Docker/dbadmin.Dockerfile | 11 +++++--- Docker/dev.Dockerfile | 25 +++++++++++++------ 4 files changed, 36 insertions(+), 14 deletions(-) diff --git a/Application/EdFi.Ods.AdminApi/appsettings.Docker.json b/Application/EdFi.Ods.AdminApi/appsettings.Docker.json index 3b6e7859a..531df2eb8 100644 --- a/Application/EdFi.Ods.AdminApi/appsettings.Docker.json +++ b/Application/EdFi.Ods.AdminApi/appsettings.Docker.json @@ -28,7 +28,8 @@ "LogLevel": { "Default": "Information", "Microsoft": "Warning", - "Microsoft.Hosting.Lifetime": "Information" + "Microsoft.Hosting.Lifetime": "Information", + "Microsoft.AspNetCore.DataProtection": "Information" } }, "AllowedHosts": "*" diff --git a/Docker/Settings/DB-Admin/pgsql/Dockerfile b/Docker/Settings/DB-Admin/pgsql/Dockerfile index 4b53a0a0d..20fdc762f 100644 --- a/Docker/Settings/DB-Admin/pgsql/Dockerfile +++ b/Docker/Settings/DB-Admin/pgsql/Dockerfile @@ -12,17 +12,22 @@ ENV POSTGRES_DB=postgres ARG VERSION=latest +USER root + +RUN apk --no-cache add dos2unix=~7 unzip=~6 + +FROM base as setup + COPY run-adminapi-migrations.sh /docker-entrypoint-initdb.d/3-run-adminapi-migrations.sh USER root -RUN apk --no-cache add dos2unix=~7.4 unzip=~6.0 && \ - wget -nv -O /tmp/EdFi_AdminApi_Scripts.zip https://pkgs.dev.azure.com/ed-fi-alliance/Ed-Fi-Alliance-OSS/_apis/packaging/feeds/EdFi/nuget/packages/EdFi.Suite3.ODS.AdminApi/versions/${VERSION}/content && \ +RUN wget -nv -O /tmp/EdFi_AdminApi_Scripts.zip https://pkgs.dev.azure.com/ed-fi-alliance/Ed-Fi-Alliance-OSS/_apis/packaging/feeds/EdFi/nuget/packages/EdFi.Suite3.ODS.AdminApi/versions/${VERSION}/content && \ unzip /tmp/EdFi_AdminApi_Scripts.zip AdminApi/Artifacts/PgSql/Structure/Admin/* -d /tmp/AdminApiScripts/ && \ cp -r /tmp/AdminApiScripts/AdminApi/Artifacts/PgSql/Structure/Admin/. /tmp/AdminApiScripts/PgSql/ && \ rm -f /tmp/EdFi_AdminApi_Scripts.zip && \ rm -r /tmp/AdminApiScripts/AdminApi && \ dos2unix /docker-entrypoint-initdb.d/3-run-adminapi-migrations.sh && \ dos2unix /tmp/AdminApiScripts/PgSql/* && \ - chmod -R 777 /tmp/AdminApiScripts/PgSql + chmod -R 600 /tmp/AdminApiScripts/PgSql EXPOSE 5432 USER postgres diff --git a/Docker/dbadmin.Dockerfile b/Docker/dbadmin.Dockerfile index 1d39a4183..809e76ba4 100644 --- a/Docker/dbadmin.Dockerfile +++ b/Docker/dbadmin.Dockerfile @@ -10,15 +10,20 @@ ENV POSTGRES_USER=${POSTGRES_USER} ENV POSTGRES_PASSWORD=${POSTGRES_PASSWORD} ENV POSTGRES_DB=postgres +USER root + +RUN apk --no-cache add dos2unix=~7 unzip=~6 + +FROM base AS setup + COPY Settings/DB-Admin/pgsql/run-adminapi-migrations.sh /docker-entrypoint-initdb.d/3-run-adminapi-migrations.sh COPY Application/EdFi.Ods.AdminApi/Artifacts/PgSql/Structure/Admin/ /tmp/AdminApiScripts/PgSql COPY Settings/dev/adminapi-test-seeddata.sql /tmp/AdminApiScripts/PgSql/adminapi-test-seeddata.sql USER root -RUN apk --no-cache add dos2unix=~7.4 unzip=~6.0 && \ - dos2unix /docker-entrypoint-initdb.d/3-run-adminapi-migrations.sh && \ +RUN dos2unix /docker-entrypoint-initdb.d/3-run-adminapi-migrations.sh && \ dos2unix /tmp/AdminApiScripts/PgSql/* && \ - chmod -R 777 /tmp/AdminApiScripts/PgSql/* + chmod -R 600 /tmp/AdminApiScripts/PgSql/* EXPOSE 5432 USER postgres diff --git a/Docker/dev.Dockerfile b/Docker/dev.Dockerfile index fd6a0acaf..17960cc7c 100644 --- a/Docker/dev.Dockerfile +++ b/Docker/dev.Dockerfile @@ -8,7 +8,7 @@ #tag sdk:6.0-alpine -FROM mcr.microsoft.com/dotnet/sdk@sha256:c1a73b72c02e7b837e9a93030d545bc4181193e1bab1033364ed2d00986d78ff AS build +FROM mcr.microsoft.com/dotnet/sdk:8.0.202-alpine3.19-amd64@sha256:4baa826eb916ba267b246c3f7f55e9e076121b0037dab78f7ae75ba70149805c AS build WORKDIR /source COPY Application/NuGet.Config EdFi.Ods.AdminApi/ @@ -21,27 +21,38 @@ FROM build AS publish RUN dotnet publish -c Release /p:EnvironmentName=Production --no-build -o /app/EdFi.Ods.AdminApi #tag aspnet:6.0-alpine -FROM mcr.microsoft.com/dotnet/aspnet@sha256:201cedd60cb295b2ebea7184561a45c5c0ee337e37300ea0f25cff5a2c762538 +FROM mcr.microsoft.com/dotnet/aspnet:8.0.3-alpine3.19-amd64@sha256:a531d9d123928514405b9da9ff28a3aa81bd6f7d7d8cfb6207b66c007e7b3075 as base +RUN apk --no-cache add curl=~8 dos2unix=~7 bash=~5 gettext=~0 icu=~74 && \ + addgroup -S edfi && adduser -S edfi -G edfi + +FROM base AS setup + LABEL maintainer="Ed-Fi Alliance, LLC and Contributors " # Alpine image does not contain Globalization Cultures library so we need to install ICU library to get for LINQ expression to work # Disable the globaliztion invariant mode (set in base image) ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false ENV ASPNETCORE_ENVIRONMENT Production +ENV ASPNETCORE_HTTP_PORTS=80 WORKDIR /app COPY --from=publish /app/EdFi.Ods.AdminApi . -COPY Settings/dev/run.sh /app/run.sh +COPY --chmod=500 Settings/dev/run.sh /app/run.sh COPY Settings/dev/log4net.config /app/log4net.txt -RUN apk --no-cache add curl=~8 dos2unix=~7 bash=~5 gettext=~0 icu=~72 && \ - cp /app/log4net.txt /app/log4net.config && \ +RUN cp /app/log4net.txt /app/log4net.config && \ dos2unix /app/*.json && \ dos2unix /app/*.sh && \ dos2unix /app/log4net.config && \ - chmod 700 /app/*.sh -- ** + chmod 500 /app/*.sh -- ** && \ + rm -f /app/log4net.txt && \ + rm -f /app/*.exe && \ + apk del dos2unix && \ + chown -R edfi /app + +EXPOSE ${ASPNETCORE_HTTP_PORTS} +USER edfi -EXPOSE 443 WORKDIR /app ENTRYPOINT ["/app/run.sh"] From 079bb5cb4b05ba3431606d9bdfc9bf38c3de83fe Mon Sep 17 00:00:00 2001 From: Johnny Brenes Date: Wed, 27 Mar 2024 15:23:20 -0600 Subject: [PATCH 05/17] clean appsettings values --- Application/EdFi.Ods.AdminApi/appsettings.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Application/EdFi.Ods.AdminApi/appsettings.json b/Application/EdFi.Ods.AdminApi/appsettings.json index a1017e423..d1ebcd3e2 100644 --- a/Application/EdFi.Ods.AdminApi/appsettings.json +++ b/Application/EdFi.Ods.AdminApi/appsettings.json @@ -7,9 +7,9 @@ "MultiTenancy": false }, "Authentication": { - "Authority": "https://desktop-orf770q/WebApi", - "IssuerUrl": "https://desktop-orf770q/WebApi", - "SigningKey": "YS1sb25nLXNhbXBsZQ==", + "Authority": "", + "IssuerUrl": "", + "SigningKey": "", "AllowRegistration": false }, "SwaggerSettings": { From ada562cf90124ffe98997cf45f6e0b42ee2cc2dd Mon Sep 17 00:00:00 2001 From: Johnny Brenes Date: Thu, 28 Mar 2024 08:05:46 -0600 Subject: [PATCH 06/17] dbadmin dockerfile --- Docker/api.Dockerfile | 4 ++-- Docker/dbadmin.Dockerfile | 14 ++++++-------- Docker/dev.Dockerfile | 4 ++-- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/Docker/api.Dockerfile b/Docker/api.Dockerfile index 5c147137e..0e83b0eb4 100644 --- a/Docker/api.Dockerfile +++ b/Docker/api.Dockerfile @@ -3,8 +3,8 @@ # The Ed-Fi Alliance licenses this file to you under the Apache License, Version 2.0. # See the LICENSE and NOTICES files in the project root for more information. -#tag 6.0-alpine -FROM mcr.microsoft.com/dotnet/aspnet@sha256:201cedd60cb295b2ebea7184561a45c5c0ee337e37300ea0f25cff5a2c762538 +#tag 8.0-alpine +FROM mcr.microsoft.com/dotnet/aspnet:8.0.3-alpine3.19-amd64@sha256:a531d9d123928514405b9da9ff28a3aa81bd6f7d7d8cfb6207b66c007e7b3075 as base LABEL maintainer="Ed-Fi Alliance, LLC and Contributors " ARG VERSION=latest ARG DB=pgsql diff --git a/Docker/dbadmin.Dockerfile b/Docker/dbadmin.Dockerfile index 809e76ba4..12685f85a 100644 --- a/Docker/dbadmin.Dockerfile +++ b/Docker/dbadmin.Dockerfile @@ -5,26 +5,24 @@ FROM edfialliance/ods-api-db-admin:7.1 LABEL maintainer="Ed-Fi Alliance, LLC and Contributors " - ENV POSTGRES_USER=${POSTGRES_USER} ENV POSTGRES_PASSWORD=${POSTGRES_PASSWORD} ENV POSTGRES_DB=postgres USER root - -RUN apk --no-cache add dos2unix=~7 unzip=~6 - -FROM base AS setup - COPY Settings/DB-Admin/pgsql/run-adminapi-migrations.sh /docker-entrypoint-initdb.d/3-run-adminapi-migrations.sh COPY Application/EdFi.Ods.AdminApi/Artifacts/PgSql/Structure/Admin/ /tmp/AdminApiScripts/PgSql COPY Settings/dev/adminapi-test-seeddata.sql /tmp/AdminApiScripts/PgSql/adminapi-test-seeddata.sql +RUN apk --no-cache add dos2unix=~7.4 unzip=~6.0 +USER postgres + USER root RUN dos2unix /docker-entrypoint-initdb.d/3-run-adminapi-migrations.sh && \ dos2unix /tmp/AdminApiScripts/PgSql/* && \ - chmod -R 600 /tmp/AdminApiScripts/PgSql/* + chmod -R 777 /tmp/AdminApiScripts/PgSql/* +USER postgres EXPOSE 5432 -USER postgres + CMD ["docker-entrypoint.sh", "postgres"] diff --git a/Docker/dev.Dockerfile b/Docker/dev.Dockerfile index 17960cc7c..358431760 100644 --- a/Docker/dev.Dockerfile +++ b/Docker/dev.Dockerfile @@ -7,7 +7,7 @@ # Second layer uses the dotnet/aspnet image to run the built code -#tag sdk:6.0-alpine +#tag sdk:8.0-alpine FROM mcr.microsoft.com/dotnet/sdk:8.0.202-alpine3.19-amd64@sha256:4baa826eb916ba267b246c3f7f55e9e076121b0037dab78f7ae75ba70149805c AS build WORKDIR /source @@ -20,7 +20,7 @@ RUN dotnet restore && dotnet build -c Release FROM build AS publish RUN dotnet publish -c Release /p:EnvironmentName=Production --no-build -o /app/EdFi.Ods.AdminApi -#tag aspnet:6.0-alpine +#tag aspnet:8.0-alpine FROM mcr.microsoft.com/dotnet/aspnet:8.0.3-alpine3.19-amd64@sha256:a531d9d123928514405b9da9ff28a3aa81bd6f7d7d8cfb6207b66c007e7b3075 as base RUN apk --no-cache add curl=~8 dos2unix=~7 bash=~5 gettext=~0 icu=~74 && \ addgroup -S edfi && adduser -S edfi -G edfi From e97bc8faee1f14945940ee044fdfcd40359292e1 Mon Sep 17 00:00:00 2001 From: Johnny Brenes Date: Thu, 28 Mar 2024 12:29:30 -0600 Subject: [PATCH 07/17] Validation of empty results in test --- .../Admin API E2E 2.0 - Actions.postman_collection.json | 8 +++++--- ...n API E2E 2.0 - AuthStrategies.postman_collection.json | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Application/EdFi.Ods.AdminApi/E2E Tests/Admin API E2E 2.0 - Actions.postman_collection.json b/Application/EdFi.Ods.AdminApi/E2E Tests/Admin API E2E 2.0 - Actions.postman_collection.json index bdbabb6f4..ce0bbc342 100644 --- a/Application/EdFi.Ods.AdminApi/E2E Tests/Admin API E2E 2.0 - Actions.postman_collection.json +++ b/Application/EdFi.Ods.AdminApi/E2E Tests/Admin API E2E 2.0 - Actions.postman_collection.json @@ -26,9 +26,11 @@ "const response = pm.response.json();\r", "\r", "pm.test(\"GET Actions: Response matches success format\", function () {\r", - " pm.expect(response[0]).to.have.property(\"id\");\r", - " pm.expect(response[0]).to.have.property(\"name\");\r", - " pm.expect(response[0]).to.have.property(\"uri\");\r", + " if (response && response.length > 0) {\r", + " pm.expect(response[0]).to.have.property(\"id\");\r", + " pm.expect(response[0]).to.have.property(\"name\");\r", + " pm.expect(response[0]).to.have.property(\"uri\");\r", + " }\r", "});\r", "\r", "const GetActionsSchema = {\r", diff --git a/Application/EdFi.Ods.AdminApi/E2E Tests/Admin API E2E 2.0 - AuthStrategies.postman_collection.json b/Application/EdFi.Ods.AdminApi/E2E Tests/Admin API E2E 2.0 - AuthStrategies.postman_collection.json index 750f874ff..3526862d9 100644 --- a/Application/EdFi.Ods.AdminApi/E2E Tests/Admin API E2E 2.0 - AuthStrategies.postman_collection.json +++ b/Application/EdFi.Ods.AdminApi/E2E Tests/Admin API E2E 2.0 - AuthStrategies.postman_collection.json @@ -26,9 +26,11 @@ "const response = pm.response.json();\r", "\r", "pm.test(\"GET AuthorizationStrategies: Response matches success format\", function () {\r", - " pm.expect(response[0]).to.have.property(\"id\");\r", - " pm.expect(response[0]).to.have.property(\"name\");\r", - " pm.expect(response[0]).to.have.property(\"displayName\");\r", + " if (response && response.length > 0) {\r", + " pm.expect(response[0]).to.have.property(\"id\");\r", + " pm.expect(response[0]).to.have.property(\"name\");\r", + " pm.expect(response[0]).to.have.property(\"displayName\");\r", + " }\r", "});\r", "\r", "const GetAuthStrategiesSchema = {\r", From 45d22b64cd9574ebb981d255e7d2da8a513f7653 Mon Sep 17 00:00:00 2001 From: Johnny Brenes Date: Thu, 28 Mar 2024 15:30:39 -0600 Subject: [PATCH 08/17] comparing against 980 ticket --- .../ClaimSets/ResourceClaims/EditAuthStrategy.cs | 2 +- .../Features/RequestLoggingMiddleware.cs | 6 ++++-- .../ClaimSetEditor/AuthStrategyResolver.cs | 2 +- Docker/Settings/DB-Admin/pgsql/Dockerfile | 15 ++++++++------- Docker/Settings/ssl/generate-certificate.sh | 4 ++-- Docker/api.Dockerfile | 2 +- 6 files changed, 17 insertions(+), 14 deletions(-) diff --git a/Application/EdFi.Ods.AdminApi/Features/ClaimSets/ResourceClaims/EditAuthStrategy.cs b/Application/EdFi.Ods.AdminApi/Features/ClaimSets/ResourceClaims/EditAuthStrategy.cs index 3b20e4058..0315afb4d 100644 --- a/Application/EdFi.Ods.AdminApi/Features/ClaimSets/ResourceClaims/EditAuthStrategy.cs +++ b/Application/EdFi.Ods.AdminApi/Features/ClaimSets/ResourceClaims/EditAuthStrategy.cs @@ -109,7 +109,7 @@ public OverrideAuthStategyOnClaimSetValidator(IGetResourcesByClaimSetIdQuery get var authStrategies = getAllAuthorizationStrategiesQuery.Execute(); foreach (var authStrategyName in overrideAuthStategyOnClaimSetRequest.AuthorizationStrategies!) { - var validAuthStrategyName = authStrategies + var validAuthStrategyName = authStrategies.AsEnumerable() .FirstOrDefault(a => a.AuthStrategyName!.ToLower() == authStrategyName!.ToLower()); if (validAuthStrategyName == null) diff --git a/Application/EdFi.Ods.AdminApi/Features/RequestLoggingMiddleware.cs b/Application/EdFi.Ods.AdminApi/Features/RequestLoggingMiddleware.cs index 9e6a7dd87..354e09dd4 100644 --- a/Application/EdFi.Ods.AdminApi/Features/RequestLoggingMiddleware.cs +++ b/Application/EdFi.Ods.AdminApi/Features/RequestLoggingMiddleware.cs @@ -45,7 +45,8 @@ public async Task Invoke(HttpContext context, ILogger case ValidationException validationException: var validationResponse = new { - title = "Validation failed", + title = "Validation failed", + status = (int)HttpStatusCode.BadRequest, errors = new Dictionary>() }; @@ -67,7 +68,8 @@ public async Task Invoke(HttpContext context, ILogger case INotFoundException notFoundException: var notFoundResponse = new { - title = notFoundException.Message, + title = notFoundException.Message, + status = (int)HttpStatusCode.NotFound }; logger.LogDebug(JsonSerializer.Serialize(new { message = notFoundResponse, traceId = context.TraceIdentifier })); diff --git a/Application/EdFi.Ods.AdminApi/Infrastructure/Services/ClaimSetEditor/AuthStrategyResolver.cs b/Application/EdFi.Ods.AdminApi/Infrastructure/Services/ClaimSetEditor/AuthStrategyResolver.cs index 831e591fb..bb66b981b 100644 --- a/Application/EdFi.Ods.AdminApi/Infrastructure/Services/ClaimSetEditor/AuthStrategyResolver.cs +++ b/Application/EdFi.Ods.AdminApi/Infrastructure/Services/ClaimSetEditor/AuthStrategyResolver.cs @@ -36,7 +36,7 @@ public IEnumerable ResolveAuthStrategies(IEnumerable x.AuthorizationStrategyName.Equals( strategy.AuthStrategyName, StringComparison.InvariantCultureIgnoreCase)); diff --git a/Docker/Settings/DB-Admin/pgsql/Dockerfile b/Docker/Settings/DB-Admin/pgsql/Dockerfile index 20fdc762f..fa57dd4fe 100644 --- a/Docker/Settings/DB-Admin/pgsql/Dockerfile +++ b/Docker/Settings/DB-Admin/pgsql/Dockerfile @@ -3,7 +3,7 @@ # The Ed-Fi Alliance licenses this file to you under the Apache License, Version 2.0. # See the LICENSE and NOTICES files in the project root for more information. -FROM edfialliance/ods-api-db-admin:7.1 +FROM edfialliance/ods-api-db-admin:7.1 as base LABEL maintainer="Ed-Fi Alliance, LLC and Contributors " ENV POSTGRES_USER=${POSTGRES_USER} @@ -13,22 +13,23 @@ ENV POSTGRES_DB=postgres ARG VERSION=latest USER root - -RUN apk --no-cache add dos2unix=~7 unzip=~6 +COPY run-adminapi-migrations.sh /docker-entrypoint-initdb.d/3-run-adminapi-migrations.sh +RUN apk --no-cache add dos2unix=~7.4 unzip=~6.0 +USER postgres FROM base as setup -COPY run-adminapi-migrations.sh /docker-entrypoint-initdb.d/3-run-adminapi-migrations.sh USER root -RUN wget -nv -O /tmp/EdFi_AdminApi_Scripts.zip https://pkgs.dev.azure.com/ed-fi-alliance/Ed-Fi-Alliance-OSS/_apis/packaging/feeds/EdFi/nuget/packages/EdFi.Suite3.ODS.AdminApi/versions/${VERSION}/content && \ +RUN wget -nv -O /tmp/EdFi_AdminApi_Scripts.zip "https://pkgs.dev.azure.com/ed-fi-alliance/Ed-Fi-Alliance-OSS/_apis/packaging/feeds/EdFi/nuget/packages/EdFi.Suite3.ODS.AdminApi/versions/${VERSION}/content" && \ unzip /tmp/EdFi_AdminApi_Scripts.zip AdminApi/Artifacts/PgSql/Structure/Admin/* -d /tmp/AdminApiScripts/ && \ cp -r /tmp/AdminApiScripts/AdminApi/Artifacts/PgSql/Structure/Admin/. /tmp/AdminApiScripts/PgSql/ && \ rm -f /tmp/EdFi_AdminApi_Scripts.zip && \ rm -r /tmp/AdminApiScripts/AdminApi && \ dos2unix /docker-entrypoint-initdb.d/3-run-adminapi-migrations.sh && \ dos2unix /tmp/AdminApiScripts/PgSql/* && \ - chmod -R 600 /tmp/AdminApiScripts/PgSql + chmod -R 777 /tmp/AdminApiScripts/PgSql +USER postgres EXPOSE 5432 -USER postgres + CMD ["docker-entrypoint.sh", "postgres"] diff --git a/Docker/Settings/ssl/generate-certificate.sh b/Docker/Settings/ssl/generate-certificate.sh index 21a90ad49..506405e9e 100644 --- a/Docker/Settings/ssl/generate-certificate.sh +++ b/Docker/Settings/ssl/generate-certificate.sh @@ -8,5 +8,5 @@ set -e set -x -openssl dhparam -out dhparam.pem 4096 -openssl req -subj '//CN=localhost' -x509 -newkey rsa:4096 -nodes -keyout server.key -out server.crt -days 365 -addext "subjectAltName = DNS:nginx" \ No newline at end of file +openssl dhparam -out dhparam.pem 2048 +openssl req -subj '/CN=localhost' -x509 -newkey rsa:2048 -nodes -keyout server.key -out server.crt -days 365 -addext "subjectAltName = DNS:nginx" diff --git a/Docker/api.Dockerfile b/Docker/api.Dockerfile index 0e83b0eb4..5f90fa896 100644 --- a/Docker/api.Dockerfile +++ b/Docker/api.Dockerfile @@ -21,7 +21,7 @@ COPY Settings/"${DB}"/log4net.config /app/log4net.txt RUN apk --no-cache add curl=~8 unzip=~6 dos2unix=~7 bash=~5 gettext=~0 jq=~1 icu=~72 && \ if [ "$DB" = "pgsql" ]; then apk --no-cache add postgresql13-client=~13; fi && \ - wget -nv -O /app/AdminApi.zip https://pkgs.dev.azure.com/ed-fi-alliance/Ed-Fi-Alliance-OSS/_apis/packaging/feeds/EdFi/nuget/packages/EdFi.Suite3.ODS.AdminApi/versions/${VERSION}/content && \ + wget -nv -O /app/AdminApi.zip "https://pkgs.dev.azure.com/ed-fi-alliance/Ed-Fi-Alliance-OSS/_apis/packaging/feeds/EdFi/nuget/packages/EdFi.Suite3.ODS.AdminApi/versions/${VERSION}/content" && \ unzip /app/AdminApi.zip AdminApi/* -d /app/ && \ cp -r /app/AdminApi/. /app/ && \ rm -f /app/AdminApi.zip && \ From 4e21d87c8f06a65295d07f323559dcd6b44971eb Mon Sep 17 00:00:00 2001 From: Johnny Brenes Date: Wed, 27 Mar 2024 09:03:53 -0600 Subject: [PATCH 09/17] net 8 Migration projects --- .../EdFi.Ods.AdminApi.DBTests.csproj | 68 +++++++++---------- .../EdFi.Ods.AdminApi.UnitTests.csproj | 8 +-- .../EdFi.Ods.AdminApi.csproj | 17 ++--- 3 files changed, 39 insertions(+), 54 deletions(-) diff --git a/Application/EdFi.Ods.AdminApi.DBTests/EdFi.Ods.AdminApi.DBTests.csproj b/Application/EdFi.Ods.AdminApi.DBTests/EdFi.Ods.AdminApi.DBTests.csproj index 17f748ea6..264afa554 100644 --- a/Application/EdFi.Ods.AdminApi.DBTests/EdFi.Ods.AdminApi.DBTests.csproj +++ b/Application/EdFi.Ods.AdminApi.DBTests/EdFi.Ods.AdminApi.DBTests.csproj @@ -1,38 +1,32 @@ - - - net6.0 - - - - - - - - - - - - - - - - - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - - Always - - - + + net8.0 + + + + + + + + + + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + Always + + + \ No newline at end of file diff --git a/Application/EdFi.Ods.AdminApi.UnitTests/EdFi.Ods.AdminApi.UnitTests.csproj b/Application/EdFi.Ods.AdminApi.UnitTests/EdFi.Ods.AdminApi.UnitTests.csproj index d43feb191..15c224cc2 100644 --- a/Application/EdFi.Ods.AdminApi.UnitTests/EdFi.Ods.AdminApi.UnitTests.csproj +++ b/Application/EdFi.Ods.AdminApi.UnitTests/EdFi.Ods.AdminApi.UnitTests.csproj @@ -1,11 +1,9 @@ - - net6.0 + net8.0 Debug;Release Copyright © 2023 Ed-Fi Alliance - @@ -20,9 +18,7 @@ - - - + \ No newline at end of file diff --git a/Application/EdFi.Ods.AdminApi/EdFi.Ods.AdminApi.csproj b/Application/EdFi.Ods.AdminApi/EdFi.Ods.AdminApi.csproj index af26b9894..dfba25536 100644 --- a/Application/EdFi.Ods.AdminApi/EdFi.Ods.AdminApi.csproj +++ b/Application/EdFi.Ods.AdminApi/EdFi.Ods.AdminApi.csproj @@ -1,7 +1,6 @@ - - net6.0 + net8.0 enable enable true @@ -13,13 +12,11 @@ .env adminapi-dev - - @@ -35,12 +32,7 @@ - - - - - @@ -48,6 +40,9 @@ + + + + - - + \ No newline at end of file From e97ad4f27f926b600ec21bf4c89b9c6d5bde2015 Mon Sep 17 00:00:00 2001 From: Johnny Brenes Date: Wed, 27 Mar 2024 09:31:07 -0600 Subject: [PATCH 10/17] Update Edfi packages --- .../EdFi.Ods.AdminApi.DBTests.csproj | 6 +++--- .../EdFi.Ods.AdminApi.UnitTests.csproj | 4 ++-- Application/EdFi.Ods.AdminApi/EdFi.Ods.AdminApi.csproj | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Application/EdFi.Ods.AdminApi.DBTests/EdFi.Ods.AdminApi.DBTests.csproj b/Application/EdFi.Ods.AdminApi.DBTests/EdFi.Ods.AdminApi.DBTests.csproj index 264afa554..30e5024e4 100644 --- a/Application/EdFi.Ods.AdminApi.DBTests/EdFi.Ods.AdminApi.DBTests.csproj +++ b/Application/EdFi.Ods.AdminApi.DBTests/EdFi.Ods.AdminApi.DBTests.csproj @@ -7,9 +7,9 @@ - - - + + + diff --git a/Application/EdFi.Ods.AdminApi.UnitTests/EdFi.Ods.AdminApi.UnitTests.csproj b/Application/EdFi.Ods.AdminApi.UnitTests/EdFi.Ods.AdminApi.UnitTests.csproj index 15c224cc2..9d6c4657d 100644 --- a/Application/EdFi.Ods.AdminApi.UnitTests/EdFi.Ods.AdminApi.UnitTests.csproj +++ b/Application/EdFi.Ods.AdminApi.UnitTests/EdFi.Ods.AdminApi.UnitTests.csproj @@ -6,8 +6,8 @@ - - + + diff --git a/Application/EdFi.Ods.AdminApi/EdFi.Ods.AdminApi.csproj b/Application/EdFi.Ods.AdminApi/EdFi.Ods.AdminApi.csproj index dfba25536..8281d8e30 100644 --- a/Application/EdFi.Ods.AdminApi/EdFi.Ods.AdminApi.csproj +++ b/Application/EdFi.Ods.AdminApi/EdFi.Ods.AdminApi.csproj @@ -27,8 +27,8 @@ - - + + From 9a590bf3fc098603ee32e94252284b8e193ae357 Mon Sep 17 00:00:00 2001 From: Johnny Brenes Date: Wed, 27 Mar 2024 13:32:25 -0600 Subject: [PATCH 11/17] updating other packages and make build works --- .github/workflows/on-prerelease.yml | 5 - .github/workflows/on-pullrequest.yml | 4 - .../EdFi.Ods.AdminApi.DBTests.csproj | 1 - .../MockExtensions.cs | 57 --------- .../TestDbAsyncEnumerator.cs | 111 ------------------ .../EdFi.Ods.AdminApi.csproj | 7 +- .../EdFi.Ods.AdminApi/appsettings.json | 12 +- 7 files changed, 10 insertions(+), 187 deletions(-) delete mode 100644 Application/EdFi.Ods.AdminApi.DBTests/MockExtensions.cs delete mode 100644 Application/EdFi.Ods.AdminApi.DBTests/TestDbAsyncEnumerator.cs diff --git a/.github/workflows/on-prerelease.yml b/.github/workflows/on-prerelease.yml index 9626b3b07..f417bc64f 100644 --- a/.github/workflows/on-prerelease.yml +++ b/.github/workflows/on-prerelease.yml @@ -53,11 +53,6 @@ jobs: # SemVer "admin-api-semver=$($apiVersion -Replace $apiPrefix)" >> $env:GITHUB_OUTPUT - - name: Setup .NET - uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a # v3.0.3 - with: - dotnet-version: 6.0.x - - name: Publish .NET Assemblies run: | $apiVersion = "${{ steps.versions.outputs.admin-api-semver }}" diff --git a/.github/workflows/on-pullrequest.yml b/.github/workflows/on-pullrequest.yml index 33c66d126..57df65431 100644 --- a/.github/workflows/on-pullrequest.yml +++ b/.github/workflows/on-pullrequest.yml @@ -41,10 +41,6 @@ jobs: steps: - name: Checkout the Repo uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - - name: Setup .NET - uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a # v3.0.3 - with: - dotnet-version: 6.0.x - name: Build run: ./build.ps1 -Command Build -Configuration Debug diff --git a/Application/EdFi.Ods.AdminApi.DBTests/EdFi.Ods.AdminApi.DBTests.csproj b/Application/EdFi.Ods.AdminApi.DBTests/EdFi.Ods.AdminApi.DBTests.csproj index 30e5024e4..0682be199 100644 --- a/Application/EdFi.Ods.AdminApi.DBTests/EdFi.Ods.AdminApi.DBTests.csproj +++ b/Application/EdFi.Ods.AdminApi.DBTests/EdFi.Ods.AdminApi.DBTests.csproj @@ -10,7 +10,6 @@ - diff --git a/Application/EdFi.Ods.AdminApi.DBTests/MockExtensions.cs b/Application/EdFi.Ods.AdminApi.DBTests/MockExtensions.cs deleted file mode 100644 index 405dbe394..000000000 --- a/Application/EdFi.Ods.AdminApi.DBTests/MockExtensions.cs +++ /dev/null @@ -1,57 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -// Licensed to the Ed-Fi Alliance under one or more agreements. -// The Ed-Fi Alliance licenses this file to you under the Apache License, Version 2.0. -// See the LICENSE and NOTICES files in the project root for more information. - -using System; -using System.Collections.Generic; -using System.Data.Entity; -using System.Data.Entity.Infrastructure; -using System.Linq; -using Moq; - -namespace EdFi.Ods.AdminApi.DBTests -{ - public static class MockExtensions - { - public static Mock> MockDbSet(List underlyingData) where T : class - { - var mockSet = new Mock>(); - mockSet.ConfigureDbSetWithData(underlyingData); - - return mockSet; - } - - public static Mock> EmptyMockDbSet() where T : class - { - var mockSet = new Mock>(); - var underlyingData = new List(); - - ConfigureDbSetWithData(mockSet, underlyingData); - - return mockSet; - } - - public static Mock> ConfigureDbSetWithData(this Mock> mockSet, List underlyingData) where T : class - { - mockSet.As>() - .Setup(m => m.GetAsyncEnumerator()) - .Returns(() => new TestDbAsyncEnumerator(underlyingData.GetEnumerator())); - - mockSet.As>() - .Setup(m => m.Provider) - .Returns(() => new TestDbAsyncQueryProvider(underlyingData.AsQueryable().Provider)); - - mockSet.As>().Setup(m => m.Expression).Returns(() => underlyingData.AsQueryable().Expression); - mockSet.As>().Setup(m => m.ElementType).Returns(() => underlyingData.AsQueryable().ElementType); - mockSet.As>().Setup(m => m.GetEnumerator()).Returns(() => underlyingData.AsQueryable().GetEnumerator()); - - mockSet.Setup(m => m.Add(It.IsAny())).Callback((T x) => underlyingData.Add(x)); - mockSet.Setup(m => m.AddRange(It.IsAny>())).Callback((IEnumerable x) => underlyingData.AddRange(x)); - mockSet.Setup(m => m.Remove(It.IsAny())).Callback((T x) => underlyingData.Remove(x)); - mockSet.Setup(m => m.RemoveRange(It.IsAny>())).Callback((IEnumerable x) => underlyingData.RemoveAll(x.Contains)); - - return mockSet; - } - } -} diff --git a/Application/EdFi.Ods.AdminApi.DBTests/TestDbAsyncEnumerator.cs b/Application/EdFi.Ods.AdminApi.DBTests/TestDbAsyncEnumerator.cs deleted file mode 100644 index 3853e6499..000000000 --- a/Application/EdFi.Ods.AdminApi.DBTests/TestDbAsyncEnumerator.cs +++ /dev/null @@ -1,111 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -// Licensed to the Ed-Fi Alliance under one or more agreements. -// The Ed-Fi Alliance licenses this file to you under the Apache License, Version 2.0. -// See the LICENSE and NOTICES files in the project root for more information. - -using System.Collections.Generic; -using System.Data.Entity.Infrastructure; -using System.Linq; -using System.Linq.Expressions; -using System.Threading; -using System.Threading.Tasks; - -namespace EdFi.Ods.AdminApi.DBTests; - -//Classes to assist with mocking a DBSet -- see https://msdn.microsoft.com/en-us/library/dn314429.aspx - -internal class TestDbAsyncQueryProvider : IDbAsyncQueryProvider -{ - private readonly IQueryProvider _inner; - - internal TestDbAsyncQueryProvider(IQueryProvider inner) - { - _inner = inner; - } - - public IQueryable CreateQuery(Expression expression) - { - return new TestDbAsyncEnumerable(expression); - } - - public IQueryable CreateQuery(Expression expression) - { - return new TestDbAsyncEnumerable(expression); - } - - public object Execute(Expression expression) - { - return _inner.Execute(expression); - } - - public TResult Execute(Expression expression) - { - return _inner.Execute(expression); - } - - public Task ExecuteAsync(Expression expression, CancellationToken cancellationToken) - { - return Task.FromResult(Execute(expression)); - } - - public Task ExecuteAsync(Expression expression, CancellationToken cancellationToken) - { - return Task.FromResult(Execute(expression)); - } -} - -internal class TestDbAsyncEnumerable : EnumerableQuery, IDbAsyncEnumerable, IQueryable -{ - public TestDbAsyncEnumerable(IEnumerable enumerable) - : base(enumerable) - { } - - public TestDbAsyncEnumerable(Expression expression) - : base(expression) - { } - - public IDbAsyncEnumerator GetAsyncEnumerator() - { - return new TestDbAsyncEnumerator(this.AsEnumerable().GetEnumerator()); - } - - IDbAsyncEnumerator IDbAsyncEnumerable.GetAsyncEnumerator() - { - return GetAsyncEnumerator(); - } - - IQueryProvider IQueryable.Provider - { - get { return new TestDbAsyncQueryProvider(this); } - } -} - -internal class TestDbAsyncEnumerator : IDbAsyncEnumerator -{ - private readonly IEnumerator _inner; - - public TestDbAsyncEnumerator(IEnumerator inner) - { - _inner = inner; - } - - public void Dispose() - { - _inner.Dispose(); - } - - public Task MoveNextAsync(CancellationToken cancellationToken) - { - return Task.FromResult(_inner.MoveNext()); - } - - public T Current - { - get { return _inner.Current; } - } - - object IDbAsyncEnumerator.Current - { - get { return Current; } - } -} diff --git a/Application/EdFi.Ods.AdminApi/EdFi.Ods.AdminApi.csproj b/Application/EdFi.Ods.AdminApi/EdFi.Ods.AdminApi.csproj index 8281d8e30..80714347a 100644 --- a/Application/EdFi.Ods.AdminApi/EdFi.Ods.AdminApi.csproj +++ b/Application/EdFi.Ods.AdminApi/EdFi.Ods.AdminApi.csproj @@ -18,7 +18,7 @@ - + @@ -34,8 +34,8 @@ - - + + @@ -43,6 +43,7 @@ + \ No newline at end of file diff --git a/Application/EdFi.Ods.AdminApi/appsettings.json b/Application/EdFi.Ods.AdminApi/appsettings.json index 03c4da066..a1017e423 100644 --- a/Application/EdFi.Ods.AdminApi/appsettings.json +++ b/Application/EdFi.Ods.AdminApi/appsettings.json @@ -7,9 +7,9 @@ "MultiTenancy": false }, "Authentication": { - "Authority": "", - "IssuerUrl": "", - "SigningKey": "", + "Authority": "https://desktop-orf770q/WebApi", + "IssuerUrl": "https://desktop-orf770q/WebApi", + "SigningKey": "YS1sb25nLXNhbXBsZQ==", "AllowRegistration": false }, "SwaggerSettings": { @@ -18,8 +18,8 @@ }, "EnableDockerEnvironment": false, "ConnectionStrings": { - "EdFi_Admin": "Data Source=.\\;Initial Catalog=EdFi_Admin;Integrated Security=True", - "EdFi_Security": "Data Source=.\\;Initial Catalog=EdFi_Security;Integrated Security=True" + "EdFi_Admin": "Data Source=.\\;Initial Catalog=EdFi_Admin;Integrated Security=True;Encrypt=False", + "EdFi_Security": "Data Source=.\\;Initial Catalog=EdFi_Security;Integrated Security=True;Encrypt=False" }, "Log4NetCore": { "Log4NetConfigFileName": "log4net\\log4net.config" @@ -46,7 +46,7 @@ { "Endpoint": "POST:/Connect/Register", "Period": "1m", - "Limit": 3 + "Limit": 1000 } ] } From 2b450b811a7d071325f382ca8bea558f28d99cd0 Mon Sep 17 00:00:00 2001 From: Johnny Brenes Date: Wed, 27 Mar 2024 14:19:55 -0600 Subject: [PATCH 12/17] docker files --- Application/EdFi.Ods.AdminApi/appsettings.Docker.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Application/EdFi.Ods.AdminApi/appsettings.Docker.json b/Application/EdFi.Ods.AdminApi/appsettings.Docker.json index 3b6e7859a..531df2eb8 100644 --- a/Application/EdFi.Ods.AdminApi/appsettings.Docker.json +++ b/Application/EdFi.Ods.AdminApi/appsettings.Docker.json @@ -28,7 +28,8 @@ "LogLevel": { "Default": "Information", "Microsoft": "Warning", - "Microsoft.Hosting.Lifetime": "Information" + "Microsoft.Hosting.Lifetime": "Information", + "Microsoft.AspNetCore.DataProtection": "Information" } }, "AllowedHosts": "*" From 669f1a3dc36a3b07a9edad6b140f6ca4b0aa0eed Mon Sep 17 00:00:00 2001 From: Johnny Brenes Date: Wed, 27 Mar 2024 15:23:20 -0600 Subject: [PATCH 13/17] clean appsettings values --- Application/EdFi.Ods.AdminApi/appsettings.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Application/EdFi.Ods.AdminApi/appsettings.json b/Application/EdFi.Ods.AdminApi/appsettings.json index a1017e423..d1ebcd3e2 100644 --- a/Application/EdFi.Ods.AdminApi/appsettings.json +++ b/Application/EdFi.Ods.AdminApi/appsettings.json @@ -7,9 +7,9 @@ "MultiTenancy": false }, "Authentication": { - "Authority": "https://desktop-orf770q/WebApi", - "IssuerUrl": "https://desktop-orf770q/WebApi", - "SigningKey": "YS1sb25nLXNhbXBsZQ==", + "Authority": "", + "IssuerUrl": "", + "SigningKey": "", "AllowRegistration": false }, "SwaggerSettings": { From 439918a9d9f4ff6c51dac42fa0ea5caaf84b11e7 Mon Sep 17 00:00:00 2001 From: Johnny Brenes Date: Thu, 28 Mar 2024 08:05:46 -0600 Subject: [PATCH 14/17] dbadmin dockerfile --- Docker/dbadmin.Dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Docker/dbadmin.Dockerfile b/Docker/dbadmin.Dockerfile index 6af729210..12685f85a 100644 --- a/Docker/dbadmin.Dockerfile +++ b/Docker/dbadmin.Dockerfile @@ -5,7 +5,6 @@ FROM edfialliance/ods-api-db-admin:7.1 LABEL maintainer="Ed-Fi Alliance, LLC and Contributors " - ENV POSTGRES_USER=${POSTGRES_USER} ENV POSTGRES_PASSWORD=${POSTGRES_PASSWORD} ENV POSTGRES_DB=postgres From c578cbb4de0d35a886b3b95cd4cadaaf1e826274 Mon Sep 17 00:00:00 2001 From: Johnny Brenes Date: Thu, 28 Mar 2024 12:29:30 -0600 Subject: [PATCH 15/17] Validation of empty results in test --- .../Admin API E2E 2.0 - Actions.postman_collection.json | 8 +++++--- ...n API E2E 2.0 - AuthStrategies.postman_collection.json | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Application/EdFi.Ods.AdminApi/E2E Tests/Admin API E2E 2.0 - Actions.postman_collection.json b/Application/EdFi.Ods.AdminApi/E2E Tests/Admin API E2E 2.0 - Actions.postman_collection.json index bdbabb6f4..ce0bbc342 100644 --- a/Application/EdFi.Ods.AdminApi/E2E Tests/Admin API E2E 2.0 - Actions.postman_collection.json +++ b/Application/EdFi.Ods.AdminApi/E2E Tests/Admin API E2E 2.0 - Actions.postman_collection.json @@ -26,9 +26,11 @@ "const response = pm.response.json();\r", "\r", "pm.test(\"GET Actions: Response matches success format\", function () {\r", - " pm.expect(response[0]).to.have.property(\"id\");\r", - " pm.expect(response[0]).to.have.property(\"name\");\r", - " pm.expect(response[0]).to.have.property(\"uri\");\r", + " if (response && response.length > 0) {\r", + " pm.expect(response[0]).to.have.property(\"id\");\r", + " pm.expect(response[0]).to.have.property(\"name\");\r", + " pm.expect(response[0]).to.have.property(\"uri\");\r", + " }\r", "});\r", "\r", "const GetActionsSchema = {\r", diff --git a/Application/EdFi.Ods.AdminApi/E2E Tests/Admin API E2E 2.0 - AuthStrategies.postman_collection.json b/Application/EdFi.Ods.AdminApi/E2E Tests/Admin API E2E 2.0 - AuthStrategies.postman_collection.json index 750f874ff..3526862d9 100644 --- a/Application/EdFi.Ods.AdminApi/E2E Tests/Admin API E2E 2.0 - AuthStrategies.postman_collection.json +++ b/Application/EdFi.Ods.AdminApi/E2E Tests/Admin API E2E 2.0 - AuthStrategies.postman_collection.json @@ -26,9 +26,11 @@ "const response = pm.response.json();\r", "\r", "pm.test(\"GET AuthorizationStrategies: Response matches success format\", function () {\r", - " pm.expect(response[0]).to.have.property(\"id\");\r", - " pm.expect(response[0]).to.have.property(\"name\");\r", - " pm.expect(response[0]).to.have.property(\"displayName\");\r", + " if (response && response.length > 0) {\r", + " pm.expect(response[0]).to.have.property(\"id\");\r", + " pm.expect(response[0]).to.have.property(\"name\");\r", + " pm.expect(response[0]).to.have.property(\"displayName\");\r", + " }\r", "});\r", "\r", "const GetAuthStrategiesSchema = {\r", From 1be4dd087f8304d3a202c1251502d1eae1eff5e8 Mon Sep 17 00:00:00 2001 From: Johnny Brenes Date: Thu, 28 Mar 2024 15:30:39 -0600 Subject: [PATCH 16/17] comparing against 980 ticket --- .../Features/ClaimSets/ResourceClaims/EditAuthStrategy.cs | 2 +- .../EdFi.Ods.AdminApi/Features/RequestLoggingMiddleware.cs | 6 ++++-- .../Services/ClaimSetEditor/AuthStrategyResolver.cs | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Application/EdFi.Ods.AdminApi/Features/ClaimSets/ResourceClaims/EditAuthStrategy.cs b/Application/EdFi.Ods.AdminApi/Features/ClaimSets/ResourceClaims/EditAuthStrategy.cs index 3b20e4058..0315afb4d 100644 --- a/Application/EdFi.Ods.AdminApi/Features/ClaimSets/ResourceClaims/EditAuthStrategy.cs +++ b/Application/EdFi.Ods.AdminApi/Features/ClaimSets/ResourceClaims/EditAuthStrategy.cs @@ -109,7 +109,7 @@ public OverrideAuthStategyOnClaimSetValidator(IGetResourcesByClaimSetIdQuery get var authStrategies = getAllAuthorizationStrategiesQuery.Execute(); foreach (var authStrategyName in overrideAuthStategyOnClaimSetRequest.AuthorizationStrategies!) { - var validAuthStrategyName = authStrategies + var validAuthStrategyName = authStrategies.AsEnumerable() .FirstOrDefault(a => a.AuthStrategyName!.ToLower() == authStrategyName!.ToLower()); if (validAuthStrategyName == null) diff --git a/Application/EdFi.Ods.AdminApi/Features/RequestLoggingMiddleware.cs b/Application/EdFi.Ods.AdminApi/Features/RequestLoggingMiddleware.cs index 9e6a7dd87..354e09dd4 100644 --- a/Application/EdFi.Ods.AdminApi/Features/RequestLoggingMiddleware.cs +++ b/Application/EdFi.Ods.AdminApi/Features/RequestLoggingMiddleware.cs @@ -45,7 +45,8 @@ public async Task Invoke(HttpContext context, ILogger case ValidationException validationException: var validationResponse = new { - title = "Validation failed", + title = "Validation failed", + status = (int)HttpStatusCode.BadRequest, errors = new Dictionary>() }; @@ -67,7 +68,8 @@ public async Task Invoke(HttpContext context, ILogger case INotFoundException notFoundException: var notFoundResponse = new { - title = notFoundException.Message, + title = notFoundException.Message, + status = (int)HttpStatusCode.NotFound }; logger.LogDebug(JsonSerializer.Serialize(new { message = notFoundResponse, traceId = context.TraceIdentifier })); diff --git a/Application/EdFi.Ods.AdminApi/Infrastructure/Services/ClaimSetEditor/AuthStrategyResolver.cs b/Application/EdFi.Ods.AdminApi/Infrastructure/Services/ClaimSetEditor/AuthStrategyResolver.cs index 831e591fb..bb66b981b 100644 --- a/Application/EdFi.Ods.AdminApi/Infrastructure/Services/ClaimSetEditor/AuthStrategyResolver.cs +++ b/Application/EdFi.Ods.AdminApi/Infrastructure/Services/ClaimSetEditor/AuthStrategyResolver.cs @@ -36,7 +36,7 @@ public IEnumerable ResolveAuthStrategies(IEnumerable x.AuthorizationStrategyName.Equals( strategy.AuthStrategyName, StringComparison.InvariantCultureIgnoreCase)); From 265db37712170344f5fdd8de151f4e13c69f9416 Mon Sep 17 00:00:00 2001 From: CSR2017 Date: Tue, 2 Apr 2024 16:14:53 -0500 Subject: [PATCH 17/17] Update docker files --- Docker/api.Dockerfile | 4 ++-- Docker/dev.Dockerfile | 11 +++++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Docker/api.Dockerfile b/Docker/api.Dockerfile index d50b95c65..7d873e97e 100644 --- a/Docker/api.Dockerfile +++ b/Docker/api.Dockerfile @@ -3,8 +3,8 @@ # The Ed-Fi Alliance licenses this file to you under the Apache License, Version 2.0. # See the LICENSE and NOTICES files in the project root for more information. -#tag 6.0-alpine -FROM mcr.microsoft.com/dotnet/aspnet@sha256:201cedd60cb295b2ebea7184561a45c5c0ee337e37300ea0f25cff5a2c762538 AS base +#tag 8.0-alpine +FROM mcr.microsoft.com/dotnet/aspnet:8.0.3-alpine3.19-amd64@sha256:a531d9d123928514405b9da9ff28a3aa81bd6f7d7d8cfb6207b66c007e7b3075 as base ARG DB=pgsql RUN apk --no-cache add curl=~8 unzip=~6 dos2unix=~7 bash=~5 gettext=~0 jq=~1 icu=~72 && \ diff --git a/Docker/dev.Dockerfile b/Docker/dev.Dockerfile index e523960a0..0b52fe47e 100644 --- a/Docker/dev.Dockerfile +++ b/Docker/dev.Dockerfile @@ -21,9 +21,8 @@ WORKDIR /source/EdFi.Ods.AdminApi RUN dotnet restore && dotnet build -c Release RUN dotnet publish -c Release /p:EnvironmentName=Production --no-build -o /app/EdFi.Ods.AdminApi -# TODO: update to .NET 8, will be handled in AdminAPI-983 -#tag aspnet:6.0-alpine -FROM mcr.microsoft.com/dotnet/aspnet@sha256:201cedd60cb295b2ebea7184561a45c5c0ee337e37300ea0f25cff5a2c762538 AS runtimebase +#tag aspnet:8.0-alpine +FROM mcr.microsoft.com/dotnet/aspnet:8.0.3-alpine3.19-amd64@sha256:a531d9d123928514405b9da9ff28a3aa81bd6f7d7d8cfb6207b66c007e7b3075 AS runtimebase FROM runtimebase AS runtime RUN apk --no-cache add curl=~8 dos2unix=~7 bash=~5 gettext=~0 icu=~72 && \ @@ -35,6 +34,7 @@ LABEL maintainer="Ed-Fi Alliance, LLC and Contributors " # Disable the globaliztion invariant mode (set in base image) ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false ENV ASPNETCORE_ENVIRONMENT=Production +ENV ASPNETCORE_HTTP_PORTS=80 WORKDIR /app COPY --from=publish /app/EdFi.Ods.AdminApi . @@ -47,9 +47,12 @@ RUN cp /app/log4net.txt /app/log4net.config && \ dos2unix /app/*.sh && \ dos2unix /app/log4net.config && \ chmod 500 /app/*.sh -- ** && \ + rm -f /app/log4net.txt && \ + rm -f /app/*.exe && \ + apk del dos2unix && \ chown -R edfi /app -EXPOSE 443 +EXPOSE ${ASPNETCORE_HTTP_PORTS} USER edfi WORKDIR /app