1717package server
1818
1919import (
20- "context"
2120 "testing"
2221
2322 "github.com/containerd/containerd"
2423 "github.com/containerd/containerd/images"
2524 "github.com/containerd/containerd/metadata"
26- imagespec "github.com/opencontainers/image-spec/specs-go/v1"
2725 "github.com/stretchr/testify/assert"
2826 "github.com/stretchr/testify/require"
2927 runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
@@ -39,6 +37,7 @@ func TestListImages(t *testing.T) {
3937 imageLabelConfigDigest : "sha256:1123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" ,
4038 imageLabelSize : "1000" ,
4139 imageLabelKey : imageLabelValue ,
40+ imageLabelUser : "root" ,
4241 },
4342 },
4443 {
@@ -48,6 +47,7 @@ func TestListImages(t *testing.T) {
4847 imageLabelConfigDigest : "sha256:1123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" ,
4948 imageLabelSize : "1000" ,
5049 imageLabelKey : imageLabelValue ,
50+ imageLabelUser : "root" ,
5151 },
5252 },
5353 {
@@ -57,6 +57,7 @@ func TestListImages(t *testing.T) {
5757 imageLabelConfigDigest : "sha256:1123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" ,
5858 imageLabelSize : "1000" ,
5959 imageLabelKey : imageLabelValue ,
60+ imageLabelUser : "root" ,
6061 },
6162 },
6263 // Image 2
@@ -67,6 +68,7 @@ func TestListImages(t *testing.T) {
6768 imageLabelConfigDigest : "sha256:2123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" ,
6869 imageLabelSize : "2000" ,
6970 imageLabelKey : imageLabelValue ,
71+ imageLabelUser : "1234:1234" ,
7072 },
7173 },
7274 {
@@ -76,6 +78,7 @@ func TestListImages(t *testing.T) {
7678 imageLabelConfigDigest : "sha256:2123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" ,
7779 imageLabelSize : "2000" ,
7880 imageLabelKey : imageLabelValue ,
81+ imageLabelUser : "1234:1234" ,
7982 },
8083 },
8184 {
@@ -85,6 +88,7 @@ func TestListImages(t *testing.T) {
8588 imageLabelConfigDigest : "sha256:2123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" ,
8689 imageLabelSize : "2000" ,
8790 imageLabelKey : imageLabelValue ,
91+ imageLabelUser : "1234:1234" ,
8892 },
8993 },
9094 // Image 3
@@ -95,6 +99,7 @@ func TestListImages(t *testing.T) {
9599 imageLabelConfigDigest : "sha256:3123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" ,
96100 imageLabelSize : "3000" ,
97101 imageLabelKey : imageLabelValue ,
102+ imageLabelUser : "nobody" ,
98103 },
99104 },
100105 {
@@ -104,6 +109,7 @@ func TestListImages(t *testing.T) {
104109 imageLabelConfigDigest : "sha256:3123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" ,
105110 imageLabelSize : "3000" ,
106111 imageLabelKey : imageLabelValue ,
112+ imageLabelUser : "nobody" ,
107113 },
108114 }, {
109115 Name : "gcr.io/library/ubuntu@sha256:e6693c20186f837fc393390135d8a598a96a833917917789d63766cab6c59582" ,
@@ -112,25 +118,11 @@ func TestListImages(t *testing.T) {
112118 imageLabelConfigDigest : "sha256:3123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" ,
113119 imageLabelSize : "3000" ,
114120 imageLabelKey : imageLabelValue ,
121+ imageLabelUser : "nobody" ,
115122 },
116123 },
117124 }
118125
119- getImageSpec = func (ctx context.Context , image containerd.Image ) (imagespec.Image , error ) {
120- switch image .Name () {
121- case "sha256:1123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" , "gcr.io/library/busybox:latest" :
122- return imagespec.Image {Config : imagespec.ImageConfig {User : "root" }}, nil
123- case "sha256:2123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" , "gcr.io/library/alpine:latest" :
124- return imagespec.Image {Config : imagespec.ImageConfig {User : "1234:1234" }}, nil
125- case "sha256:3123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" , "gcr.io/library/ubuntu:latest" :
126- return imagespec.Image {Config : imagespec.ImageConfig {User : "nobody" }}, nil
127- default :
128- t .Fatalf ("unexpected OCI spec request for image %q" , image .Name ())
129- }
130- return imagespec.Image {}, nil
131- }
132- t .Cleanup (func () { getImageSpec = retrieveImageSpec })
133-
134126 expect := []* runtime.Image {
135127 {
136128 Id : "sha256:1123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" ,
0 commit comments