diff options
author | Giteabot <teabot@gitea.io> | 2023-07-09 08:00:04 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-09 12:00:04 +0000 |
commit | ea2c9de3c457afb648191b501582a73f7b5498e4 (patch) | |
tree | 2a7d1c73aea7d6950d4bb4d3df9b79bbbd4d7464 /tests/integration | |
parent | 348a6bf70d0f4766e57f0a3d0425b9222feccf62 (diff) | |
download | gitea-ea2c9de3c457afb648191b501582a73f7b5498e4.tar.gz gitea-ea2c9de3c457afb648191b501582a73f7b5498e4.zip |
Test if container blob is accessible before mounting (#22759) (#25784)
Backport #22759 by @KN4CK3R
related #16865
This PR adds an accessibility check before mounting container blobs.
Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: silverwind <me@silverwind.io>
Diffstat (limited to 'tests/integration')
-rw-r--r-- | tests/integration/api_packages_container_test.go | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/tests/integration/api_packages_container_test.go b/tests/integration/api_packages_container_test.go index fe9208bb05..01002a4413 100644 --- a/tests/integration/api_packages_container_test.go +++ b/tests/integration/api_packages_container_test.go @@ -34,6 +34,7 @@ func TestPackageContainer(t *testing.T) { user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2}) session := loginUser(t, user.Name) token := getTokenForLoggedInUser(t, session, auth_model.AccessTokenScopeReadPackage) + privateUser := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 31}) has := func(l packages_model.PackagePropertyList, name string) bool { for _, pp := range l { @@ -262,7 +263,16 @@ func TestPackageContainer(t *testing.T) { t.Run("UploadBlob/Mount", func(t *testing.T) { defer tests.PrintCurrentTest(t)() - req := NewRequest(t, "POST", fmt.Sprintf("%s/blobs/uploads?mount=%s", url, unknownDigest)) + privateBlobDigest := "sha256:6ccce4863b70f258d691f59609d31b4502e1ba5199942d3bc5d35d17a4ce771d" + req := NewRequestWithBody(t, "POST", fmt.Sprintf("%sv2/%s/%s/blobs/uploads?digest=%s", setting.AppURL, privateUser.Name, image, privateBlobDigest), strings.NewReader("gitea")) + req = AddBasicAuthHeader(req, privateUser.Name) + MakeRequest(t, req, http.StatusCreated) + + req = NewRequest(t, "POST", fmt.Sprintf("%s/blobs/uploads?mount=%s", url, unknownDigest)) + addTokenAuthHeader(req, userToken) + MakeRequest(t, req, http.StatusAccepted) + + req = NewRequest(t, "POST", fmt.Sprintf("%s/blobs/uploads?mount=%s", url, privateBlobDigest)) addTokenAuthHeader(req, userToken) MakeRequest(t, req, http.StatusAccepted) |