|
139 | 139 |
|
140 | 140 | expect do |
141 | 141 | klass.check_attestation fake_bottle, |
142 | | - klass::HOMEBREW_CORE_REPO |
143 | | - end.to raise_error(klass::GhAuthNeeded) |
| 142 | + Homebrew::Attestation::HOMEBREW_CORE_REPO |
| 143 | + end.to raise_error(Homebrew::Attestation::GhAuthNeeded) |
144 | 144 | end |
145 | 145 |
|
146 | 146 | it "raises when gh subprocess fails" do |
|
149 | 149 |
|
150 | 150 | expect(klass).to receive(:system_command!) |
151 | 151 | .with(fake_gh, args: ["attestation", "verify", cached_download, "--repo", |
152 | | - klass::HOMEBREW_CORE_REPO, "--format", "json"], |
| 152 | + Homebrew::Attestation::HOMEBREW_CORE_REPO, "--format", "json"], |
153 | 153 | env: { "GH_TOKEN" => fake_gh_creds, "GH_HOST" => "github.com" }, secrets: [fake_gh_creds], |
154 | 154 | print_stderr: false, chdir: HOMEBREW_TEMP) |
155 | 155 | .and_raise(ErrorDuringExecution.new(["foo"], status: fake_error_status)) |
156 | 156 |
|
157 | 157 | expect do |
158 | 158 | klass.check_attestation fake_bottle, |
159 | | - klass::HOMEBREW_CORE_REPO |
160 | | - end.to raise_error(klass::InvalidAttestationError) |
| 159 | + Homebrew::Attestation::HOMEBREW_CORE_REPO |
| 160 | + end.to raise_error(Homebrew::Attestation::InvalidAttestationError) |
161 | 161 | end |
162 | 162 |
|
163 | 163 | it "raises auth error when gh subprocess fails with auth exit code" do |
|
166 | 166 |
|
167 | 167 | expect(klass).to receive(:system_command!) |
168 | 168 | .with(fake_gh, args: ["attestation", "verify", cached_download, "--repo", |
169 | | - klass::HOMEBREW_CORE_REPO, "--format", "json"], |
| 169 | + Homebrew::Attestation::HOMEBREW_CORE_REPO, "--format", "json"], |
170 | 170 | env: { "GH_TOKEN" => fake_gh_creds, "GH_HOST" => "github.com" }, secrets: [fake_gh_creds], |
171 | 171 | print_stderr: false, chdir: HOMEBREW_TEMP) |
172 | 172 | .and_raise(ErrorDuringExecution.new(["foo"], status: fake_auth_status)) |
173 | 173 |
|
174 | 174 | expect do |
175 | 175 | klass.check_attestation fake_bottle, |
176 | | - klass::HOMEBREW_CORE_REPO |
177 | | - end.to raise_error(klass::GhAuthInvalid) |
| 176 | + Homebrew::Attestation::HOMEBREW_CORE_REPO |
| 177 | + end.to raise_error(Homebrew::Attestation::GhAuthInvalid) |
178 | 178 | end |
179 | 179 |
|
180 | 180 | it "raises when gh returns invalid JSON" do |
|
183 | 183 |
|
184 | 184 | expect(klass).to receive(:system_command!) |
185 | 185 | .with(fake_gh, args: ["attestation", "verify", cached_download, "--repo", |
186 | | - klass::HOMEBREW_CORE_REPO, "--format", "json"], |
| 186 | + Homebrew::Attestation::HOMEBREW_CORE_REPO, "--format", "json"], |
187 | 187 | env: { "GH_TOKEN" => fake_gh_creds, "GH_HOST" => "github.com" }, secrets: [fake_gh_creds], |
188 | 188 | print_stderr: false, chdir: HOMEBREW_TEMP) |
189 | 189 | .and_return(fake_result_invalid_json) |
190 | 190 |
|
191 | 191 | expect do |
192 | 192 | klass.check_attestation fake_bottle, |
193 | | - klass::HOMEBREW_CORE_REPO |
194 | | - end.to raise_error(klass::InvalidAttestationError) |
| 193 | + Homebrew::Attestation::HOMEBREW_CORE_REPO |
| 194 | + end.to raise_error(Homebrew::Attestation::InvalidAttestationError) |
195 | 195 | end |
196 | 196 |
|
197 | 197 | it "raises when gh returns other subjects" do |
|
200 | 200 |
|
201 | 201 | expect(klass).to receive(:system_command!) |
202 | 202 | .with(fake_gh, args: ["attestation", "verify", cached_download, "--repo", |
203 | | - klass::HOMEBREW_CORE_REPO, "--format", "json"], |
| 203 | + Homebrew::Attestation::HOMEBREW_CORE_REPO, "--format", "json"], |
204 | 204 | env: { "GH_TOKEN" => fake_gh_creds, "GH_HOST" => "github.com" }, secrets: [fake_gh_creds], |
205 | 205 | print_stderr: false, chdir: HOMEBREW_TEMP) |
206 | 206 | .and_return(fake_json_resp_wrong_sub) |
207 | 207 |
|
208 | 208 | expect do |
209 | 209 | klass.check_attestation fake_bottle, |
210 | | - klass::HOMEBREW_CORE_REPO |
211 | | - end.to raise_error(klass::InvalidAttestationError) |
| 210 | + Homebrew::Attestation::HOMEBREW_CORE_REPO |
| 211 | + end.to raise_error(Homebrew::Attestation::InvalidAttestationError) |
212 | 212 | end |
213 | 213 |
|
214 | 214 | it "checks subject prefix when the bottle is an :all bottle" do |
|
217 | 217 |
|
218 | 218 | expect(klass).to receive(:system_command!) |
219 | 219 | .with(fake_gh, args: ["attestation", "verify", cached_download, "--repo", |
220 | | - klass::HOMEBREW_CORE_REPO, "--format", "json"], |
| 220 | + Homebrew::Attestation::HOMEBREW_CORE_REPO, "--format", "json"], |
221 | 221 | env: { "GH_TOKEN" => fake_gh_creds, "GH_HOST" => "github.com" }, secrets: [fake_gh_creds], |
222 | 222 | print_stderr: false, chdir: HOMEBREW_TEMP) |
223 | 223 | .and_return(fake_result_json_resp) |
224 | 224 |
|
225 | | - klass.check_attestation fake_all_bottle, klass::HOMEBREW_CORE_REPO |
| 225 | + klass.check_attestation fake_all_bottle, Homebrew::Attestation::HOMEBREW_CORE_REPO |
226 | 226 | end |
227 | 227 | end |
228 | 228 |
|
|
238 | 238 | it "calls gh with args for homebrew-core" do |
239 | 239 | expect(klass).to receive(:system_command!) |
240 | 240 | .with(fake_gh, args: ["attestation", "verify", cached_download, "--repo", |
241 | | - klass::HOMEBREW_CORE_REPO, "--format", "json"], |
| 241 | + Homebrew::Attestation::HOMEBREW_CORE_REPO, "--format", "json"], |
242 | 242 | env: { "GH_TOKEN" => fake_gh_creds, "GH_HOST" => "github.com" }, secrets: [fake_gh_creds], |
243 | 243 | print_stderr: false, chdir: HOMEBREW_TEMP) |
244 | 244 | .and_return(fake_result_json_resp) |
|
249 | 249 | it "calls gh with args for homebrew-core and handles a multi-subject attestation" do |
250 | 250 | expect(klass).to receive(:system_command!) |
251 | 251 | .with(fake_gh, args: ["attestation", "verify", cached_download, "--repo", |
252 | | - klass::HOMEBREW_CORE_REPO, "--format", "json"], |
| 252 | + Homebrew::Attestation::HOMEBREW_CORE_REPO, "--format", "json"], |
253 | 253 | env: { "GH_TOKEN" => fake_gh_creds, "GH_HOST" => "github.com" }, secrets: [fake_gh_creds], |
254 | 254 | print_stderr: false, chdir: HOMEBREW_TEMP) |
255 | 255 | .and_return(fake_result_json_resp_multi_subject) |
|
260 | 260 | it "calls gh with args for backfill when homebrew-core attestation is missing" do |
261 | 261 | expect(klass).to receive(:system_command!) |
262 | 262 | .with(fake_gh, args: ["attestation", "verify", cached_download, "--repo", |
263 | | - klass::HOMEBREW_CORE_REPO, "--format", "json"], |
| 263 | + Homebrew::Attestation::HOMEBREW_CORE_REPO, "--format", "json"], |
264 | 264 | env: { "GH_TOKEN" => fake_gh_creds, "GH_HOST" => "github.com" }, secrets: [fake_gh_creds], |
265 | 265 | print_stderr: false, chdir: HOMEBREW_TEMP) |
266 | 266 | .once |
267 | | - .and_raise(klass::MissingAttestationError) |
| 267 | + .and_raise(Homebrew::Attestation::MissingAttestationError) |
268 | 268 |
|
269 | 269 | expect(klass).to receive(:system_command!) |
270 | 270 | .with(fake_gh, args: ["attestation", "verify", cached_download, "--repo", |
271 | | - klass::BACKFILL_REPO, "--format", "json"], |
| 271 | + Homebrew::Attestation::BACKFILL_REPO, "--format", "json"], |
272 | 272 | env: { "GH_TOKEN" => fake_gh_creds, "GH_HOST" => "github.com" }, secrets: [fake_gh_creds], |
273 | 273 | print_stderr: false, chdir: HOMEBREW_TEMP) |
274 | 274 | .and_return(fake_result_json_resp_backfill) |
|
279 | 279 | it "raises when the backfilled attestation is too new" do |
280 | 280 | expect(klass).to receive(:system_command!) |
281 | 281 | .with(fake_gh, args: ["attestation", "verify", cached_download, "--repo", |
282 | | - klass::HOMEBREW_CORE_REPO, "--format", "json"], |
| 282 | + Homebrew::Attestation::HOMEBREW_CORE_REPO, "--format", "json"], |
283 | 283 | env: { "GH_TOKEN" => fake_gh_creds, "GH_HOST" => "github.com" }, secrets: [fake_gh_creds], |
284 | 284 | print_stderr: false, chdir: HOMEBREW_TEMP) |
285 | | - .exactly(klass::ATTESTATION_MAX_RETRIES + 1) |
286 | | - .and_raise(klass::MissingAttestationError) |
| 285 | + .exactly(Homebrew::Attestation::ATTESTATION_MAX_RETRIES + 1) |
| 286 | + .and_raise(Homebrew::Attestation::MissingAttestationError) |
287 | 287 |
|
288 | 288 | expect(klass).to receive(:system_command!) |
289 | 289 | .with(fake_gh, args: ["attestation", "verify", cached_download, "--repo", |
290 | | - klass::BACKFILL_REPO, "--format", "json"], |
| 290 | + Homebrew::Attestation::BACKFILL_REPO, "--format", "json"], |
291 | 291 | env: { "GH_TOKEN" => fake_gh_creds, "GH_HOST" => "github.com" }, secrets: [fake_gh_creds], |
292 | 292 | print_stderr: false, chdir: HOMEBREW_TEMP) |
293 | | - .exactly(klass::ATTESTATION_MAX_RETRIES + 1) |
| 293 | + .exactly(Homebrew::Attestation::ATTESTATION_MAX_RETRIES + 1) |
294 | 294 | .and_return(fake_result_json_resp_too_new) |
295 | 295 |
|
296 | 296 | expect do |
297 | 297 | klass.check_core_attestation fake_bottle |
298 | | - end.to raise_error(klass::InvalidAttestationError) |
| 298 | + end.to raise_error(Homebrew::Attestation::InvalidAttestationError) |
299 | 299 | end |
300 | 300 | end |
301 | 301 | end |
0 commit comments