Skip to content

Commit 057a6c5

Browse files
committed
add multi subject test
Signed-off-by: William Woodruff <william@yossarian.net>
1 parent 9e82563 commit 057a6c5

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

Library/Homebrew/test/attestation_spec.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,15 @@
3434
} },
3535
]))
3636
end
37+
let(:fake_result_json_resp_multi_subject) do
38+
instance_double(SystemCommand::Result,
39+
stdout: JSON.dump([
40+
{ verificationResult: {
41+
verifiedTimestamps: [{ timestamp: "2024-03-13T00:00:00Z" }],
42+
statement: { subject: [{ name: "nonsense" }, { name: fake_bottle_filename.to_s }] },
43+
} },
44+
]))
45+
end
3746
let(:fake_result_json_resp_backfill) do
3847
digest = Digest::SHA256.hexdigest(fake_bottle_url)
3948
instance_double(SystemCommand::Result,
@@ -234,6 +243,17 @@
234243
described_class.check_core_attestation fake_bottle
235244
end
236245

246+
it "calls gh with args for homebrew-core and handles a multi-subject attestation" do
247+
expect(described_class).to receive(:system_command!)
248+
.with(fake_gh, args: ["attestation", "verify", cached_download, "--repo",
249+
described_class::HOMEBREW_CORE_REPO, "--format", "json"],
250+
env: { "GH_TOKEN" => fake_gh_creds, "GH_HOST" => "github.com" }, secrets: [fake_gh_creds],
251+
print_stderr: false, chdir: HOMEBREW_TEMP)
252+
.and_return(fake_result_json_resp_multi_subject)
253+
254+
described_class.check_core_attestation fake_bottle
255+
end
256+
237257
it "calls gh with args for backfill when homebrew-core attestation is missing" do
238258
expect(described_class).to receive(:system_command!)
239259
.with(fake_gh, args: ["attestation", "verify", cached_download, "--repo",

0 commit comments

Comments
 (0)