test: check the vendored MADR files against the blob SHAs in NOTICE #864
No reviewers
Labels
No labels
breaking
bug
documentation
enhancement
epic
good first issue
help wanted
refactoring
resolution/duplicate
resolution/invalid
resolution/wontfix
security
severity/critical
severity/high
severity/low
severity/medium
status/abandoned
status/blocked
status/needs-decision
status/needs-info
status/needs-verification
testing
upstream
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
sixfold-space/madtea!864
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "issue-520-madr-notice-blob-sha-test"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
What was wrong
internal/service/adr/madr/NOTICErecords the upstream git blob SHA-1 of each vendored MADR 4.0.0 file. It says the files are vendored byte for byte, becauseadr newandadr initwrite them out verbatim. No test checked this. A reformat, a stray edit, or a normalised newline would pass every gate.What changed
I added two test files in
internal/service/adr/madr/. No production code changes.notice_helpers_test.goholds two helpers.gitBlobSHA1computes the git blob id: SHA-1 over the headerblob <len>\x00followed by the bytes. It does not run git, because this repo uses the sha256 object format.parseNoticeRowsreads theNOTICErows that start withtemplate/. It maps each file base name to its SHA-1. It returns an error for a bad SHA-1, a duplicate name, a row with the wrong field count, or a table with no rows.notice_test.goholds the tests.What the tests cover
TestNoticeBlobSHAshashes each vendored file from disk and from the embedded bytes (TemplateBare,Template,Record0000). It compares both hashes with the SHA inNOTICE. A mismatch fails with the file name and both hashes. It also checks that the embedded bytes equal the file on disk. It fails whenNOTICEdoes not list exactly the*.mdfiles in the directory, soNOTICEand the files must change together.TestGitBlobSHA1locks the helper against knowngit hash-objectids for an empty file and forhello\n. It also shows that flipping one bit ofadr-template-bare.mdchanges the hash. This covers the acceptance point that a one-byte change fails the check.TestParseNoticeRowschecks that a short SHA, a missing SHA, a duplicate row, and a table with no rows are errors.Refs #520
./scripts/gate.shpasses on this commit.Closes #520