Skip to content

Commit e3ae3be

Browse files
Balijepalli Vamshi KrishnaBalijepalli Vamshi Krishna
authored andcommitted
add more test cases
1 parent c1b538e commit e3ae3be

File tree

5 files changed

+44
-1
lines changed

5 files changed

+44
-1
lines changed

remediation/workflow/pin/pinactions_test.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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

@@ -293,7 +308,7 @@ func TestPinActions(t *testing.T) {
293308
{fileName: "actionwithcomment.yml", wantUpdated: true, pinToImmutable: true},
294309
{fileName: "repeatedactionwithcomment.yml", wantUpdated: true, pinToImmutable: true},
295310
{fileName: "immutableaction-1.yml", wantUpdated: true, pinToImmutable: true},
296-
{fileName: "exemptaction.yml", wantUpdated: true, exemptedActions: []string{"actions/checkout", "rohith/*", "praveen/*", "aman-*/*", "*/seperate*"}, pinToImmutable: true},
311+
{fileName: "exemptaction.yml", wantUpdated: true, exemptedActions: []string{"actions/checkout", "rohith/*", "praveen/*", "aman-*/*", "*/seperate*", "starc/*"}, pinToImmutable: true},
297312
{fileName: "donotpintoimmutable.yml", wantUpdated: true, pinToImmutable: false},
298313
{fileName: "invertedcommas.yml", wantUpdated: true, pinToImmutable: false},
299314
}

testfiles/pinactions/input/basic.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ jobs:
1111
steps:
1212
- name: Close Issue
1313
uses: peter-evans/close-issue@v1
14+
with:
15+
issue-number: 1
16+
comment: Auto-closing issue
17+
18+
- name: test case
19+
uses: evans/shield/@v1
1420
with:
1521
issue-number: 1
1622
comment: Auto-closing issue

testfiles/pinactions/input/exemptaction.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,14 @@ jobs:
6262
- name: publish on version change 2
6363
id: publish_nuget
6464
uses: smith/seperate/from-version@v2
65+
with:
66+
PROJECT_FILE_PATH: Core/Core.csproj
67+
NUGET_KEY: ${{ secrets.GITHUB_TOKEN }}
68+
NUGET_SOURCE: https://nuget.pkg.github.com/OWNER/index.json
69+
70+
- name: publish on version change 2
71+
id: publish_nuget
72+
uses: starc/swing/from-version/@v2
6573
with:
6674
PROJECT_FILE_PATH: Core/Core.csproj
6775
NUGET_KEY: ${{ secrets.GITHUB_TOKEN }}

testfiles/pinactions/output/basic.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ jobs:
1111
steps:
1212
- name: Close Issue
1313
uses: peter-evans/close-issue@a700eac5bf2a1c7a8cb6da0c13f93ed96fd53dbe # v1.0.3
14+
with:
15+
issue-number: 1
16+
comment: Auto-closing issue
17+
18+
- name: test case
19+
uses: evans/shield/@a700eac5bf2a1c7a8cb6da0c13f93ed96fd53dbd # v1.0.3
1420
with:
1521
issue-number: 1
1622
comment: Auto-closing issue

testfiles/pinactions/output/exemptaction.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,14 @@ jobs:
6262
- name: publish on version change 2
6363
id: publish_nuget
6464
uses: smith/seperate/from-version@v2
65+
with:
66+
PROJECT_FILE_PATH: Core/Core.csproj
67+
NUGET_KEY: ${{ secrets.GITHUB_TOKEN }}
68+
NUGET_SOURCE: https://nuget.pkg.github.com/OWNER/index.json
69+
70+
- name: publish on version change 2
71+
id: publish_nuget
72+
uses: starc/swing/from-version/@v2
6573
with:
6674
PROJECT_FILE_PATH: Core/Core.csproj
6775
NUGET_KEY: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)