mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-29 11:20:42 +00:00
remove resolved todo & integration test
This commit is contained in:
parent
2f2330c450
commit
a9a30fc212
4 changed files with 20 additions and 8 deletions
|
@ -778,7 +778,6 @@ func Routes() *web.Route {
|
|||
m.Group("/repository-id/{repository-id}", func() {
|
||||
m.Get("", activitypub.Repository)
|
||||
m.Post("/inbox",
|
||||
// TODO: bind ativities here
|
||||
bind(forgefed.ForgeLike{}),
|
||||
// TODO: activitypub.ReqHTTPSignature(),
|
||||
activitypub.RepositoryInbox)
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
// Copyright 2024 The Forgejo Authors. All rights reserved.
|
||||
// Copyright 2017, 2023 The Gitea Authors. All rights reserved.
|
||||
// Copyright 2017 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package utils
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright 2023 The Forgejo Authors. All rights reserved.
|
||||
// Copyright 2023, 2024 The Forgejo Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package context
|
||||
|
@ -12,14 +12,13 @@ import (
|
|||
// RepositoryIDAssignmentAPI returns a middleware to handle context-repo assignment for api routes
|
||||
func RepositoryIDAssignmentAPI() func(ctx *APIContext) {
|
||||
return func(ctx *APIContext) {
|
||||
// TODO: enough validation for security?
|
||||
repositoryID := ctx.ParamsInt64(":repository-id")
|
||||
|
||||
var err error
|
||||
repository := new(Repository)
|
||||
repository.Repository, err = repo_model.GetRepositoryByID(ctx, repositoryID)
|
||||
if err != nil {
|
||||
ctx.Error(http.StatusInternalServerError, "GetRepositoryByID", err)
|
||||
ctx.Error(http.StatusNotFound, "GetRepositoryByID", err)
|
||||
}
|
||||
ctx.Repo = repository
|
||||
}
|
||||
|
|
|
@ -35,7 +35,22 @@ func TestActivityPubRepository(t *testing.T) {
|
|||
err := repository.UnmarshalJSON(body)
|
||||
assert.NoError(t, err)
|
||||
|
||||
assert.Equal(t, "", repository.Name)
|
||||
assert.Equal(t, fmt.Sprintf("activitypub/repository-id/%v$", repository.GetID().String()), repository.ID)
|
||||
assert.Regexp(t, fmt.Sprintf("activitypub/repository-id/%v$", repositoryID), repository.GetID().String())
|
||||
})
|
||||
}
|
||||
|
||||
func TestActivityPubMissingRepository(t *testing.T) {
|
||||
setting.Federation.Enabled = true
|
||||
testWebRoutes = routers.NormalRoutes()
|
||||
defer func() {
|
||||
setting.Federation.Enabled = false
|
||||
testWebRoutes = routers.NormalRoutes()
|
||||
}()
|
||||
|
||||
onGiteaRun(t, func(*testing.T, *url.URL) {
|
||||
repositoryID := 9999999
|
||||
req := NewRequest(t, "GET", fmt.Sprintf("/api/v1/activitypub/repository-id/%v", repositoryID))
|
||||
resp := MakeRequest(t, req, http.StatusNotFound)
|
||||
assert.Contains(t, resp.Body.String(), "repository does not exist")
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue