@@ -115,13 +115,14 @@ func (s suffixStubTripper) RoundTrip(r *http.Request) (*http.Response, error) {
115115 }, nil
116116}
117117
118- func Test_githubVerifier_contains (t * testing.T ) {
118+ func Test_githubVerifier_contains_codeql_v1 (t * testing.T ) {
119119 t .Parallel ()
120120 httpClient := http.Client {
121121 Transport : suffixStubTripper {
122122 responsePaths : map [string ]string {
123123 "codeql-action" : "./testdata/api/github/repository.json" , // api call which finds the default branch
124124 "main...somehash" : "./testdata/api/github/divergent.json" , // doesnt belong to default branch
125+ "v2...somehash" : "./testdata/api/github/divergent.json" , // doesnt belong to releases/v2 branch
125126 "v1...somehash" : "./testdata/api/github/containsCommit.json" , // belongs to releases/v1 branch
126127 },
127128 },
@@ -140,6 +141,31 @@ func Test_githubVerifier_contains(t *testing.T) {
140141 }
141142}
142143
144+ func Test_githubVerifier_contains_codeql_v2 (t * testing.T ) {
145+ t .Parallel ()
146+ httpClient := http.Client {
147+ Transport : suffixStubTripper {
148+ responsePaths : map [string ]string {
149+ "codeql-action" : "./testdata/api/github/repository.json" , // api call which finds the default branch
150+ "main...somehash" : "./testdata/api/github/divergent.json" , // doesnt belong to default branch
151+ "v2...somehash" : "./testdata/api/github/containsCommit.json" , // belongs to releases/v2 branch
152+ },
153+ },
154+ }
155+ client := github .NewClient (& httpClient )
156+ gv := githubVerifier {
157+ ctx : context .Background (),
158+ client : client ,
159+ }
160+ got , err := gv .contains ("github" , "codeql-action" , "somehash" )
161+ if err != nil {
162+ t .Fatalf ("unexpected error: %v" , err )
163+ }
164+ if got != true {
165+ t .Errorf ("expected to contain hash, but it didnt" )
166+ }
167+ }
168+
143169func FuzzVerifyWorkflow (f * testing.F ) {
144170 testfiles := []string {
145171 "testdata/workflow-valid.yml" ,
0 commit comments