test(backup, scrobble, playevents, recsettings, apierror, auth, providers): merge repeated cases (#8299)
release / web (push) Successful in 1m41s
release / go (push) Successful in 2m4s
release / govulncheck (push) Successful in 23s
release / integration (push) Successful in 3m5s
release / Attach APK to the Release (tag releases only) (push) Canceled after 0s
release / Build + push container image (push) Canceled after 0s
release / Publish the release image to GHCR (dispatch only) (push) Canceled after 0s
release / Verify release artifacts (tag releases only) (push) Canceled after 0s
release / android (push) Canceled after 4m35s
release / Build signed APK (push) Canceled after 3m53s

- backup: schema coverage's three tests and the three AWS signing
  examples, one table each.
- scrobble: Qualifies' six boundary tests; the ListenBrainz client's
  refusal mapping, twelve tests of the same rule across three calls, one
  table over call x status; the two similarity lookups' success and URL
  tests, one table.
- playevents: the skip rule's three plays share one fixture. Dropped
  TestRecordPlayEnded_SubThreshold_NoEnqueue: the writer only calls
  scrobble.MaybeEnqueue, whose own test and Qualifies' table hold that
  case; the qualifying-play test still proves the writer calls it.
- recsettings: the three tag-scale tests share one database reset.
- apierror: Error() and From, one test each; auth: RequireAdmin's three.
- providers: GetJSON's not-found and transient answers, one table. Its
  two 401 tests expected the same answer with and without
  TreatAuthAsTransient, which changes only the error's text; the table
  says so.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-02 15:16:20 -05:00
co-authored by Claude Opus 5.5
parent b6454270b5
commit cfdbfa30e3
9 changed files with 306 additions and 628 deletions
+30 -30
View File
@@ -22,37 +22,37 @@ const (
var awsTime = time.Date(2013, 5, 24, 0, 0, 0, 0, time.UTC)
func TestSignMatchesAWSsGetObjectExample(t *testing.T) {
req, _ := http.NewRequest(http.MethodGet, "http://examplebucket.s3.amazonaws.com/test.txt", nil)
req.Header.Set("Range", "bytes=0-9")
sign(req, emptySHA256, awsAccessKey, awsSecretKey, "us-east-1", awsTime)
want := awsCred + ", SignedHeaders=host;range;x-amz-content-sha256;x-amz-date, Signature=f0e8bdb87c964420e857bd35b5d6ed310bd44f0170aba48dd91039c6036bdb41"
if got := req.Header.Get("Authorization"); got != want {
t.Errorf("Authorization =\n%s\nwant\n%s", got, want)
func TestSignMatchesAWSsExamples(t *testing.T) {
put := "Welcome to Amazon S3."
if got := hexSHA256([]byte(put)); got != "44ce7dd67c959e0d3524ffac1771dfbba87d2b6b4b4e99e42034a8b803f8b072" {
t.Fatalf("payload hash = %s", got)
}
}
func TestSignMatchesAWSsPutObjectExample(t *testing.T) {
req, _ := http.NewRequest(http.MethodPut, "http://examplebucket.s3.amazonaws.com/test$file.text", strings.NewReader("Welcome to Amazon S3."))
req.Header.Set("Date", "Fri, 24 May 2013 00:00:00 GMT")
req.Header.Set("X-Amz-Storage-Class", "REDUCED_REDUNDANCY")
payload := hexSHA256([]byte("Welcome to Amazon S3."))
if payload != "44ce7dd67c959e0d3524ffac1771dfbba87d2b6b4b4e99e42034a8b803f8b072" {
t.Fatalf("payload hash = %s", payload)
}
sign(req, payload, awsAccessKey, awsSecretKey, "us-east-1", awsTime)
want := awsCred + ", SignedHeaders=date;host;x-amz-content-sha256;x-amz-date;x-amz-storage-class, Signature=98ad721746da40c64f1a55b78f14c238d841ea1380cd77a1b5971af0ece108bd"
if got := req.Header.Get("Authorization"); got != want {
t.Errorf("Authorization =\n%s\nwant\n%s", got, want)
}
}
func TestSignMatchesAWSsListObjectsExample(t *testing.T) {
req, _ := http.NewRequest(http.MethodGet, "http://examplebucket.s3.amazonaws.com/?max-keys=2&prefix=J", nil)
sign(req, emptySHA256, awsAccessKey, awsSecretKey, "us-east-1", awsTime)
want := awsCred + ", SignedHeaders=host;x-amz-content-sha256;x-amz-date, Signature=34b48302e7b5fa45bde8084f4b7868a86f0a534bc59db6670ed5711ef69dc6f7"
if got := req.Header.Get("Authorization"); got != want {
t.Errorf("Authorization =\n%s\nwant\n%s", got, want)
for _, tc := range []struct {
name, method, url, body string
headers map[string]string
want string // after the credential
}{
{"GET object", http.MethodGet, "http://examplebucket.s3.amazonaws.com/test.txt", "",
map[string]string{"Range": "bytes=0-9"},
"SignedHeaders=host;range;x-amz-content-sha256;x-amz-date, Signature=f0e8bdb87c964420e857bd35b5d6ed310bd44f0170aba48dd91039c6036bdb41"},
{"PUT object", http.MethodPut, "http://examplebucket.s3.amazonaws.com/test$file.text", put,
map[string]string{"Date": "Fri, 24 May 2013 00:00:00 GMT", "X-Amz-Storage-Class": "REDUCED_REDUNDANCY"},
"SignedHeaders=date;host;x-amz-content-sha256;x-amz-date;x-amz-storage-class, Signature=98ad721746da40c64f1a55b78f14c238d841ea1380cd77a1b5971af0ece108bd"},
{"list objects", http.MethodGet, "http://examplebucket.s3.amazonaws.com/?max-keys=2&prefix=J", "", nil,
"SignedHeaders=host;x-amz-content-sha256;x-amz-date, Signature=34b48302e7b5fa45bde8084f4b7868a86f0a534bc59db6670ed5711ef69dc6f7"},
} {
req, _ := http.NewRequest(tc.method, tc.url, strings.NewReader(tc.body))
for k, v := range tc.headers {
req.Header.Set(k, v)
}
payload := emptySHA256
if tc.body != "" {
payload = hexSHA256([]byte(tc.body))
}
sign(req, payload, awsAccessKey, awsSecretKey, "us-east-1", awsTime)
if got, want := req.Header.Get("Authorization"), awsCred+", "+tc.want; got != want {
t.Errorf("%s: Authorization =\n%s\nwant\n%s", tc.name, got, want)
}
}
}