Skip to content

feat(test): add unit test suites for API security, controllers, and attachment handling - #1073

Merged
DerekRoberts merged 2 commits into
mainfrom
test/backend-security-controller-suites
Aug 22, 2026
Merged

feat(test): add unit test suites for API security, controllers, and attachment handling#1073
DerekRoberts merged 2 commits into
mainfrom
test/backend-security-controller-suites

Conversation

@DerekRoberts

@DerekRoberts DerekRoberts commented Aug 22, 2026

Copy link
Copy Markdown
Member

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 against TypeError when no file is uploaded.

Verification

  • All 21 test suites (239 unit tests) executed inside Podman container with 100% pass rate:
    podman compose exec api npm run test:api

Thanks 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:

Copilot AI balanced review requested due to automatic review settings August 22, 2026 01:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread api/src/app/modules/interaction/interaction.controller.ts
Comment thread api/src/app/modules/interaction/interaction.controller.ts
Comment thread api/src/app/modules/attachment/attachment.service.spec.ts
Comment thread api/src/app/modules/interaction/interaction.service.spec.ts
Comment thread api/src/app/modules/attachment/attachment.service.spec.ts
@DerekRoberts DerekRoberts moved this to Active in DevOps (NR) Aug 22, 2026
@DerekRoberts DerekRoberts self-assigned this Aug 22, 2026
@DerekRoberts
DerekRoberts merged commit ea658f1 into main Aug 22, 2026
28 of 30 checks passed
@github-project-automation github-project-automation Bot moved this from Active to Done in DevOps (NR) Aug 22, 2026
@DerekRoberts
DerekRoberts deleted the test/backend-security-controller-suites branch August 22, 2026 02:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants