Skip to content

Update backend services, user right tests and user right documentation#1217

Merged
juhanikat merged 15 commits into
mainfrom
update-user-rights-tests
Jul 20, 2026
Merged

Update backend services, user right tests and user right documentation#1217
juhanikat merged 15 commits into
mainfrom
update-user-rights-tests

Conversation

@juhanikat

Copy link
Copy Markdown
Collaborator

No description provided.

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

Updates backend authorization behavior and aligns API tests + documentation with the current user-rights model (notably around EditRestricted behavior and occurrence/cross-search access).

Changes:

  • Hardened EditRestricted locality write permission checks to prevent gaining access by adding project links during an edit.
  • Refactored/expanded backend API tests (locality update, species merge, collecting method values) to better cover user-right scenarios.
  • Updated user-rights documentation with an Occurrence (Cross-Search) section and minor formatting cleanups.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
documentation/user_rights.md Adds/adjusts documentation for occurrence/cross-search access and formatting.
backend/src/services/locality.ts Tightens EditRestricted write permission logic for locality updates.
backend/src/api-tests/species/merge.test.ts Refactors merge tests and adds explicit non-admin/anonymous rejection coverage.
backend/src/api-tests/locality/update.test.ts Restructures locality update tests and adds permission-related cases for EditRestricted/anonymous.
backend/src/api-tests/locality/data.ts Moves locality-species test payload details out of shared fixture to the test setup.
backend/src/api-tests/crossSearch/get.test.ts Minor test description adjustment.
backend/src/api-tests/collectingMethodValues/getAll.test.ts Updates auth coverage to include anonymous rejection and edit-role acceptance.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread backend/src/services/locality.ts
Comment thread backend/src/api-tests/collectingMethodValues/getAll.test.ts Outdated
Comment thread backend/src/api-tests/species/merge.test.ts Outdated
@juhanikat juhanikat changed the title Update backend user right tests and user right documentation Update backend services, user right tests and user right documentation Jul 12, 2026
@juhanikat
juhanikat force-pushed the update-user-rights-tests branch from c5e6615 to 3152270 Compare July 12, 2026 12:11

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

Copilot reviewed 23 out of 23 changed files in this pull request and generated 4 comments.

Comments suppressed due to low confidence (1)

backend/src/api-tests/collectingMethodValues/getAll.test.ts:41

  • This test only verifies that anonymous users are rejected and that EditRestricted/EditUnrestricted users are accepted, but it no longer checks that a logged-in user without the required roles (e.g. Role.Project/testPl) is rejected. The route is protected by requireOneOf([Admin, EditUnrestricted, EditRestricted]) (backend/src/routes/collectingMethodValues.ts:8-12), so a negative case should be covered here.
  it('accepts users with locality edit access', async () => {
    await login('testEr', 'test')
    const { status: erStatus } = await send('collecting-method-values/all', 'GET')
    expect(erStatus).toBe(200)

Comment thread backend/src/api-tests/project/delete.test.ts Outdated
Comment thread backend/src/api-tests/museum/update.test.ts
Comment thread backend/src/api-tests/museum/create.test.ts
Comment thread backend/src/api-tests/projects/get.test.ts Outdated
juhanikat and others added 2 commits July 20, 2026 14:42
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@juhanikat
juhanikat marked this pull request as ready for review July 20, 2026 12:00
@juhanikat
juhanikat merged commit fa6dc11 into main Jul 20, 2026
4 checks passed
@juhanikat
juhanikat deleted the update-user-rights-tests branch July 20, 2026 12:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants