feat(api): list all packages for site administrators - #38968
Open
lunny wants to merge 3 commits into
Open
Conversation
Add GET /admin/packages so admins can review packages across every owner
instead of querying each owner separately. It returns the same package
version representation as GET /packages/{owner} and supports page, limit,
type, and q filters.
Assisted-by: Codet:unknown
bircni
reviewed
Aug 18, 2026
bircni
approved these changes
Aug 18, 2026
bircni
left a comment
Member
There was a problem hiding this comment.
nits:
- Tests cover the unique behavior (admin sees another owner’s package, non-admin is forbidden) but not q/type, pagination, or X-Total-Count/Link headers. --> same as for others
- The swagger type enum omits arch, same as GET /packages/{owner}.
Co-authored-by: bircni <bircni@icloud.com> Signed-off-by: bircni <bircni@icloud.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new site-admin API endpoint to list package versions across the entire instance (GET /api/v1/admin/packages), aligning the response shape and query filters with the existing owner-scoped packages listing API.
Changes:
- Adds
GET /admin/packagesunder the existing admin API route group (site-admin + admin-scope protected). - Implements the handler to search package versions with pagination and
type/qfilters and returnsapi.Packagepayloads. - Adds an integration test and updates generated Swagger/OpenAPI specs for the new endpoint.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/integration/api_admin_packages_test.go | Adds integration coverage for listing packages as admin and forbidding non-admin access. |
| templates/swagger/v1-swagger.generated.json | Documents GET /admin/packages in Swagger v2 output. |
| templates/swagger/v1-openapi3.generated.json | Documents GET /admin/packages in OpenAPI v3 output. |
| routers/api/v1/api.go | Registers the new admin route GET /admin/packages. |
| routers/api/v1/admin/packages.go | Implements the admin packages listing handler and its Swagger annotation. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Lunny Xiao <xiaolunwen@gmail.com>
wxiaoguang
reviewed
Aug 19, 2026
Comment on lines
+53
to
+67
| func TestAPIAdminListPackagesForbidden(t *testing.T) { | ||
| defer tests.PrepareTestEnv(t)() | ||
|
|
||
| token := getUserToken(t, "user2", auth_model.AccessTokenScopeReadAdmin) | ||
| req := NewRequest(t, "GET", "/api/v1/admin/packages"). | ||
| AddTokenAuth(token) | ||
| MakeRequest(t, req, http.StatusForbidden) | ||
| } | ||
|
|
||
| func TestAPIAdminListPackagesNotLoggedIn(t *testing.T) { | ||
| defer tests.PrepareTestEnv(t)() | ||
|
|
||
| req := NewRequest(t, "GET", "/api/v1/admin/packages") | ||
| MakeRequest(t, req, http.StatusUnauthorized) | ||
| } |
Contributor
There was a problem hiding this comment.
Do you mean to test every endpoint under /admin path?
Does it really make sense?
If there are bugs, isn't the middleware's problem?
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.
Add
GET /admin/packagesso site administrators can review packages across every owner without querying each owner separately.It returns the same package version representation as
GET /packages/{owner}and supportspage,limit,type, andqfilters.Assisted by Codet(DeepSeek)