Commit graph

8 commits

Author SHA1 Message Date
limiting-factor
22e87b2441 [v16.0/forgejo] chore(refactor): clarify REST API permissions tests (#13271) (#13312)
**Backport:** https://codeberg.org/forgejo/forgejo/pulls/13271

- separate test cases from fixtures
  - testcase.go: A `testCase` describes a test using `testData`
  - fixture.go: `fixture*` are function that creates the conditions for this test  case to run
- move the testData closer to the beginning
- update the README.md

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/13271
Reviewed-by: Mathieu Fenniak <mfenniak@noreply.codeberg.org>
(cherry picked from commit c1351e62d4)

```
Conflicts:
	routers/api/v1/permissions/tests/README.md
   one line because coverage targets are not the same in v15, keep the
   non coverage documentation
	routers/api/v1/permissions/tests/check_fork_destination.go
   ignore as it only exists in the main branch
```

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/13312
Reviewed-by: Mathieu Fenniak <mfenniak@noreply.codeberg.org>
2026-07-06 00:11:53 +02:00
forgejo-backport-action
fb0ab1e5fa [v16.0/forgejo] chore(refactor): remove GetX redundant accessors and use X in services/context/api.go (#13217)
**Backport:** https://codeberg.org/forgejo/forgejo/pulls/13215

Followup of the refactor adding setter/getter to APIContext  https://codeberg.org/forgejo/forgejo/pulls/13143

- Only has an impact on the getters used by `routers/api/v1/permissions`
- When GetX and X both exist, remove GetX
- When GetX exists and X does not, rename GetX to X
- GetOrg is an exception as it would conflict with Org and is renamed Organization. This is due to APIContext having its own Org structure that includes an Organization.

Co-authored-by: limiting-factor <limiting-factor@posteo.com>
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/13217
Reviewed-by: Mathieu Fenniak <mfenniak@noreply.codeberg.org>
2026-06-27 22:44:01 +02:00
limiting-factor
76ca2dc503 chore(refactor): s/Base.Data["requiredScopeCategories"]/APIContext.RequiredScopeCategories/ (#13138)
Move from storing in the untyped Base.Data disctionary to a typed field of APIContext.

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/13138
Reviewed-by: Mathieu Fenniak <mfenniak@noreply.codeberg.org>
2026-06-23 20:04:19 +02:00
limiting-factor
65e35d2ba0 chore(refactor): run routers/api/v1/permissions/tests from tests/integration (#13157)
Changing the tests introduced in [this pull request](https://codeberg.org/forgejo/forgejo/pulls/12512) to run from the integration directory instead of running from a package, makes it possible to backport to v15.

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/13157
Reviewed-by: Mathieu Fenniak <mfenniak@noreply.codeberg.org>
2026-06-21 21:43:57 +02:00
limiting-factor
97595369c7
chore: tests for REST API permission check 2026-06-20 22:58:56 +02:00
limiting-factor
b296496356
chore: refactor REST API permission check 2026-06-20 22:58:56 +02:00
limiting-factor
17616708fd
feat: interface for REST API permissions
and a concrete implementation for testing and re-use
2026-06-20 22:58:56 +02:00
limiting-factor
9995b923a8
tests: record permission middleware used in REST API routes 2026-06-20 22:58:56 +02:00