mirror of
https://codeberg.org/forgejo/forgejo
synced 2024-11-25 11:16:11 +01:00
remove resolved todo & integration test
This commit is contained in:
parent
2f2330c450
commit
a9a30fc212
|
@ -778,7 +778,6 @@ func Routes() *web.Route {
|
||||||
m.Group("/repository-id/{repository-id}", func() {
|
m.Group("/repository-id/{repository-id}", func() {
|
||||||
m.Get("", activitypub.Repository)
|
m.Get("", activitypub.Repository)
|
||||||
m.Post("/inbox",
|
m.Post("/inbox",
|
||||||
// TODO: bind ativities here
|
|
||||||
bind(forgefed.ForgeLike{}),
|
bind(forgefed.ForgeLike{}),
|
||||||
// TODO: activitypub.ReqHTTPSignature(),
|
// TODO: activitypub.ReqHTTPSignature(),
|
||||||
activitypub.RepositoryInbox)
|
activitypub.RepositoryInbox)
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
// Copyright 2024 The Forgejo Authors. All rights reserved.
|
// Copyright 2017 The Gitea Authors. All rights reserved.
|
||||||
// Copyright 2017, 2023 The Gitea Authors. All rights reserved.
|
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package utils
|
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
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package context
|
package context
|
||||||
|
@ -12,14 +12,13 @@ import (
|
||||||
// RepositoryIDAssignmentAPI returns a middleware to handle context-repo assignment for api routes
|
// RepositoryIDAssignmentAPI returns a middleware to handle context-repo assignment for api routes
|
||||||
func RepositoryIDAssignmentAPI() func(ctx *APIContext) {
|
func RepositoryIDAssignmentAPI() func(ctx *APIContext) {
|
||||||
return func(ctx *APIContext) {
|
return func(ctx *APIContext) {
|
||||||
// TODO: enough validation for security?
|
|
||||||
repositoryID := ctx.ParamsInt64(":repository-id")
|
repositoryID := ctx.ParamsInt64(":repository-id")
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
repository := new(Repository)
|
repository := new(Repository)
|
||||||
repository.Repository, err = repo_model.GetRepositoryByID(ctx, repositoryID)
|
repository.Repository, err = repo_model.GetRepositoryByID(ctx, repositoryID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.Error(http.StatusInternalServerError, "GetRepositoryByID", err)
|
ctx.Error(http.StatusNotFound, "GetRepositoryByID", err)
|
||||||
}
|
}
|
||||||
ctx.Repo = repository
|
ctx.Repo = repository
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,22 @@ func TestActivityPubRepository(t *testing.T) {
|
||||||
err := repository.UnmarshalJSON(body)
|
err := repository.UnmarshalJSON(body)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
assert.Equal(t, "", repository.Name)
|
assert.Regexp(t, fmt.Sprintf("activitypub/repository-id/%v$", repositoryID), repository.GetID().String())
|
||||||
assert.Equal(t, fmt.Sprintf("activitypub/repository-id/%v$", repository.GetID().String()), repository.ID)
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
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