feat(test): add unit test suites for API security, controllers, and attachment handling - #1073
Merged
Merged
Conversation
…ttachment handling
DerekRoberts
requested review from
OlgaLiber2 and
arcshiftsolutions
as code owners
August 22, 2026 01:56
Contributor
There was a problem hiding this comment.
Pull request overview
Adds API unit coverage for project authorization, controllers, attachments, and stakeholder interactions, plus safer optional access for absent interaction files.
Changes:
- Tests project access control and controller routing.
- Tests attachment and interaction validation/lifecycle behavior.
- Prevents direct buffer access when no file is uploaded.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
project.controller.spec.ts |
Tests routing and query criteria. |
project-auth.service.spec.ts |
Tests client and workflow authorization. |
interaction.service.spec.ts |
Tests authorization and attachment flows. |
interaction.controller.ts |
Safely accesses optional file buffers. |
interaction.controller.spec.ts |
Tests multipart request handling. |
attachment.service.spec.ts |
Tests authorization and replacement behavior. |
attachment.controller.spec.ts |
Tests attachment endpoint delegation. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…d attachment test coverage
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds comprehensive unit test coverage for core API security, controller routing, file attachments, and stakeholder interaction workflows that previously had 0 unit test coverage:
ProjectAuthService: Role and client-level access control, workflow state validations for forest clients and anonymous users.ProjectController: Central endpoint routing, query parameter conversions, search criteria construction, error handling, and state change delegations.AttachmentService&AttachmentController: File extension whitelist validations, public notice replacement lifecycle, MinIO/S3 object operations (getFileContent,delete,deleteObject, stream-to-buffer conversion), and download streaming.InteractionService&InteractionController: Business validations (communication date vs open date), attachment linking, replacement lifecycle (unlinking/deleting old, uploading new), filename/file pairing validations, and hardened buffer access againstTypeErrorwhen no file is uploaded.Verification
podman compose exec api npm run test:apiThanks for the PR!
Deployments, as required, will be available below:
Please create PRs in draft mode. Mark as ready to enable:
After merge, new images are deployed in: