aboutsummaryrefslogtreecommitdiffstats
path: root/tests/integration
diff options
context:
space:
mode:
authorWayne Starr <Racer159@users.noreply.github.com>2022-10-24 08:50:22 -0500
committerGitHub <noreply@github.com>2022-10-24 21:50:22 +0800
commit49a4464160254604d2c42b760a901952d8bc3c8b (patch)
treef0367db2ec870b273cb4f6f1fc7c7e93291cc52a /tests/integration
parent0218fa7cf1a7fe1b54835642165243f10b1324d9 (diff)
downloadgitea-49a4464160254604d2c42b760a901952d8bc3c8b.tar.gz
gitea-49a4464160254604d2c42b760a901952d8bc3c8b.zip
Allow for resolution of NPM registry paths that match upstream (#21568)
This PR fixes issue #21567 allowing for package tarball URLs to match the upstream registry (and GitLab/JFrog Artifactory URLs). It uses a regex to parse the filename (which contains the NPM version) and does a fuzzy search to pull it out. The regex was built/expanded from http://json.schemastore.org/package, https://github.com/Masterminds/semver, and https://docs.npmjs.com/cli/v6/using-npm/semver and is testable here: https://regex101.com/r/OydBJq/5 Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Diffstat (limited to 'tests/integration')
-rw-r--r--tests/integration/api_packages_npm_test.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/tests/integration/api_packages_npm_test.go b/tests/integration/api_packages_npm_test.go
index 4fdcf6682e..20412fe727 100644
--- a/tests/integration/api_packages_npm_test.go
+++ b/tests/integration/api_packages_npm_test.go
@@ -127,10 +127,16 @@ func TestPackageNpm(t *testing.T) {
b, _ := base64.StdEncoding.DecodeString(data)
assert.Equal(t, b, resp.Body.Bytes())
+ req = NewRequest(t, "GET", fmt.Sprintf("%s/-/%s", root, filename))
+ req = addTokenAuthHeader(req, token)
+ resp = MakeRequest(t, req, http.StatusOK)
+
+ assert.Equal(t, b, resp.Body.Bytes())
+
pvs, err := packages.GetVersionsByPackageType(db.DefaultContext, user.ID, packages.TypeNpm)
assert.NoError(t, err)
assert.Len(t, pvs, 1)
- assert.Equal(t, int64(1), pvs[0].DownloadCount)
+ assert.Equal(t, int64(2), pvs[0].DownloadCount)
})
t.Run("PackageMetadata", func(t *testing.T) {