mirror of
https://github.com/go-gitea/gitea
synced 2025-07-09 20:17:21 +00:00
Backport #34666 by wxiaoguang Fix #25846 1. the ImageConfig can be empty, fall back to default 2. the blob size can be empty, it still needs "Content-Length" header Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
@ -7,6 +7,7 @@ import (
|
||||
"bytes"
|
||||
"crypto/sha256"
|
||||
"encoding/base64"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strconv"
|
||||
@ -623,6 +624,22 @@ func TestPackageContainer(t *testing.T) {
|
||||
assert.Equal(t, blobContent, resp.Body.Bytes())
|
||||
})
|
||||
|
||||
t.Run("GetBlob/Empty", func(t *testing.T) {
|
||||
defer tests.PrintCurrentTest(t)()
|
||||
emptyDigestBuf := sha256.Sum256(nil)
|
||||
emptyDigest := "sha256:" + hex.EncodeToString(emptyDigestBuf[:])
|
||||
req := NewRequestWithBody(t, "POST", fmt.Sprintf("%s/blobs/uploads?digest=%s", url, emptyDigest), strings.NewReader("")).AddTokenAuth(userToken)
|
||||
MakeRequest(t, req, http.StatusCreated)
|
||||
|
||||
req = NewRequest(t, "HEAD", fmt.Sprintf("%s/blobs/%s", url, emptyDigest)).AddTokenAuth(userToken)
|
||||
resp := MakeRequest(t, req, http.StatusOK)
|
||||
assert.Equal(t, "0", resp.Header().Get("Content-Length"))
|
||||
|
||||
req = NewRequest(t, "GET", fmt.Sprintf("%s/blobs/%s", url, emptyDigest)).AddTokenAuth(userToken)
|
||||
resp = MakeRequest(t, req, http.StatusOK)
|
||||
assert.Equal(t, "0", resp.Header().Get("Content-Length"))
|
||||
})
|
||||
|
||||
t.Run("GetTagList", func(t *testing.T) {
|
||||
defer tests.PrintCurrentTest(t)()
|
||||
|
||||
|
Reference in New Issue
Block a user