@@ -33,6 +33,21 @@ func TestPinActions(t *testing.T) {
3333 }
3434 ]` ))
3535
36+ httpmock .RegisterResponder ("GET" , "https://api.github.com/repos/evans/shield/commits/v1" ,
37+ httpmock .NewStringResponder (200 , `a700eac5bf2a1c7a8cb6da0c13f93ed96fd53dbd` ))
38+
39+ httpmock .RegisterResponder ("GET" , "https://api.github.com/repos/evans/shield/git/matching-refs/tags/v1." ,
40+ httpmock .NewStringResponder (200 ,
41+ `[
42+ {
43+ "ref": "refs/tags/v1.0.3",
44+ "object": {
45+ "sha": "a700eac5bf2a1c7a8cb6da0c13f93ed96fd53dbd",
46+ "type": "commit"
47+ }
48+ }
49+ ]` ))
50+
3651 httpmock .RegisterResponder ("GET" , "https://api.github.com/repos/actions/checkout/commits/master" ,
3752 httpmock .NewStringResponder (200 , `61b9e3751b92087fd0b06925ba6dd6314e06f089` ))
3853
@@ -308,10 +323,9 @@ func TestPinActions(t *testing.T) {
308323 {fileName : "actionwithcomment.yml" , wantUpdated : true , pinToImmutable : true },
309324 {fileName : "repeatedactionwithcomment.yml" , wantUpdated : true , pinToImmutable : true },
310325 {fileName : "immutableaction-1.yml" , wantUpdated : true , pinToImmutable : true },
311- {fileName : "exemptaction.yml" , wantUpdated : true , exemptedActions : []string {"actions/checkout" , "rohith/*" }, pinToImmutable : true },
326+ {fileName : "exemptaction.yml" , wantUpdated : true , exemptedActions : []string {"actions/checkout" , "rohith/*" , "praveen/*" , "aman-*/*" , "*/seperate*" , "starc/*" }, pinToImmutable : true },
312327 {fileName : "donotpintoimmutable.yml" , wantUpdated : true , pinToImmutable : false },
313328 {fileName : "invertedcommas.yml" , wantUpdated : true , pinToImmutable : false },
314- {fileName : "pinusingmap.yml" , wantUpdated : true , pinToImmutable : true },
315329 }
316330 for _ , tt := range tests {
317331
@@ -330,6 +344,7 @@ func TestPinActions(t *testing.T) {
330344 actionCommitMap = map [string ]string {
331345 "peter-evans-test/close-issue@v1" : "a700eac5bf2a1c7a8cb6da0c13f93ed96fd53vam" ,
332346 "peter-check/[email protected] " :
"a700eac5bf2a1c7a8cb6da0c13f93ed96fd53tom" ,
347+ "evans/shield-test/@v1.2.5" : "a700eac5bf2a1c7a8cb6da0c13f93ed96fd53cat" ,
333348 }
334349 }
335350
@@ -374,3 +389,36 @@ func Test_isAbsolute(t *testing.T) {
374389 })
375390 }
376391}
392+
393+ func TestActionExists (t * testing.T ) {
394+ result := ActionExists ("actions/checkout" , []string {"actions/checkout" })
395+ t .Log (result )
396+ if ! result {
397+ t .Errorf ("ActionExists returned false for actions/checkout" )
398+ }
399+
400+ result = ActionExists ("actions/checkout" , []string {"actions/*" })
401+ t .Log (result )
402+ if ! result {
403+ t .Errorf ("ActionExists returned false for actions/checkout" )
404+ }
405+
406+ result = ActionExists ("actions/checkout/something" , []string {"actions/*" })
407+ t .Log (result )
408+ if ! result {
409+ t .Errorf ("ActionExists returned true for actions/checkout/something" )
410+ }
411+
412+ result = ActionExists ("step-security/checkout/something" , []string {"step-*/*" })
413+ t .Log (result )
414+ if ! result {
415+ t .Errorf ("ActionExists returned true for actions/checkout/something" )
416+ }
417+
418+ result = ActionExists ("step-security/checkout-release/something" , []string {"*/checkout-*" })
419+ t .Log (result )
420+ if ! result {
421+ t .Errorf ("ActionExists returned true for actions/checkout/something" )
422+ }
423+
424+ }
0 commit comments