aboutsummaryrefslogtreecommitdiffstats
path: root/tests/integration/api_packages_container_test.go
diff options
context:
space:
mode:
authorKN4CK3R <admin@oldschoolhack.me>2023-07-09 13:24:43 +0200
committerGitHub <noreply@github.com>2023-07-09 11:24:43 +0000
commit115f40e43368fefc776232a2df289b2fcadbb11d (patch)
tree5a892ca23c2fc5173a39aa439cce428ede7356fc /tests/integration/api_packages_container_test.go
parent38844e0869bff0a08f8810c97cb3f5cb07df9a8e (diff)
downloadgitea-115f40e43368fefc776232a2df289b2fcadbb11d.tar.gz
gitea-115f40e43368fefc776232a2df289b2fcadbb11d.zip
Test if container blob is accessible before mounting (#22759)
related #16865 This PR adds an accessibility check before mounting container blobs. --------- Co-authored-by: techknowlogick <techknowlogick@gitea.io> Co-authored-by: silverwind <me@silverwind.io>
Diffstat (limited to 'tests/integration/api_packages_container_test.go')
-rw-r--r--tests/integration/api_packages_container_test.go12
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)