Skip to content

Commit b419680

Browse files
author
Mike Blair
committed
update tests and extension methods
1 parent 8a1f3b1 commit b419680

143 files changed

Lines changed: 7787 additions & 1282 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

FractalDataWorks.DeveloperKit.slnx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@
209209
<Project Path="src/FractalDataWorks.Operations/FractalDataWorks.Operations.csproj" />
210210
<Project Path="src/FractalDataWorks.Processors.Abstractions/FractalDataWorks.Processors.Abstractions.csproj" />
211211
<Project Path="src/FractalDataWorks.Registration.SourceGenerators/FractalDataWorks.Registration.SourceGenerators.csproj" />
212+
<Project Path="src/FractalDataWorks.Calculations.Endpoints/FractalDataWorks.Calculations.Endpoints.csproj" />
212213
<Project Path="src/FractalDataWorks.Conventions.Analyzers/FractalDataWorks.Conventions.Analyzers.csproj" />
213214
<Project Path="src/FractalDataWorks.Conventions.CodeFixes/FractalDataWorks.Conventions.CodeFixes.csproj" />
214215
<Project Path="src/FractalDataWorks.Conventions.FileSplitter/FractalDataWorks.Conventions.FileSplitter.csproj" />
@@ -219,6 +220,8 @@
219220
<Project Path="src/FractalDataWorks.Schema.Ddl/FractalDataWorks.Schema.Ddl.csproj" />
220221
<Project Path="src/FractalDataWorks.Schema.Endpoints/FractalDataWorks.Schema.Endpoints.csproj" />
221222
<Project Path="src/FractalDataWorks.Security.Hashing/FractalDataWorks.Security.Hashing.csproj" />
223+
<Project Path="src/FractalDataWorks.Services.Authentication.Clients/FractalDataWorks.Services.Authentication.Clients.csproj" />
224+
<Project Path="src/FractalDataWorks.Services.Authentication.Endpoints/FractalDataWorks.Services.Authentication.Endpoints.csproj" />
222225
<Project Path="src/FractalDataWorks.Services.Authentication.Sql/FractalDataWorks.Services.Authentication.Sql.csproj" />
223226
<Project Path="src/FractalDataWorks.Services.Authorization.Endpoints/FractalDataWorks.Services.Authorization.Endpoints.csproj" />
224227
<Project Path="src/FractalDataWorks.Services.Authorization/FractalDataWorks.Services.Authorization.csproj" />

ReferenceSolutions/.gitlab-ci.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
stages:
2+
- deploy
3+
4+
variables:
5+
DOTNET_CLI_HOME: "/tmp/dotnet-cli"
6+
DOTNET_NOLOGO: "true"
7+
DEPLOY_DIR: "/opt/fdw"
8+
9+
deploy:
10+
stage: deploy
11+
tags:
12+
- shell
13+
script:
14+
- echo "=== Building all services ==="
15+
- dotnet publish ApiSolution/src/Reference.Api/Reference.Api.csproj -c Release -o build/api
16+
- dotnet publish EtlServer/src/Reference.Etl.Server/Reference.Etl.Server.csproj -c Release -o build/etl
17+
- dotnet publish SchedulerServer/src/Reference.Scheduler.Server/Reference.Scheduler.Server.csproj -c Release -o build/scheduler
18+
- dotnet publish ManagementUI/src/Reference.Management.UI/Reference.Management.UI.csproj -c Release -o build/ui
19+
- echo "=== Stopping services ==="
20+
- sudo systemctl stop fdw-api fdw-etl fdw-scheduler fdw-ui || true
21+
- echo "=== Deploying ==="
22+
- rsync -a --delete build/api/ $DEPLOY_DIR/api/
23+
- rsync -a --delete build/etl/ $DEPLOY_DIR/etl/
24+
- rsync -a --delete build/scheduler/ $DEPLOY_DIR/scheduler/
25+
- rsync -a --delete build/ui/ $DEPLOY_DIR/ui/
26+
- echo "=== Starting services ==="
27+
- sudo systemctl start fdw-api fdw-etl fdw-scheduler fdw-ui
28+
- sleep 3
29+
- systemctl is-active fdw-api fdw-etl fdw-scheduler fdw-ui
30+
only:
31+
- develop
32+
environment:
33+
name: development
34+
url: https://fdw.cyberdynedevelopment.dev

ReferenceSolutions/ApiSolution/Directory.Packages.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
-->
1111
<PropertyGroup>
1212
<!-- FractalDataWorks version - pinned for stable builds -->
13-
<FdwVersion>0.7.0-rc.13.g9b5f33c298</FdwVersion>
13+
<FdwVersion>0.7.0-rc.14</FdwVersion>
1414
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
1515
</PropertyGroup>
1616

