Bundled end-of-branch commit on feat/postit-acl-members. PostIt UI for circles + per-post ACL - Reorganise PostIt.Tests into Auth/ and Blogs/ subfolders (Bearer/OIDC scope tests vs. blog API fakes live where they belong) and introduces PostItHeadlessCollection so the Avalonia.Headless tests share a single xUnit collection instead of contending with the EF-Core test host. - Adds BlogAclApiTests (a brand-new behavioural layer over POST /api/v1/blogacl) and the fakes it relies on (BlogApiTestFakes, BlogPostAuthorDtoTests, AddCircleMember DialogTests); pulls UserId-through-OIDC-sub path into BearerScopeTests / FakeAuthorizingBrowser / OidcStubAuthority. - App.axaml.cs gets a small PushPageAsync touch-up the new tests rely on. - Drops UnitTest1.cs (xUnit scaffold, never used). Yavsc.Blogs.Tests — SQLite instead of InMemory - Bumps Yavsc.Blogs.Tests.csproj on Microsoft.EntityFrameworkCore.Sqlite and rewrites BlogsWebServerFixture to hold a single shared SqliteConnection (Cache=Shared) for the fixture lifetime, with a sync Dispose close to dodge async teardown hangs. Reason: the EF Core InMemory provider silently ignores FKs, which masked the kind of bug we are about to pin in the ACL tests. SQLite enforces them, so any future INSERT that forgets to seed its parent rows fails loudly here instead of passing the test and breaking prod. - PublishEndpointTests and BlogApiSmokeTests get a one-line tweak to follow the new connection lifecycle. Foreign-key fallout: seed the default user in the fixture - Adds BlogsWebServerFixture.SeedUser(userName). Now that SQLite enforces BlogPost.AuthorId → AspNetUsers.Id, every test that POST/PUT/DELETE a BlogPost and sends AuthorId= 'tester' in the payload needs an AspNetUsers row to satisfy the FK or it returns 500 with SQLite Error 19. - BlogApiTests wraps the existing ResetDatabase with a ResetAndSeedDefaultUser helper for the six mutating tests; the four GET-only and ModelState-only tests keep the bare ResetDatabase. - Side benefit: every test in Yavsc.Blogs.Tests now finishes cleanly instead of hanging at teardown — previously a stuck test held the shared SqliteConnection open and the next tests waited indefinitely. Verified: dotnet test src/Yavsc.Blogs.Tests passes 25/25 green from a clean run, no fixture teardown hang.
95 lines
3 KiB
Makefile
95 lines
3 KiB
Makefile
APP_PROJECT_NAMES=Org Blogs
|
|
SLNDIR=..
|
|
|
|
include $(SLNDIR)/.env
|
|
include .env
|
|
|
|
generated/:
|
|
@mkdir -p $@
|
|
|
|
generated/yavscOrg.service:
|
|
generated/yavscBlogs.service:
|
|
|
|
generated/yavsc%.service: generated/ template.service $(SLNDIR)/.env
|
|
@cat template.service | APP_NAME="$*" \
|
|
HTTP_HOST="$(HTTP_HOST)" \
|
|
HTTP_PORT="$*_$(HTTP_PORT)" \
|
|
BASEAPPDIR="$(BASEAPPDIR)" \
|
|
APP_SYSLOG_ID="yavsc$*" \
|
|
POSTGRES_HOST="$(POSTGRES_HOST)" \
|
|
POSTGRES_PORT="$(POSTGRES_PORT)" \
|
|
POSTGRES_DB="$(POSTGRES_DB)" \
|
|
POSTGRES_USER="$(POSTGRES_USER)" \
|
|
POSTGRES_PASSWORD="$(POSTGRES_PASSWORD)" \
|
|
ANTHROPIC_API_KEY="$(ANTHROPIC_API_KEY)" \
|
|
ANTHROPIC_MAX_TOKENS="$(ANTHROPIC_MAX_TOKENS)" \
|
|
ASPNETCORE_Smtp__Host="$(ASPNETCORE_Smtp__Host)" \
|
|
ASPNETCORE_Smtp__Port="$(ASPNETCORE_Smtp__Port)" \
|
|
ASPNETCORE_Smtp__SenderName=$(ASPNETCORE_Smtp__SenderName) \
|
|
ASPNETCORE_Smtp__SenderEmail="$(ASPNETCORE_Smtp__SenderEmail)" \
|
|
ASPNETCORE_Smtp__UserName="$(ASPNETCORE_Smtp__UserName)" \
|
|
ASPNETCORE_Smtp__Password="$(ASPNETCORE_Smtp__Password)" \
|
|
envsubst > $@
|
|
@echo Created service file: $@
|
|
|
|
|
|
copy-services: copy-service-Org copy-service-Blogs
|
|
copy-service-Org: /etc/systemd/system/yavscOrg.service
|
|
copy-service-Blogs: /etc/systemd/system/yavscBlogs.service
|
|
|
|
copy-binaries: build_publish_Org build_publish_Blogs stop-services
|
|
@for project in $(APP_PROJECT_NAMES); \
|
|
do LCAPI=$$(echo $${project}|tr [:upper:] [:lower:]) ; \
|
|
echo "$${project} -> $${LCAPI}" ; \
|
|
BINDIR="$(SLNDIR)/src/Yavsc.$${project}/bin/$(CONFIGURATION)/$(DOTNET_FRAMEWORK)/publish" ; \
|
|
echo BINDIR: $${BINDIR} ; \
|
|
rm -f $${BINDIR}/appsettings-$${LCAPI}-dist.json ; \
|
|
mv -f $${BINDIR}/appsettings-$${LCAPI}.json \
|
|
$${BINDIR}/appsettings-$${LCAPI}-dist.json ; \
|
|
rm -f $${BINDIR}/appsettings-$${LCAPI}.json ; \
|
|
sync ; \
|
|
ls $${BINDIR}/appsettings* 2>&1 ; \
|
|
sudo cp -a $${BINDIR}/* $(BASEAPPDIR) ; \
|
|
done
|
|
@sudo chown -R $(USER_AND_GROUP) $(BASEAPPDIR)
|
|
|
|
/etc/systemd/system/yavsc%.service: generated/yavsc%.service
|
|
sudo cp $^ $@
|
|
sudo chown root:root $@
|
|
|
|
build_publish_%: clean_publish_dir_%
|
|
@ASPNETCORE_ENV=$(CONFIGURATION) dotnet publish $(SLNDIR)/src/Yavsc.$*/Yavsc.$*.csproj
|
|
|
|
clean_publish_dir_%:
|
|
@rm -rf $(SLNDIR)/src/Yavsc.$*/bin/$(CONFIGURATION)/$(DOTNET_FRAMEWORK)/publish
|
|
|
|
install: build_publish copy-binaries copy-services
|
|
@sudo systemctl daemon-reload
|
|
@for project in $(APP_PROJECT_NAMES); \
|
|
do \
|
|
sudo systemctl enable yavsc$${project} ; \
|
|
sudo systemctl start yavsc$${project} ; \
|
|
done
|
|
|
|
reinstall: copy-binaries
|
|
@sync
|
|
@for project in $(APP_PROJECT_NAMES); do \
|
|
sudo systemctl start yavsc$${project} ; done
|
|
|
|
stop-services:
|
|
@for project in $(APP_PROJECT_NAMES); \
|
|
do \
|
|
sudo systemctl stop yavsc$${project} ; \
|
|
done
|
|
|
|
$(SLNDIR)/src/Yavsc.Org/bin/$(CONFIGURATION)/$(DOTNET_FRAMEWORK)/publish: build_publish
|
|
$(SLNDIR)/src/Yavsc.Blogs/bin/$(CONFIGURATION)/$(DOTNET_FRAMEWORK)/publish: build_publish
|
|
|
|
showConfig:
|
|
@echo CONFIGURATION: $(CONFIGURATION)
|
|
@echo BASEAPPDIR: $(BASEAPPDIR)
|
|
|
|
clean:
|
|
@rm -rf generated
|
|
|
|
.PHONY: build_publish mep showConfig copy-service-Org copy-service-Blogs reinstall clean
|