diff options
author | Giteabot <teabot@gitea.io> | 2024-05-20 15:10:27 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-20 07:10:27 +0000 |
commit | 3d3123d553826880c06202cade24ea432cd8b7dd (patch) | |
tree | 2b5a6d2895ea9651f82503d1a2c11958b762619d /tests | |
parent | a798a1eb179fb22105c854ebd0f1d4ceb20b6c06 (diff) | |
download | gitea-3d3123d553826880c06202cade24ea432cd8b7dd.tar.gz gitea-3d3123d553826880c06202cade24ea432cd8b7dd.zip |
Avoid 500 panic error when uploading invalid maven package file (#31014) (#31027)
Backport #31014 by wxiaoguang
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/integration/api_packages_maven_test.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/integration/api_packages_maven_test.go b/tests/integration/api_packages_maven_test.go index c7ed554a9d..0466a727b2 100644 --- a/tests/integration/api_packages_maven_test.go +++ b/tests/integration/api_packages_maven_test.go @@ -15,6 +15,7 @@ import ( "code.gitea.io/gitea/models/unittest" user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/packages/maven" + "code.gitea.io/gitea/modules/test" "code.gitea.io/gitea/tests" "github.com/stretchr/testify/assert" @@ -241,4 +242,13 @@ func TestPackageMaven(t *testing.T) { putFile(t, fmt.Sprintf("/%s/maven-metadata.xml", snapshotVersion), "test", http.StatusCreated) putFile(t, fmt.Sprintf("/%s/maven-metadata.xml", snapshotVersion), "test-overwrite", http.StatusCreated) }) + + t.Run("InvalidFile", func(t *testing.T) { + ver := packageVersion + "-invalid" + putFile(t, fmt.Sprintf("/%s/%s", ver, filename), "any invalid content", http.StatusCreated) + req := NewRequestf(t, "GET", "/%s/-/packages/maven/%s-%s/%s", user.Name, groupID, artifactID, ver) + resp := MakeRequest(t, req, http.StatusOK) + assert.Contains(t, resp.Body.String(), "No metadata.") + assert.True(t, test.IsNormalPageCompleted(resp.Body.String())) + }) } |