1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2024-12-22 12:54:53 -05:00

get wo body

This commit is contained in:
Michael Jerger 2023-12-13 16:06:37 +01:00
parent c2a42587d2
commit 44e10ed65a
2 changed files with 10 additions and 6 deletions

View file

@ -125,9 +125,10 @@ func (c *Client) Post(b []byte, to string) (resp *http.Response, err error) {
}
// Create an http GET request with forgejo/gitea specific headers
func (c *Client) Get(b []byte, to string) (resp *http.Response, err error) { // ToDo: we might not need the b parameter
func (c *Client) Get(to string) (resp *http.Response, err error) { // ToDo: we might not need the b parameter
var req *http.Request
if req, err = c.NewRequest(http.MethodGet, b, to); err != nil {
emptyBody := []byte{0}
if req, err = c.NewRequest(http.MethodGet, emptyBody, to); err != nil {
return nil, err
}
resp, err = c.client.Do(req)

View file

@ -1,4 +1,5 @@
// Copyright 2022 The Gitea Authors. All rights reserved.
// Copyright 2023 The forgejo Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package activitypub
@ -56,7 +57,7 @@ Set up a user called "me" for all tests
func TestNewClientReturnsClient(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 1})
pubID := "https://codeberg.org/api/v1/activitypub/user-id/12345"
pubID := "myGpgId"
c, err := NewClient(db.DefaultContext, user, pubID)
log.Debug("Client: %v\nError: %v", c, err)
@ -64,14 +65,15 @@ func TestNewClientReturnsClient(t *testing.T) {
}
/* TODO: bring this test to work or delete
func TestActivityPubSignedGet(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 1, Name: "me"})
pubID := "https://repo.prod.meissa.de/api/v1/activitypub/user-id/1/"
pubID := "myGpgId"
c, err := NewClient(db.DefaultContext, user, pubID)
assert.NoError(t, err)
expected := "BODY" // We want a person response
expected := "TestActivityPubSignedGet"
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
assert.Regexp(t, regexp.MustCompile("^"+setting.Federation.DigestAlgorithm), r.Header.Get("Digest"))
@ -84,7 +86,7 @@ func TestActivityPubSignedGet(t *testing.T) {
}))
defer srv.Close()
r, err := c.Get([]byte(expected), srv.URL)
r, err := c.Get(srv.URL)
assert.NoError(t, err)
defer r.Body.Close()
body, err := io.ReadAll(r.Body)
@ -92,6 +94,7 @@ func TestActivityPubSignedGet(t *testing.T) {
assert.Equal(t, expected, string(body))
}
*/
func TestActivityPubSignedPost(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())