@@ -90,7 +90,7 @@ func TestImageRegistryController_Sync_PendingOrNoStatus(t *testing.T) {
9090 Username : "test" ,
9191 Password : "test" ,
9292 },
93- Repository : "neutree " ,
93+ Repository : "" ,
9494 URL : "http://test" ,
9595 },
9696 }
@@ -109,7 +109,7 @@ func TestImageRegistryController_Sync_PendingOrNoStatus(t *testing.T) {
109109 Username : "test" ,
110110 Password : "test" ,
111111 },
112- Repository : "neutree " ,
112+ Repository : "" ,
113113 URL : "http://test" ,
114114 },
115115 }
@@ -122,17 +122,17 @@ func TestImageRegistryController_Sync_PendingOrNoStatus(t *testing.T) {
122122 wantErr bool
123123 }{
124124 {
125- name : "Pending/NoStatus -> Connected (image service list tags success)" ,
125+ name : "Pending/NoStatus -> Connected (check pull permission success)" ,
126126 input : testImageRegistry (),
127127 mockSetup : func (input * v1.ImageRegistry , s * storagemocks.MockStorage , imageSvc * registrymocks.MockImageService ) {
128- imageSvc .On ("ListImageTags " , mock .Anything , mock .Anything ).Run (func (args mock.Arguments ) {
128+ imageSvc .On ("CheckPullPermission " , mock .Anything , mock .Anything ).Run (func (args mock.Arguments ) {
129129 image := args .Get (0 ).(string )
130130 assert .Equal (t , "test/neutree/neutree-serve" , image )
131131 arg := args .Get (1 ).(authn.Authenticator )
132132 authConfig , _ := arg .Authorization ()
133133 assert .Equal (t , input .Spec .AuthConfig .Username , authConfig .Username )
134134 assert .Equal (t , input .Spec .AuthConfig .Password , authConfig .Password )
135- }).Return (nil , nil )
135+ }).Return (true , nil )
136136 s .On ("UpdateImageRegistry" , "1" , mock .Anything ).Run (func (args mock.Arguments ) {
137137 arg := args .Get (1 ).(* v1.ImageRegistry )
138138 assert .Equal (t , v1 .ImageRegistryPhaseCONNECTED , arg .Status .Phase )
@@ -141,17 +141,17 @@ func TestImageRegistryController_Sync_PendingOrNoStatus(t *testing.T) {
141141 wantErr : false ,
142142 },
143143 {
144- name : "Pending/NoStatus -> Failed (image service list tags failed)" ,
144+ name : "Pending/NoStatus -> Failed (check pull permission failed)" ,
145145 input : testImageRegistry (),
146146 mockSetup : func (input * v1.ImageRegistry , s * storagemocks.MockStorage , imageSvc * registrymocks.MockImageService ) {
147- imageSvc .On ("ListImageTags " , mock .Anything , mock .Anything ).Run (func (args mock.Arguments ) {
147+ imageSvc .On ("CheckPullPermission " , mock .Anything , mock .Anything ).Run (func (args mock.Arguments ) {
148148 image := args .Get (0 ).(string )
149149 assert .Equal (t , "test/neutree/neutree-serve" , image )
150150 arg := args .Get (1 ).(authn.Authenticator )
151151 authConfig , _ := arg .Authorization ()
152152 assert .Equal (t , input .Spec .AuthConfig .Username , authConfig .Username )
153153 assert .Equal (t , input .Spec .AuthConfig .Password , authConfig .Password )
154- }).Return (nil , assert .AnError )
154+ }).Return (false , assert .AnError )
155155 s .On ("UpdateImageRegistry" , "1" , mock .Anything ).Run (func (args mock.Arguments ) {
156156 arg := args .Get (1 ).(* v1.ImageRegistry )
157157 assert .Equal (t , v1 .ImageRegistryPhaseFAILED , arg .Status .Phase )
@@ -204,7 +204,7 @@ func TestImageRegistryController_Sync_Conneted(t *testing.T) {
204204 Password : "test" ,
205205 },
206206 URL : "http://test" ,
207- Repository : "neutree " ,
207+ Repository : "" ,
208208 },
209209 Status : & v1.ImageRegistryStatus {Phase : v1 .ImageRegistryPhaseCONNECTED },
210210 }
@@ -223,7 +223,7 @@ func TestImageRegistryController_Sync_Conneted(t *testing.T) {
223223 Password : "test" ,
224224 },
225225 URL : "http://test" ,
226- Repository : "neutree " ,
226+ Repository : "" ,
227227 },
228228 Status : & v1.ImageRegistryStatus {Phase : v1 .ImageRegistryPhaseCONNECTED },
229229 }
@@ -236,32 +236,32 @@ func TestImageRegistryController_Sync_Conneted(t *testing.T) {
236236 wantErr bool
237237 }{
238238 {
239- name : "Connected -> Connected (image service list tags success)" ,
239+ name : "Connected -> Connected (check pull permission success)" ,
240240 input : testImageRegistry (),
241241 mockSetup : func (input * v1.ImageRegistry , s * storagemocks.MockStorage , imageSvc * registrymocks.MockImageService ) {
242- imageSvc .On ("ListImageTags " , mock .Anything , mock .Anything ).Run (func (args mock.Arguments ) {
242+ imageSvc .On ("CheckPullPermission " , mock .Anything , mock .Anything ).Run (func (args mock.Arguments ) {
243243 image := args .Get (0 ).(string )
244244 assert .Equal (t , "test/neutree/neutree-serve" , image )
245245 arg := args .Get (1 ).(authn.Authenticator )
246246 authConfig , _ := arg .Authorization ()
247247 assert .Equal (t , input .Spec .AuthConfig .Username , authConfig .Username )
248248 assert .Equal (t , input .Spec .AuthConfig .Password , authConfig .Password )
249- }).Return (nil , nil )
249+ }).Return (true , nil )
250250 },
251251 wantErr : false ,
252252 },
253253 {
254- name : "Connected -> Failed (image service list tags failed)" ,
254+ name : "Connected -> Failed (check pull permission failed)" ,
255255 input : testImageRegistry (),
256256 mockSetup : func (input * v1.ImageRegistry , s * storagemocks.MockStorage , imageSvc * registrymocks.MockImageService ) {
257- imageSvc .On ("ListImageTags " , mock .Anything , mock .Anything ).Run (func (args mock.Arguments ) {
257+ imageSvc .On ("CheckPullPermission " , mock .Anything , mock .Anything ).Run (func (args mock.Arguments ) {
258258 image := args .Get (0 ).(string )
259259 assert .Equal (t , "test/neutree/neutree-serve" , image )
260260 arg := args .Get (1 ).(authn.Authenticator )
261261 authConfig , _ := arg .Authorization ()
262262 assert .Equal (t , input .Spec .AuthConfig .Username , authConfig .Username )
263263 assert .Equal (t , input .Spec .AuthConfig .Password , authConfig .Password )
264- }).Return (nil , assert .AnError )
264+ }).Return (false , assert .AnError )
265265 s .On ("UpdateImageRegistry" , "1" , mock .Anything ).Run (func (args mock.Arguments ) {
266266 arg := args .Get (1 ).(* v1.ImageRegistry )
267267 assert .Equal (t , v1 .ImageRegistryPhaseFAILED , arg .Status .Phase )
@@ -315,7 +315,7 @@ func TestImageRegistryController_Sync_Failed(t *testing.T) {
315315 Username : "test" ,
316316 Password : "test" ,
317317 },
318- Repository : "neutree " ,
318+ Repository : "" ,
319319 URL : "http://test" ,
320320 },
321321 Status : & v1.ImageRegistryStatus {Phase : v1 .ImageRegistryPhaseFAILED },
@@ -334,7 +334,7 @@ func TestImageRegistryController_Sync_Failed(t *testing.T) {
334334 Username : "test" ,
335335 Password : "test" ,
336336 },
337- Repository : "neutree " ,
337+ Repository : "" ,
338338 URL : "http://test" ,
339339 },
340340 Status : & v1.ImageRegistryStatus {Phase : v1 .ImageRegistryPhaseFAILED },
@@ -348,17 +348,17 @@ func TestImageRegistryController_Sync_Failed(t *testing.T) {
348348 wantErr bool
349349 }{
350350 {
351- name : "Failed -> Connected (image service list tags success)" ,
351+ name : "Failed -> Connected (check pull permission success)" ,
352352 input : testImageRegistry (),
353353 mockSetup : func (input * v1.ImageRegistry , s * storagemocks.MockStorage , imageSvc * registrymocks.MockImageService ) {
354- imageSvc .On ("ListImageTags " , mock .Anything , mock .Anything ).Run (func (args mock.Arguments ) {
354+ imageSvc .On ("CheckPullPermission " , mock .Anything , mock .Anything ).Run (func (args mock.Arguments ) {
355355 image := args .Get (0 ).(string )
356356 assert .Equal (t , "test/neutree/neutree-serve" , image )
357357 arg := args .Get (1 ).(authn.Authenticator )
358358 authConfig , _ := arg .Authorization ()
359359 assert .Equal (t , input .Spec .AuthConfig .Username , authConfig .Username )
360360 assert .Equal (t , input .Spec .AuthConfig .Password , authConfig .Password )
361- }).Return (nil , nil )
361+ }).Return (true , nil )
362362 s .On ("UpdateImageRegistry" , "1" , mock .Anything ).Run (func (args mock.Arguments ) {
363363 arg := args .Get (1 ).(* v1.ImageRegistry )
364364 assert .Equal (t , v1 .ImageRegistryPhaseCONNECTED , arg .Status .Phase )
@@ -367,17 +367,17 @@ func TestImageRegistryController_Sync_Failed(t *testing.T) {
367367 wantErr : false ,
368368 },
369369 {
370- name : "Failed -> Failed (image service list tags failed)" ,
370+ name : "Failed -> Failed (check pull permission failed)" ,
371371 input : testImageRegistry (),
372372 mockSetup : func (input * v1.ImageRegistry , s * storagemocks.MockStorage , imageSvc * registrymocks.MockImageService ) {
373- imageSvc .On ("ListImageTags " , mock .Anything , mock .Anything ).Run (func (args mock.Arguments ) {
373+ imageSvc .On ("CheckPullPermission " , mock .Anything , mock .Anything ).Run (func (args mock.Arguments ) {
374374 image := args .Get (0 ).(string )
375375 assert .Equal (t , "test/neutree/neutree-serve" , image )
376376 arg := args .Get (1 ).(authn.Authenticator )
377377 authConfig , _ := arg .Authorization ()
378378 assert .Equal (t , input .Spec .AuthConfig .Username , authConfig .Username )
379379 assert .Equal (t , input .Spec .AuthConfig .Password , authConfig .Password )
380- }).Return (nil , assert .AnError )
380+ }).Return (false , assert .AnError )
381381 // Defer block updates status to FAILED when connection fails
382382 s .On ("UpdateImageRegistry" , "1" , mock .Anything ).Run (func (args mock.Arguments ) {
383383 arg := args .Get (1 ).(* v1.ImageRegistry )
0 commit comments