|
|
@ -205,18 +205,54 @@ func TestPackageContainer(t *testing.T) { |
|
|
|
assert.Equal(t, uuid, resp.Header().Get("Docker-Upload-Uuid")) |
|
|
|
assert.Equal(t, uuid, resp.Header().Get("Docker-Upload-Uuid")) |
|
|
|
assert.Equal(t, contentRange, resp.Header().Get("Range")) |
|
|
|
assert.Equal(t, contentRange, resp.Header().Get("Range")) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
uploadURL = resp.Header().Get("Location") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
req = NewRequest(t, "GET", setting.AppURL+uploadURL[1:]) |
|
|
|
|
|
|
|
addTokenAuthHeader(req, userToken) |
|
|
|
|
|
|
|
resp = MakeRequest(t, req, http.StatusNoContent) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assert.Equal(t, uuid, resp.Header().Get("Docker-Upload-Uuid")) |
|
|
|
|
|
|
|
assert.Equal(t, fmt.Sprintf("0-%d", len(blobContent)), resp.Header().Get("Range")) |
|
|
|
|
|
|
|
|
|
|
|
pbu, err = packages_model.GetBlobUploadByID(db.DefaultContext, uuid) |
|
|
|
pbu, err = packages_model.GetBlobUploadByID(db.DefaultContext, uuid) |
|
|
|
assert.NoError(t, err) |
|
|
|
assert.NoError(t, err) |
|
|
|
assert.EqualValues(t, len(blobContent), pbu.BytesReceived) |
|
|
|
assert.EqualValues(t, len(blobContent), pbu.BytesReceived) |
|
|
|
|
|
|
|
|
|
|
|
uploadURL = resp.Header().Get("Location") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
req = NewRequest(t, "PUT", fmt.Sprintf("%s?digest=%s", setting.AppURL+uploadURL[1:], blobDigest)) |
|
|
|
req = NewRequest(t, "PUT", fmt.Sprintf("%s?digest=%s", setting.AppURL+uploadURL[1:], blobDigest)) |
|
|
|
addTokenAuthHeader(req, userToken) |
|
|
|
addTokenAuthHeader(req, userToken) |
|
|
|
resp = MakeRequest(t, req, http.StatusCreated) |
|
|
|
resp = MakeRequest(t, req, http.StatusCreated) |
|
|
|
|
|
|
|
|
|
|
|
assert.Equal(t, fmt.Sprintf("/v2/%s/%s/blobs/%s", user.Name, image, blobDigest), resp.Header().Get("Location")) |
|
|
|
assert.Equal(t, fmt.Sprintf("/v2/%s/%s/blobs/%s", user.Name, image, blobDigest), resp.Header().Get("Location")) |
|
|
|
assert.Equal(t, blobDigest, resp.Header().Get("Docker-Content-Digest")) |
|
|
|
assert.Equal(t, blobDigest, resp.Header().Get("Docker-Content-Digest")) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
t.Run("Cancel", func(t *testing.T) { |
|
|
|
|
|
|
|
defer tests.PrintCurrentTest(t)() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
req := NewRequest(t, "POST", fmt.Sprintf("%s/blobs/uploads", url)) |
|
|
|
|
|
|
|
addTokenAuthHeader(req, userToken) |
|
|
|
|
|
|
|
resp := MakeRequest(t, req, http.StatusAccepted) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
uuid := resp.Header().Get("Docker-Upload-Uuid") |
|
|
|
|
|
|
|
assert.NotEmpty(t, uuid) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
uploadURL := resp.Header().Get("Location") |
|
|
|
|
|
|
|
assert.NotEmpty(t, uploadURL) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
req = NewRequest(t, "GET", setting.AppURL+uploadURL[1:]) |
|
|
|
|
|
|
|
addTokenAuthHeader(req, userToken) |
|
|
|
|
|
|
|
resp = MakeRequest(t, req, http.StatusNoContent) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assert.Equal(t, uuid, resp.Header().Get("Docker-Upload-Uuid")) |
|
|
|
|
|
|
|
assert.Equal(t, "0-0", resp.Header().Get("Range")) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
req = NewRequest(t, "DELETE", setting.AppURL+uploadURL[1:]) |
|
|
|
|
|
|
|
addTokenAuthHeader(req, userToken) |
|
|
|
|
|
|
|
MakeRequest(t, req, http.StatusNoContent) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
req = NewRequest(t, "GET", setting.AppURL+uploadURL[1:]) |
|
|
|
|
|
|
|
addTokenAuthHeader(req, userToken) |
|
|
|
|
|
|
|
MakeRequest(t, req, http.StatusNotFound) |
|
|
|
|
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
for _, tag := range tags { |
|
|
|
for _, tag := range tags { |
|
|
|