@@ -350,7 +350,7 @@ func TestActionsArtifactV4RunDownloadSinglePublicApi(t *testing.T) {
350350 session := loginUser (t , user .Name )
351351 token := getTokenForLoggedInUser (t , session , auth_model .AccessTokenScopeWriteRepository )
352352
353- // confirm artifact upload via rest api
353+ // confirm artifact can be listed and found by name
354354 req := NewRequestWithBody (t , "GET" , fmt .Sprintf ("/api/v1/repos/%s/actions/runs/792/artifacts?name=artifact-v4-download" , repo .FullName ()), nil ).
355355 AddTokenAuth (token )
356356 resp := MakeRequest (t , req , http .StatusOK )
@@ -360,11 +360,13 @@ func TestActionsArtifactV4RunDownloadSinglePublicApi(t *testing.T) {
360360 assert .NotEmpty (t , listResp .Entries [0 ].ArchiveDownloadURL )
361361 assert .Equal (t , "artifact-v4-download" , listResp .Entries [0 ].Name )
362362
363+ // confirm artifact blob storage url can be retrieved
363364 req = NewRequestWithBody (t , "GET" , listResp .Entries [0 ].ArchiveDownloadURL , nil ).
364365 AddTokenAuth (token )
365366
366367 resp = MakeRequest (t , req , http .StatusFound )
367368
369+ // confirm artifact can be downloaded and has expected content
368370 req = NewRequestWithBody (t , "GET" , resp .Header ().Get ("Location" ), nil ).
369371 AddTokenAuth (token )
370372 resp = MakeRequest (t , req , http .StatusOK )
@@ -381,7 +383,7 @@ func TestActionsArtifactV4DownloadSinglePublicApi(t *testing.T) {
381383 session := loginUser (t , user .Name )
382384 token := getTokenForLoggedInUser (t , session , auth_model .AccessTokenScopeWriteRepository )
383385
384- // confirm artifact upload via rest api
386+ // confirm artifact can be listed and found by name
385387 req := NewRequestWithBody (t , "GET" , fmt .Sprintf ("/api/v1/repos/%s/actions/artifacts?name=artifact-v4-download" , repo .FullName ()), nil ).
386388 AddTokenAuth (token )
387389 resp := MakeRequest (t , req , http .StatusOK )
@@ -391,11 +393,13 @@ func TestActionsArtifactV4DownloadSinglePublicApi(t *testing.T) {
391393 assert .NotEmpty (t , listResp .Entries [0 ].ArchiveDownloadURL )
392394 assert .Equal (t , "artifact-v4-download" , listResp .Entries [0 ].Name )
393395
396+ // confirm artifact blob storage url can be retrieved
394397 req = NewRequestWithBody (t , "GET" , listResp .Entries [0 ].ArchiveDownloadURL , nil ).
395398 AddTokenAuth (token )
396399
397400 resp = MakeRequest (t , req , http .StatusFound )
398401
402+ // confirm artifact can be downloaded and has expected content
399403 req = NewRequestWithBody (t , "GET" , resp .Header ().Get ("Location" ), nil ).
400404 AddTokenAuth (token )
401405 resp = MakeRequest (t , req , http .StatusOK )
@@ -411,7 +415,7 @@ func TestActionsArtifactV4ListAndGetPublicApi(t *testing.T) {
411415 session := loginUser (t , user .Name )
412416 token := getTokenForLoggedInUser (t , session , auth_model .AccessTokenScopeWriteRepository )
413417
414- // confirm artifact upload via rest api
418+ // confirm artifact can be listed
415419 req := NewRequestWithBody (t , "GET" , fmt .Sprintf ("/api/v1/repos/%s/actions/artifacts" , repo .FullName ()), nil ).
416420 AddTokenAuth (token )
417421 resp := MakeRequest (t , req , http .StatusOK )
@@ -438,6 +442,62 @@ func TestActionsArtifactV4ListAndGetPublicApi(t *testing.T) {
438442 }
439443}
440444
445+ func TestActionsArtifactV4GetArtifactMismatchedRepoOwnerNotFound (t * testing.T ) {
446+ defer prepareTestEnvActionsArtifacts (t )()
447+
448+ repo := unittest .AssertExistsAndLoadBean (t , & repo_model.Repository {ID : 1 })
449+ user := unittest .AssertExistsAndLoadBean (t , & user_model.User {ID : repo .OwnerID })
450+ session := loginUser (t , user .Name )
451+ token := getTokenForLoggedInUser (t , session , auth_model .AccessTokenScopeWriteRepository )
452+
453+ // confirm artifacts of wrong owner or repo is not visible
454+ req := NewRequestWithBody (t , "GET" , fmt .Sprintf ("/api/v1/repos/%s/actions/artifacts/%d" , repo .FullName (), 22 ), nil ).
455+ AddTokenAuth (token )
456+ MakeRequest (t , req , http .StatusNotFound )
457+ }
458+
459+ func TestActionsArtifactV4DownloadArtifactMismatchedRepoOwnerNotFound (t * testing.T ) {
460+ defer prepareTestEnvActionsArtifacts (t )()
461+
462+ repo := unittest .AssertExistsAndLoadBean (t , & repo_model.Repository {ID : 1 })
463+ user := unittest .AssertExistsAndLoadBean (t , & user_model.User {ID : repo .OwnerID })
464+ session := loginUser (t , user .Name )
465+ token := getTokenForLoggedInUser (t , session , auth_model .AccessTokenScopeWriteRepository )
466+
467+ // confirm artifacts of wrong owner or repo is not visible
468+ req := NewRequestWithBody (t , "GET" , fmt .Sprintf ("/api/v1/repos/%s/actions/artifacts/%d/zip" , repo .FullName (), 22 ), nil ).
469+ AddTokenAuth (token )
470+ MakeRequest (t , req , http .StatusNotFound )
471+ }
472+
473+ func TestActionsArtifactV4DownloadArtifactCorrectRepoOwnerFound (t * testing.T ) {
474+ defer prepareTestEnvActionsArtifacts (t )()
475+
476+ repo := unittest .AssertExistsAndLoadBean (t , & repo_model.Repository {ID : 4 })
477+ user := unittest .AssertExistsAndLoadBean (t , & user_model.User {ID : repo .OwnerID })
478+ session := loginUser (t , user .Name )
479+ token := getTokenForLoggedInUser (t , session , auth_model .AccessTokenScopeWriteRepository )
480+
481+ // confirm artifacts of wrong owner or repo is not visible
482+ req := NewRequestWithBody (t , "GET" , fmt .Sprintf ("/api/v1/repos/%s/actions/artifacts/%d/zip" , repo .FullName (), 22 ), nil ).
483+ AddTokenAuth (token )
484+ MakeRequest (t , req , http .StatusFound )
485+ }
486+
487+ func TestActionsArtifactV4DownloadRawArtifactMismatchedRepoOwnerNotFound (t * testing.T ) {
488+ defer prepareTestEnvActionsArtifacts (t )()
489+
490+ repo := unittest .AssertExistsAndLoadBean (t , & repo_model.Repository {ID : 1 })
491+ user := unittest .AssertExistsAndLoadBean (t , & user_model.User {ID : repo .OwnerID })
492+ session := loginUser (t , user .Name )
493+ token := getTokenForLoggedInUser (t , session , auth_model .AccessTokenScopeWriteRepository )
494+
495+ // confirm artifacts of wrong owner or repo is not visible
496+ req := NewRequestWithBody (t , "GET" , fmt .Sprintf ("/api/v1/repos/%s/actions/artifacts/%d/zip/raw" , repo .FullName (), 22 ), nil ).
497+ AddTokenAuth (token )
498+ MakeRequest (t , req , http .StatusNotFound )
499+ }
500+
441501func TestActionsArtifactV4Delete (t * testing.T ) {
442502 defer prepareTestEnvActionsArtifacts (t )()
443503
0 commit comments