|
5 | 5 | "fmt" |
6 | 6 | "net/http" |
7 | 7 | "os" |
| 8 | + "sort" |
8 | 9 | "strconv" |
9 | 10 | "strings" |
10 | 11 |
|
@@ -61,17 +62,18 @@ var test03ContentDiscovery = func() { |
61 | 62 | SkipIfDisabled(contentDiscovery) |
62 | 63 | RunOnlyIf(runContentDiscoverySetup) |
63 | 64 | for i := 0; i < numTags; i++ { |
64 | | - tag := fmt.Sprintf("test%d", i) |
65 | | - tagList = append(tagList, tag) |
66 | | - req := client.NewRequest(reggie.PUT, "/v2/<name>/manifests/<reference>", |
67 | | - reggie.WithReference(tag)). |
68 | | - SetHeader("Content-Type", "application/vnd.oci.image.manifest.v1+json"). |
69 | | - SetBody(manifests[2].Content) |
70 | | - resp, err := client.Do(req) |
71 | | - Expect(err).To(BeNil()) |
72 | | - Expect(resp.StatusCode()).To(SatisfyAll( |
73 | | - BeNumerically(">=", 200), |
74 | | - BeNumerically("<", 300))) |
| 65 | + for _, tag := range []string{"test" + strconv.Itoa(i), "TEST" + strconv.Itoa(i)} { |
| 66 | + tagList = append(tagList, tag) |
| 67 | + req := client.NewRequest(reggie.PUT, "/v2/<name>/manifests/<reference>", |
| 68 | + reggie.WithReference(tag)). |
| 69 | + SetHeader("Content-Type", "application/vnd.oci.image.manifest.v1+json"). |
| 70 | + SetBody(manifests[2].Content) |
| 71 | + resp, err := client.Do(req) |
| 72 | + Expect(err).To(BeNil()) |
| 73 | + Expect(resp.StatusCode()).To(SatisfyAll( |
| 74 | + BeNumerically(">=", 200), |
| 75 | + BeNumerically("<", 300))) |
| 76 | + } |
75 | 77 | } |
76 | 78 | req := client.NewRequest(reggie.GET, "/v2/<name>/tags/list") |
77 | 79 | resp, err := client.Do(req) |
@@ -253,14 +255,21 @@ var test03ContentDiscovery = func() { |
253 | 255 | }) |
254 | 256 |
|
255 | 257 | g.Context("Test content discovery endpoints (listing tags)", func() { |
256 | | - g.Specify("GET request to list tags should yield 200 response", func() { |
| 258 | + g.Specify("GET request to list tags should yield 200 response and be in sorted order", func() { |
257 | 259 | SkipIfDisabled(contentDiscovery) |
258 | 260 | req := client.NewRequest(reggie.GET, "/v2/<name>/tags/list") |
259 | 261 | resp, err := client.Do(req) |
260 | 262 | Expect(err).To(BeNil()) |
261 | 263 | Expect(resp.StatusCode()).To(Equal(http.StatusOK)) |
262 | 264 | tagList = getTagList(resp) |
263 | 265 | numTags = len(tagList) |
| 266 | + // If the list is not empty, the tags MUST be in lexical order (i.e. case-insensitive alphanumeric order). |
| 267 | + sortedTagListLexical := append([]string{}, tagList...) |
| 268 | + sort.SliceStable(sortedTagListLexical, func(i, j int) bool { return strings.ToLower(sortedTagListLexical[i]) < strings.ToLower(sortedTagListLexical[j]) }) |
| 269 | + // Historically, registries have not been lexical, so allow `sort.Strings` to be valid too. |
| 270 | + sortedTagListAsciibetical := append([]string{}, tagList...) |
| 271 | + sort.Strings(sortedTagListAsciibetical) |
| 272 | + Expect(tagList).To(Or(Equal(sortedTagListLexical), Equal(sortedTagListAsciibetical))) |
264 | 273 | }) |
265 | 274 |
|
266 | 275 | g.Specify("GET number of tags should be limitable by `n` query parameter", func() { |
|
0 commit comments