@@ -115,13 +115,14 @@ func (s suffixStubTripper) RoundTrip(r *http.Request) (*http.Response, error) {
115
115
}, nil
116
116
}
117
117
118
- func Test_githubVerifier_contains (t * testing.T ) {
118
+ func Test_githubVerifier_contains_codeql_v1 (t * testing.T ) {
119
119
t .Parallel ()
120
120
httpClient := http.Client {
121
121
Transport : suffixStubTripper {
122
122
responsePaths : map [string ]string {
123
123
"codeql-action" : "./testdata/api/github/repository.json" , // api call which finds the default branch
124
124
"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
125
126
"v1...somehash" : "./testdata/api/github/containsCommit.json" , // belongs to releases/v1 branch
126
127
},
127
128
},
@@ -140,6 +141,31 @@ func Test_githubVerifier_contains(t *testing.T) {
140
141
}
141
142
}
142
143
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
+
143
169
func FuzzVerifyWorkflow (f * testing.F ) {
144
170
testfiles := []string {
145
171
"testdata/workflow-valid.yml" ,
0 commit comments