mirror of
https://codeberg.org/forgejo/forgejo
synced 2024-11-22 09:54:24 +01:00
wix the invalid test
This commit is contained in:
parent
534d692d68
commit
ded7b60d0c
|
@ -59,7 +59,7 @@ func TestActivityPubMissingRepository(t *testing.T) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestActivityPubRepositoryInbox(t *testing.T) {
|
func TestActivityPubRepositoryInboxValid(t *testing.T) {
|
||||||
setting.Federation.Enabled = true
|
setting.Federation.Enabled = true
|
||||||
testWebRoutes = routers.NormalRoutes()
|
testWebRoutes = routers.NormalRoutes()
|
||||||
defer func() {
|
defer func() {
|
||||||
|
@ -84,16 +84,42 @@ func TestActivityPubRepositoryInbox(t *testing.T) {
|
||||||
repoInboxUrl := fmt.Sprintf("%s/api/v1/activitypub/repository-id/%v/inbox",
|
repoInboxUrl := fmt.Sprintf("%s/api/v1/activitypub/repository-id/%v/inbox",
|
||||||
srv.URL, repositoryID)
|
srv.URL, repositoryID)
|
||||||
|
|
||||||
// valid activity request succeeds
|
|
||||||
activity := []byte(fmt.Sprintf(`{"type":"Like","startTime":"2024-03-27T00:00:00Z","actor":"%s/api/v1/activitypub/user-id/2","object":"%s/api/v1/activitypub/repository-id/%v"}`,
|
activity := []byte(fmt.Sprintf(`{"type":"Like","startTime":"2024-03-27T00:00:00Z","actor":"%s/api/v1/activitypub/user-id/2","object":"%s/api/v1/activitypub/repository-id/%v"}`,
|
||||||
srv.URL, srv.URL, repositoryID))
|
srv.URL, srv.URL, repositoryID))
|
||||||
resp, err := c.Post(activity, repoInboxUrl)
|
resp, err := c.Post(activity, repoInboxUrl)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Equal(t, http.StatusNoContent, resp.StatusCode)
|
assert.Equal(t, http.StatusNoContent, resp.StatusCode)
|
||||||
|
})
|
||||||
// invalid activity request succeeds
|
}
|
||||||
activity = []byte(fmt.Sprintf(`{"type":"Wrong"}`))
|
|
||||||
resp, err = c.Post(activity, repoInboxUrl)
|
func TestActivityPubRepositoryInboxInvalid(t *testing.T) {
|
||||||
assert.Error(t, err)
|
setting.Federation.Enabled = true
|
||||||
|
testWebRoutes = routers.NormalRoutes()
|
||||||
|
defer func() {
|
||||||
|
setting.Federation.Enabled = false
|
||||||
|
testWebRoutes = routers.NormalRoutes()
|
||||||
|
}()
|
||||||
|
|
||||||
|
srv := httptest.NewServer(testWebRoutes)
|
||||||
|
defer srv.Close()
|
||||||
|
|
||||||
|
onGiteaRun(t, func(*testing.T, *url.URL) {
|
||||||
|
appURL := setting.AppURL
|
||||||
|
setting.AppURL = srv.URL + "/"
|
||||||
|
defer func() {
|
||||||
|
setting.Database.LogSQL = false
|
||||||
|
setting.AppURL = appURL
|
||||||
|
}()
|
||||||
|
actionsUser := user.NewActionsUser()
|
||||||
|
repositoryID := 2
|
||||||
|
c, err := activitypub.NewClient(db.DefaultContext, actionsUser, "not used")
|
||||||
|
assert.NoError(t, err)
|
||||||
|
repoInboxUrl := fmt.Sprintf("%s/api/v1/activitypub/repository-id/%v/inbox",
|
||||||
|
srv.URL, repositoryID)
|
||||||
|
|
||||||
|
activity := []byte(fmt.Sprintf(`{"type":"Wrong"}`))
|
||||||
|
resp, err := c.Post(activity, repoInboxUrl)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
assert.Equal(t, http.StatusNotAcceptable, resp.StatusCode)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue