forked from go-gitea/gitea
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'giteaofficial/main'
* giteaofficial/main: (29 commits) [skip ci] Updated translations via Crowdin Support localized README (go-gitea#20508) Clean up and fix clone button script (go-gitea#20415) Add disable download source configuration (go-gitea#20548) Fix default merge style (go-gitea#20564) Update login methods in package docs (go-gitea#20561) Add missing Tabs on organisation/package view (Frontport go-gitea#20539) (go-gitea#20540) [skip ci] Updated licenses and gitignores Add setting `SQLITE_JOURNAL_MODE` to enable WAL (go-gitea#20535) Rework file highlight rendering and fix yaml copy-paste (go-gitea#19967) Add new API endpoints for push mirrors management (go-gitea#19841) WebAuthn CredentialID field needs to be increased in size (go-gitea#20530) Add latest commit's SHA to content response (go-gitea#20398) Improve token and secret key generation docs (go-gitea#20387) [skip ci] Updated translations via Crowdin Rework raw file http header logic (go-gitea#20484) Update lunny/levelqueue to prevent NPE when reads are performed after close (go-gitea#20534) Added guidance on file to choose to download (go-gitea#20474) [skip ci] Updated translations via Crowdin Ensure that all unmerged files are merged when conflict checking (go-gitea#20528) ...
- Loading branch information
Showing
139 changed files
with
3,690 additions
and
797 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,7 @@ import ( | |
|
||
func TestPackageContainer(t *testing.T) { | ||
defer prepareTestEnv(t)() | ||
|
||
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2}).(*user_model.User) | ||
|
||
has := func(l packages_model.PackagePropertyList, name string) bool { | ||
|
@@ -37,6 +38,15 @@ func TestPackageContainer(t *testing.T) { | |
} | ||
return false | ||
} | ||
getAllByName := func(l packages_model.PackagePropertyList, name string) []string { | ||
values := make([]string, 0, len(l)) | ||
for _, pp := range l { | ||
if pp.Name == name { | ||
values = append(values, pp.Value) | ||
} | ||
} | ||
return values | ||
} | ||
|
||
images := []string{"test", "te/st"} | ||
tags := []string{"latest", "main"} | ||
|
@@ -67,7 +77,7 @@ func TestPackageContainer(t *testing.T) { | |
Token string `json:"token"` | ||
} | ||
|
||
authenticate := []string{`Bearer realm="` + setting.AppURL + `v2/token"`} | ||
authenticate := []string{`Bearer realm="` + setting.AppURL + `v2/token",service="container_registry",scope="*"`} | ||
|
||
t.Run("Anonymous", func(t *testing.T) { | ||
defer PrintCurrentTest(t)() | ||
|
@@ -237,7 +247,8 @@ func TestPackageContainer(t *testing.T) { | |
assert.Nil(t, pd.SemVer) | ||
assert.Equal(t, image, pd.Package.Name) | ||
assert.Equal(t, tag, pd.Version.Version) | ||
assert.True(t, has(pd.Properties, container_module.PropertyManifestTagged)) | ||
assert.ElementsMatch(t, []string{strings.ToLower(user.LowerName + "/" + image)}, getAllByName(pd.PackageProperties, container_module.PropertyRepository)) | ||
assert.True(t, has(pd.VersionProperties, container_module.PropertyManifestTagged)) | ||
|
||
assert.IsType(t, &container_module.Metadata{}, pd.Metadata) | ||
metadata := pd.Metadata.(*container_module.Metadata) | ||
|
@@ -331,7 +342,8 @@ func TestPackageContainer(t *testing.T) { | |
assert.Nil(t, pd.SemVer) | ||
assert.Equal(t, image, pd.Package.Name) | ||
assert.Equal(t, untaggedManifestDigest, pd.Version.Version) | ||
assert.False(t, has(pd.Properties, container_module.PropertyManifestTagged)) | ||
assert.ElementsMatch(t, []string{strings.ToLower(user.LowerName + "/" + image)}, getAllByName(pd.PackageProperties, container_module.PropertyRepository)) | ||
assert.False(t, has(pd.VersionProperties, container_module.PropertyManifestTagged)) | ||
|
||
assert.IsType(t, &container_module.Metadata{}, pd.Metadata) | ||
|
||
|
@@ -363,18 +375,10 @@ func TestPackageContainer(t *testing.T) { | |
assert.Nil(t, pd.SemVer) | ||
assert.Equal(t, image, pd.Package.Name) | ||
assert.Equal(t, multiTag, pd.Version.Version) | ||
assert.True(t, has(pd.Properties, container_module.PropertyManifestTagged)) | ||
assert.ElementsMatch(t, []string{strings.ToLower(user.LowerName + "/" + image)}, getAllByName(pd.PackageProperties, container_module.PropertyRepository)) | ||
assert.True(t, has(pd.VersionProperties, container_module.PropertyManifestTagged)) | ||
|
||
getAllByName := func(l packages_model.PackagePropertyList, name string) []string { | ||
values := make([]string, 0, len(l)) | ||
for _, pp := range l { | ||
if pp.Name == name { | ||
values = append(values, pp.Value) | ||
} | ||
} | ||
return values | ||
} | ||
assert.ElementsMatch(t, []string{manifestDigest, untaggedManifestDigest}, getAllByName(pd.Properties, container_module.PropertyManifestReference)) | ||
assert.ElementsMatch(t, []string{manifestDigest, untaggedManifestDigest}, getAllByName(pd.VersionProperties, container_module.PropertyManifestReference)) | ||
|
||
assert.IsType(t, &container_module.Metadata{}, pd.Metadata) | ||
metadata := pd.Metadata.(*container_module.Metadata) | ||
|
@@ -536,4 +540,56 @@ func TestPackageContainer(t *testing.T) { | |
}) | ||
}) | ||
} | ||
|
||
t.Run("OwnerNameChange", func(t *testing.T) { | ||
defer PrintCurrentTest(t)() | ||
|
||
checkCatalog := func(owner string) func(t *testing.T) { | ||
return func(t *testing.T) { | ||
defer PrintCurrentTest(t)() | ||
|
||
req := NewRequest(t, "GET", fmt.Sprintf("%sv2/_catalog", setting.AppURL)) | ||
addTokenAuthHeader(req, userToken) | ||
resp := MakeRequest(t, req, http.StatusOK) | ||
|
||
type RepositoryList struct { | ||
Repositories []string `json:"repositories"` | ||
} | ||
|
||
repoList := &RepositoryList{} | ||
DecodeJSON(t, resp, &repoList) | ||
|
||
assert.Len(t, repoList.Repositories, len(images)) | ||
names := make([]string, 0, len(images)) | ||
for _, image := range images { | ||
names = append(names, strings.ToLower(owner+"/"+image)) | ||
} | ||
assert.ElementsMatch(t, names, repoList.Repositories) | ||
} | ||
} | ||
|
||
t.Run(fmt.Sprintf("Catalog[%s]", user.LowerName), checkCatalog(user.LowerName)) | ||
|
||
session := loginUser(t, user.Name) | ||
|
||
newOwnerName := "newUsername" | ||
|
||
req := NewRequestWithValues(t, "POST", "/user/settings", map[string]string{ | ||
"_csrf": GetCSRF(t, session, "/user/settings"), | ||
"name": newOwnerName, | ||
"email": "[email protected]", | ||
"language": "en-US", | ||
}) | ||
session.MakeRequest(t, req, http.StatusSeeOther) | ||
|
||
t.Run(fmt.Sprintf("Catalog[%s]", newOwnerName), checkCatalog(newOwnerName)) | ||
|
||
req = NewRequestWithValues(t, "POST", "/user/settings", map[string]string{ | ||
"_csrf": GetCSRF(t, session, "/user/settings"), | ||
"name": user.Name, | ||
"email": "[email protected]", | ||
"language": "en-US", | ||
}) | ||
session.MakeRequest(t, req, http.StatusSeeOther) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.