package catalogue import ( "testing" ) // An archive pinned by URL and sha256 (novox/hq ADR 0316 §2, §6): the vendor's file, mirrored by the build // seat, never a copy in the repository. const pinnedSum = "38dd24890a66b4cf9a45bc24e15192e00c26b929e1bb8df7974c16a4539129e2" func upstreamManifest(artifact string) string { return `{"module":"a","version":"1","build":{"artifacts":[` + artifact + `]}}` } func TestAnArchivePinnedByURLAndSha256IsAccepted(t *testing.T) { for _, a := range []string{ `{"name":"archive","kind":"archive","url":"https://vendor.example.org/release-1.tar.xz","sha256":"` + pinnedSum + `","version":"1.0","within":"release"}`, `{"name":"addon","kind":"archive","url":"https://vendor.example.org/addon.xpi","sha256":"` + pinnedSum + `","version":"1.5.6.1","file":"addon.xpi"}`, } { if _, err := decodeForTest([]byte(upstreamManifest(a))); err != nil { t.Errorf("%s was refused: %v", a, err) } } }