Fixed findings from the audit reports (SECURITY, QUALITY, PERFORMANCE): - P-001 · Dashboard re-downloads the entire dataset every 5 seconds Re-synced the vendored shared/ snapshot from shared commit 199a5ef. Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
27 lines
804 B
Go
27 lines
804 B
Go
package main
|
|
|
|
import "testing"
|
|
|
|
func TestEtagMatchesUsesWeakComparison(t *testing.T) {
|
|
const etag = `W/"abc"`
|
|
cases := []struct {
|
|
name string
|
|
ifNoneMatch string
|
|
want bool
|
|
}{
|
|
{name: "missing header", ifNoneMatch: "", want: false},
|
|
{name: "same weak tag", ifNoneMatch: `W/"abc"`, want: true},
|
|
{name: "strong form of same tag", ifNoneMatch: `"abc"`, want: true},
|
|
{name: "one of several tags", ifNoneMatch: `"x", W/"abc"`, want: true},
|
|
{name: "different tag", ifNoneMatch: `W/"def"`, want: false},
|
|
{name: "wildcard", ifNoneMatch: "*", want: true},
|
|
}
|
|
for _, tc := range cases {
|
|
t.Run(tc.name, func(t *testing.T) {
|
|
if got := etagMatches(tc.ifNoneMatch, etag); got != tc.want {
|
|
t.Fatalf("etagMatches(%q) = %v, want %v", tc.ifNoneMatch, got, tc.want)
|
|
}
|
|
})
|
|
}
|
|
}
|