Lines changed: 13 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,42 @@
11
# ApiSolution Dockerfile
22
# Build context: ReferenceSolutions/ (parent directory)
3-
# docker build -f ApiSolution/Dockerfile .
4-
#
5-
# Requires cross-solution references:
6-
# - SharedPackages/src/Reference.Authentication/
7-
# - ManagementUI/src/Reference.Management.Contracts/
8-
9-
FROM mcr.microsoft.com/dotnet/sdk:10.0-preview AS build
3+
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
4+
ARG GITLAB_TOKEN
5+
ENV GITLAB_TOKEN=${GITLAB_TOKEN}
6+
COPY docker-certs/cloudflare-origin-rsa.crt /usr/local/share/ca-certificates/
7+
COPY docker-certs/cloudflare-origin-ecc.crt /usr/local/share/ca-certificates/
8+
RUN update-ca-certificates
109
WORKDIR /src
11-
1210
# Copy nuget configuration and package management
1311
COPY ApiSolution/nuget.config ApiSolution/
1412
COPY ApiSolution/Directory.Packages.props ApiSolution/
15-
1613
# Copy solution file
1714
COPY ApiSolution/ApiSolution.slnx ApiSolution/
18-
19-
# Copy project files for restore (main project)
15+
# Copy project files for restore
2016
COPY ApiSolution/src/Reference.Api/Reference.Api.csproj ApiSolution/src/Reference.Api/
21-
2217
# Copy cross-solution project references
23-
COPY SharedPackages/src/Reference.Authentication/Reference.Authentication.csproj SharedPackages/src/Reference.Authentication/
24-
COPY SharedPackages/Directory.Packages.props SharedPackages/
2518
COPY ManagementUI/src/Reference.Management.Contracts/Reference.Management.Contracts.csproj ManagementUI/src/Reference.Management.Contracts/
2619
COPY ManagementUI/Directory.Build.props ManagementUI/
2720
COPY ManagementUI/Directory.Packages.props ManagementUI/
28-
29-
# Restore with NuGet packages from nuget.org only (LocalFdw packages are pre-built)
30-
# Override LocalNugetFolder to a dummy path so restore only uses nuget.org
31-
RUN dotnet restore ApiSolution/src/Reference.Api/Reference.Api.csproj \
32-
-p:LocalNugetFolder=/tmp/empty-nuget
33-
21+
# Copy internal-nuget for Reference.* packages
22+
COPY internal-nuget/ internal-nuget/
23+
# Restore
24+
RUN dotnet restore ApiSolution/src/Reference.Api/Reference.Api.csproj
3425
# Copy all source files
3526
COPY ApiSolution/src/ ApiSolution/src/
36-
COPY SharedPackages/src/Reference.Authentication/ SharedPackages/src/Reference.Authentication/
3727
COPY ManagementUI/src/Reference.Management.Contracts/ ManagementUI/src/Reference.Management.Contracts/
38-
3928
# Publish
4029
RUN dotnet publish ApiSolution/src/Reference.Api/Reference.Api.csproj \
4130
-c Release \
4231
-o /app/publish \
43-
--no-restore \
44-
-p:LocalNugetFolder=/tmp/empty-nuget
45-
32+
--no-restore
4633
# Runtime stage
47-
FROM mcr.microsoft.com/dotnet/aspnet:10.0-preview AS runtime
34+
FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS runtime
4835
WORKDIR /app
49-
50-
# Security: run as non-root
5136
RUN groupadd -r fdw && useradd -r -g fdw -s /sbin/nologin fdw
5237
USER fdw
53-
5438
COPY --from=build /app/publish .
55-
5639
EXPOSE 5001
5740
HEALTHCHECK --interval=30s --timeout=5s --retries=3 \
5841
CMD curl -sf http://localhost:5000/health || exit 1
59-
6042
ENTRYPOINT ["dotnet", "Reference.Api.dll"]

ReferenceSolutions/ApiSolution/docker/mssql/entrypoint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ if [ -f /init/ControlDb.dacpac ]; then
5858
/TargetPassword:"$MSSQL_SA_PASSWORD" \
5959
/TargetTrustServerCertificate:True \
6060
/p:BlockOnPossibleDataLoss=False \
61-
/p:AllowIncompatiblePlatform=True
61+
/p:AllowIncompatiblePlatform=True || echo "WARNING: Dacpac deployment had errors (continuing)"
6262

6363
echo "Dacpac deployment completed successfully."
6464
else

ReferenceSolutions/ApiSolution/nuget.config

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,24 @@
33
<packageSources>
44
<clear />
55
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
6-
<add key="LocalFdw" value="%LocalNugetFolder%" />
6+
<add key="GitLabFdw" value="https://gitlab.cyberdynedevelopment.dev/api/v4/projects/1/packages/nuget/index.json" />
7+
<add key="Internal" value="../internal-nuget" />
78
</packageSources>
8-
99
<packageSourceMapping>
10-
<packageSource key="LocalFdw">
10+
<packageSource key="GitLabFdw">
1111
<package pattern="FractalDataWorks.*" />
12+
</packageSource>
13+
<packageSource key="Internal">
1214
<package pattern="Reference.*" />
1315
</packageSource>
1416
<packageSource key="nuget.org">
1517
<package pattern="*" />
1618
</packageSource>
1719
</packageSourceMapping>
20+
<packageSourceCredentials>
21+
<GitLabFdw>
22+
<add key="Username" value="gitlab+deploy-token-2" />
23+
<add key="ClearTextPassword" value="gldt-Q9WhLtz5Vj1NRYy1LV7y" />
24+
</GitLabFdw>
25+
</packageSourceCredentials>
1826
</configuration>

