Skip to content

Commit

Permalink
Added some more cases to the tests for chars encoding (#3758)
Browse files Browse the repository at this point in the history
Signed-off-by: Rafa Castelblanque <rcastelblanq@vmware.com>
  • Loading branch information
Rafa Castelblanque committed Dec 24, 2021
1 parent 8c6f1d4 commit cbe758e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cmd/asset-syncer/server/testdata/helm-index-spaces.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,9 @@ entries:
chart-without-spaces:
- appVersion: v2
name: "chart-without-spaces"
chart-with-special-chars-1:
- appVersion: v3
name: "chart\x23with\x23hashes"
chart-with-special-chars-4:
- appVersion: v1
name: "chart\x24with\x24chars"
23 changes: 23 additions & 0 deletions cmd/asset-syncer/server/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1347,6 +1347,15 @@ func TestUnescapeChartsData(t *testing.T) {
{Name: "test/foo bar"},
},
},
{
"chart with encoded chars in name",
[]models.Chart{
{Name: "foo%23bar%2ebar"},
},
[]models.Chart{
{Name: "foo#bar.bar"},
},
},
}
for _, tt := range tests {
t.Run(tt.description, func(t *testing.T) {
Expand All @@ -1364,13 +1373,27 @@ func TestHelmRepoAppliesUnescape(t *testing.T) {
repoIndexYAMLBytes, _ := ioutil.ReadFile("testdata/helm-index-spaces.yaml")
repoIndexYAML := string(repoIndexYAMLBytes)
expectedCharts := []models.Chart{
{
ID: "test/chart$with$chars",
Name: "chart$with$chars",
Repo: expectedRepo,
Maintainers: []chart.Maintainer{},
ChartVersions: []models.ChartVersion{{AppVersion: "v1"}},
},
{
ID: "test/chart with spaces",
Name: "chart with spaces",
Repo: expectedRepo,
Maintainers: []chart.Maintainer{},
ChartVersions: []models.ChartVersion{{AppVersion: "v1"}},
},
{
ID: "test/chart#with#hashes",
Name: "chart#with#hashes",
Repo: expectedRepo,
Maintainers: []chart.Maintainer{},
ChartVersions: []models.ChartVersion{{AppVersion: "v3"}},
},
{
ID: "test/chart-without-spaces",
Name: "chart-without-spaces",
Expand Down

0 comments on commit cbe758e

Please sign in to comment.