Download this file
| 1 | package credits |
| 2 | |
| 3 | import ( |
| 4 | "crypto/sha256" |
| 5 | "encoding/hex" |
| 6 | "encoding/json" |
| 7 | "os" |
| 8 | "testing" |
| 9 | ) |
| 10 | |
| 11 | func TestLucideNoticeMatchesRecordedProvenance(t *testing.T) { |
| 12 | raw, err := os.ReadFile("notices/lucide-provenance.json") |
| 13 | if err != nil { |
| 14 | t.Fatal(err) |
| 15 | } |
| 16 | var record struct { |
| 17 | Source string `json:"source"` |
| 18 | SHA256 string `json:"sha256"` |
| 19 | Bytes int `json:"bytes"` |
| 20 | } |
| 21 | if err := json.Unmarshal(raw, &record); err != nil { |
| 22 | t.Fatal(err) |
| 23 | } |
| 24 | sum := sha256.Sum256([]byte(lucideNotice)) |
| 25 | if record.Source != "https://raw.githubusercontent.com/lucide-icons/lucide/a79b2d131dab2bf20cb224bd0937b439a9c4fa99/LICENSE" || record.Bytes != len(lucideNotice) || record.SHA256 != hex.EncodeToString(sum[:]) { |
| 26 | t.Fatal("Lucide notice differs from original provenance") |
| 27 | } |
| 28 | } |
| 29 | |