ReferenceSolutions/ApiSolution/src/Reference.Api/Configuration/CorsOptions.cs

Lines changed: 0 additions & 115 deletions
This file was deleted.

ReferenceSolutions/ApiSolution/src/Reference.Api/Endpoints/AdminDataEndpoint.cs

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@
33
using System.Security.Claims;
44
using System.Threading;
55
using System.Threading.Tasks;
6-
using FastEndpoints;
7-
using Microsoft.AspNetCore.Builder;
8-
using Microsoft.AspNetCore.Http;
9-
using Microsoft.AspNetCore.RateLimiting;
6+
using FractalDataWorks.Web.RestEndpoints.Security;
107

118
namespace Reference.Api.Endpoints;
129

@@ -45,19 +42,25 @@ public sealed class AdminDataResponse
4542
/// An admin endpoint requiring the Admin role and using the highest rate limit policy.
4643
/// Uses the "Admin" rate limit policy (10000 req/min).
4744
/// </summary>
48-
public sealed class AdminDataEndpoint : EndpointWithoutRequest<AdminDataResponse>
45+
public sealed class AdminDataEndpoint : AdminEndpointBase<AdminDataResponse>
4946
{
5047
/// <inheritdoc />
51-
public override void Configure()
48+
protected override string Route => "/admin/data";
49+
50+
/// <inheritdoc />
51+
protected override string EndpointSummary => "Get admin data with highest rate limit";
52+
53+
/// <inheritdoc />
54+
protected override string EndpointDescription => "An admin endpoint requiring the Admin role with highest rate limit policy (10000 req/min)";
55+
56+
/// <inheritdoc />
57+
protected override string? EndpointTag => "Security Examples";
58+
59+
/// <inheritdoc />
60+
protected override void ConfigureEndpoint()
5261
{
53-
Get("/admin/data");
54-
Policies("fdw:configurations:write");
55-
Options(x => x.RequireRateLimiting("Admin"));
56-
Description(x => x.WithTags("Security Examples"));
5762
Summary(s =>
5863
{
59-
s.Summary = "Get admin data with highest rate limit";
60-
s.Description = "An admin endpoint requiring the Admin role with highest rate limit policy (10000 req/min)";
6164
s.Response<AdminDataResponse>(200, "Success");
6265
s.Response(401, "Unauthorized");
6366
s.Response(403, "Forbidden - Admin role required");

ReferenceSolutions/ApiSolution/src/Reference.Api/Endpoints/AuthenticatedDataEndpoint.cs

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
using System;
2-
using System.Linq;
3-
using System.Security.Claims;
42
using System.Threading;
53
using System.Threading.Tasks;
6-
using FastEndpoints;
7-
using Microsoft.AspNetCore.Builder;
8-
using Microsoft.AspNetCore.Http;
9-
using Microsoft.AspNetCore.RateLimiting;
4+
using FractalDataWorks.Web.RestEndpoints.Security;
105

116
namespace Reference.Api.Endpoints;
127

@@ -40,19 +35,25 @@ public sealed class AuthenticatedDataResponse
4035
/// An authenticated endpoint demonstrating higher rate limits for authenticated users.
4136
/// Uses the "Authenticated" rate limit policy (500 req/min).
4237
/// </summary>
43-
public sealed class AuthenticatedDataEndpoint : EndpointWithoutRequest<AuthenticatedDataResponse>
38+
public sealed class AuthenticatedDataEndpoint : AuthenticatedEndpointBase<AuthenticatedDataResponse>
4439
{
4540
/// <inheritdoc />
46-
public override void Configure()
41+
protected override string Route => "/authenticated/data";
42+
43+
/// <inheritdoc />
44+
protected override string EndpointSummary => "Get authenticated data with higher rate limit";
45+
46+
/// <inheritdoc />
47+
protected override string EndpointDescription => "An authenticated endpoint demonstrating higher rate limits for authenticated users (500 req/min)";
48+
49+
/// <inheritdoc />
50+
protected override string? EndpointTag => "Security Examples";
51+
52+
/// <inheritdoc />
53+
protected override void ConfigureEndpoint()
4754
{
48-
Get("/authenticated/data");
49-
// No AllowAnonymous() - requires authentication
50-
Options(x => x.RequireRateLimiting("Authenticated"));
51-
Description(x => x.WithTags("Security Examples"));
5255
Summary(s =>
5356
{
54-
s.Summary = "Get authenticated data with higher rate limit";
55-
s.Description = "An authenticated endpoint demonstrating higher rate limits for authenticated users (500 req/min)";
5657
s.Response<AuthenticatedDataResponse>(200, "Success");
5758
s.Response(401, "Unauthorized");
5859
s.Response(429, "Rate limit exceeded");

0 commit comments

Comments
 (0)