carlos / platform Public

tests: media tests follow main's request context; multipart Allow

planmedia_test.go called planBanner and planStage without the context
that main's c855db56 (signed-in requests query under the request
context) added as their first argument; the merge compiled the
production code but not this test. It now passes context.Background(),
as main's planpdf_test.go does.

aws_test.go's assertStorePolicyDocument still expected four object
actions after 8fe00819 added s3:AbortMultipartUpload and
s3:ListMultipartUploadParts to storePolicyJSON (spec section 5.6), so
TestEnsureUserFresh and TestEnsureUserAlreadyExists failed on the
branch. The exact set now names all six.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 72479466e3da3c585c1146cca840bf70efbec6e7 parent e9329d7
2 files changed, +11 −7
  • internal/console/planmedia_test.go +5 −4
  • internal/objstore/aws_test.go +6 −3
diff --git a/internal/console/planmedia_test.go b/internal/console/planmedia_test.go
index fbdd7977c..a83617158 100644
--- a/internal/console/planmedia_test.go
+++ b/internal/console/planmedia_test.go
@@ -1,6 +1,7 @@
package console
import (
+ "context"
"encoding/json"
"fmt"
"net/http/httptest"
@@ -247,7 +248,7 @@ func TestMediaCapNotices(t *testing.T) {
if err := fx.st.PutCapState(st); err != nil {
t.Fatal(err)
}
- lines, _ := fx.srv.planBanner(acct, RoleOwner, now)
+ lines, _ := fx.srv.planBanner(context.Background(), acct, RoleOwner, now)
if len(lines) != 1 || lines[0] != tc.banner {
t.Errorf("banner = %q, want %q", lines, tc.banner)
}
@@ -262,11 +263,11 @@ func TestMediaCapNotices(t *testing.T) {
}
// A bigger plan lifts the refusal at once; a new month drops the row.
fx.srv.cfg.PlanCatalog = mediaLimitCatalog(t, 1200)
- if lines, _ := fx.srv.planBanner(acct, RoleOwner, now); strings.Contains(strings.Join(lines, " "), "twice its media allowance") {
+ if lines, _ := fx.srv.planBanner(context.Background(), acct, RoleOwner, now); strings.Contains(strings.Join(lines, " "), "twice its media allowance") {
t.Errorf("larger plan still refuses: %q", lines)
}
next := time.Date(now.Year(), now.Month()+1, 1, 0, 0, 0, 0, time.UTC)
- if lines, _ := fx.srv.planBanner(acct, RoleOwner, next); len(lines) != 0 {
+ if lines, _ := fx.srv.planBanner(context.Background(), acct, RoleOwner, next); len(lines) != 0 {
t.Errorf("stale banner = %q", lines)
}
if got := usagePhrase(planNotice{Cap: capMedia, Used: 12001, Limit: 12000}); got != "12,001 of 12,000 media minutes this month" {
@@ -294,7 +295,7 @@ func TestMediaCapEmails(t *testing.T) {
t.Run(fmt.Sprint(tc.used), func(t *testing.T) {
st := evaluateCap(nil, capMedia, tc.used, 600, now)
st.AccountID = acct.ID
- _, body := fx.srv.planNoticeEmail(acct, []capState{st}, fx.srv.planStage(acct, now))
+ _, body := fx.srv.planNoticeEmail(acct, []capState{st}, fx.srv.planStage(context.Background(), acct, now))
lines := strings.Split(body, "\n")
if len(lines) < 3 || lines[2] != tc.line {
t.Fatalf("email body:\n%s\nwant line 3 %q", body, tc.line)
diff --git a/internal/objstore/aws_test.go b/internal/objstore/aws_test.go
index 2543efb62..115a2d6c1 100644
--- a/internal/objstore/aws_test.go
+++ b/internal/objstore/aws_test.go
@@ -555,12 +555,15 @@ func assertStorePolicyDocument(t *testing.T, doc, bucketARN string) {
// own object. s3:PutObjectTagging is deliberately absent and must stay
// absent — but absence alone was never the whole property, and believing
// it was left the x-amz-tagging upload route open. storePolicyJSON's
- // comment has the story; the Denys are what actually close it.
+ // comment has the story; the Denys are what actually close it. The two
+ // multipart actions (media conversion spec §5.6) let an app list and
+ // abandon a browser's multipart upload; neither writes data or tags.
wantActions := map[string]bool{
"s3:GetObject": true, "s3:PutObject": true, "s3:DeleteObject": true,
- "s3:GetObjectTagging": true,
+ "s3:GetObjectTagging": true,
+ "s3:AbortMultipartUpload": true, "s3:ListMultipartUploadParts": true,
}
- if objects.Effect != "Allow" || len(objects.Action) != 4 || objects.Resource != bucketARN+"/*" {
+ if objects.Effect != "Allow" || len(objects.Action) != len(wantActions) || objects.Resource != bucketARN+"/*" {
t.Fatalf("object statement = %+v", objects)
}
for _, a := range objects.Action {