Some checks failed
go: build dev binaries / cleanup (push) Successful in 4s
Codespell / Check for spelling errors (push) Failing after 3s
docker: build dev containers / build-rust-binaries (amd64, x86_64-unknown-linux-musl) (push) Failing after 3s
docker: build dev containers / build-dev-containers (push) Has been skipped
docker: build dev containers / build-rust-binaries (arm64, true, aarch64-unknown-linux-musl) (push) Failing after 3s
End to End / FUSE Mount (push) Failing after 2s
EC Integration Tests / EC Integration Tests (push) Failing after 30s
FUSE DLM Integration Tests / FUSE DLM Integration Tests (push) Failing after 3s
FUSE Volume Server Failover Tests / FUSE Volume Server Failover (push) Failing after 3s
FUSE Integration Tests / FUSE Integration Testing (push) Failing after 2s
FUSE P2P Peer Chunk Sharing Integration Tests / FUSE P2P Peer Chunk Sharing (push) Failing after 3s
go: build binary / Go Vet (push) Failing after 2s
go: build binary / Go Vet 32-bit (push) Failing after 3s
go: build binary / Build (push) Failing after 4s
go: build binary / Build cross-platform (freebsd/amd64) (push) Failing after 3s
go: build binary / Build cross-platform (windows/amd64) (push) Failing after 3s
go: build binary / Build cross-platform (darwin/arm64) (push) Failing after 3s
go: build binary / Build cross-platform (windows/arm64) (push) Failing after 3s
go: build binary / Test (push) Failing after 2s
go: build binary / Test 32-bit (push) Failing after 3s
helm: lint and test charts / lint-test (push) Failing after 3s
Java Client Integration Tests / Java Integration Tests (11) (push) Failing after 3s
Java Client Integration Tests / Java Integration Tests (17) (push) Failing after 3s
go: build dev binaries / build_dev_linux_windows (amd64, linux) (push) Failing after 2s
go: build dev binaries / build_dev_linux_windows (amd64, windows) (push) Failing after 3s
go: build dev binaries / build_dev_darwin (amd64, darwin) (push) Has been skipped
go: build dev binaries / build_dev_darwin (arm64, darwin) (push) Has been skipped
Java Client Unit Tests / Java Unit Tests (11) (push) Failing after 3s
Java Client Unit Tests / Java Unit Tests (17) (push) Failing after 2s
Java Client Unit Tests / Java Unit Tests (21) (push) Failing after 3s
Java Client Unit Tests / Java Unit Tests (8) (push) Failing after 3s
Kafka Quick Test (Load Test with Schema Registry) / Kafka Client Load Test (Quick) (push) Failing after 3s
Kafka Gateway Tests / Kafka Unit Tests (unit-tests-1) (push) Failing after 11s
Kafka Gateway Tests / Kafka Integration Tests (Critical) (integration-1) (push) Failing after 3s
Kafka Gateway Tests / Kafka End-to-End Tests (with SMQ) (e2e-1) (push) Failing after 3s
Kafka Gateway Tests / Kafka Consumer Group Tests (Highly Isolated) (consumer-group-1) (push) Failing after 2s
Kafka Gateway Tests / Kafka Client Compatibility (with SMQ) (client-compat-1) (push) Failing after 3s
Kafka Gateway Tests / Kafka SMQ Integration Tests (Full Stack) (smq-integration-1) (push) Failing after 3s
Kafka Gateway Tests / Kafka Protocol Tests (Isolated) (protocol-1) (push) Failing after 3s
KMS Tests / KMS Provider Integration Tests (push) Failing after 2s
KMS Tests / S3 KMS End-to-End Tests (push) Failing after 3s
Master Cold Start Tests / Master Cold Start Tests (push) Failing after 4s
Metadata Subscribe Integration Tests / Metadata Subscribe Integration Tests (push) Failing after 3s
Multi-Master Tests / Multi-Master Failover Tests (push) Failing after 3s
Performance / CPU and Heap Profile (push) Failing after 2s
Performance / S3 Read/Write Benchmark (rust volume) (push) Failing after 3s
pjdfstest POSIX Compliance / pjdfstest (push) Failing after 2s
Plugin Worker Integration Tests / Plugin Worker: erasure_coding (push) Failing after 3s
Plugin Worker Integration Tests / Plugin Worker: vacuum (push) Failing after 3s
Rust Volume Server Tests / Rust Integration Tests (push) Failing after 3s
Rust Volume Server Tests / Go Tests with Rust Volume (grpc - Shard 1) (push) Failing after 2s
Rust Volume Server Tests / Go Tests with Rust Volume (http - Shard 1) (push) Failing after 3s
Rust Volume Server Tests / Go Tests with Rust Volume (grpc - Shard 2) (push) Failing after 3s
Rust Volume Server Tests / Go Tests with Rust Volume (http - Shard 2) (push) Failing after 3s
Rust Volume Server Tests / Go Tests with Rust Volume (grpc - Shard 3) (push) Failing after 3s
S3 IAM Integration Tests / S3 IAM Distributed Tests (push) Failing after 2s
S3 IAM Integration Tests / S3 IAM Performance Tests (push) Failing after 3s
Performance / Throughput Benchmark (go volume) (push) Failing after 3s
Performance / Throughput Benchmark (rust volume) (push) Failing after 2s
Performance / S3 Read/Write Benchmark (go volume) (push) Failing after 3s
Plugin Worker Integration Tests / Plugin Worker: volume_balance (push) Failing after 3s
PostgreSQL Gateway Tests / PostgreSQL Basic Tests (push) Failing after 3s
Rust Volume Server Tests / Rust Unit Tests (push) Failing after 2s
Rust Volume Server Tests / Go Tests with Rust Volume (http - Shard 3) (push) Failing after 3s
Rust Plugin Worker Tests / Rust Plugin Worker Build and Unit Tests (push) Failing after 3s
rust: build dev volume server binaries / cleanup (push) Successful in 3s
S3 ETag and ACL Tests / S3 ETag + ACL Integration Tests (push) Failing after 3s
S3 IAM Integration Tests / IAM Unit Tests (push) Failing after 3s
S3 IAM Integration Tests / S3 IAM Integration Tests (advanced) (push) Failing after 3s
S3 IAM Integration Tests / S3 IAM Integration Tests (basic) (push) Failing after 2s
S3 IAM Integration Tests / S3 IAM Integration Tests (group) (push) Failing after 3s
S3 IAM Integration Tests / S3 IAM Integration Tests (policy-enforcement) (push) Failing after 2s
S3 IAM Integration Tests / S3 IAM Integration Tests (sts) (push) Failing after 4s
S3 Keycloak Integration Tests / S3 Keycloak Integration Tests (push) Failing after 3s
S3 PyArrow Parquet Tests / PyArrow Parquet Tests (Python 3.11) (push) Failing after 3s
S3 PyArrow Parquet Tests / Go Unit Tests (Implicit Directory) (push) Has been cancelled
S3 PyArrow Parquet Tests / PyArrow Parquet Tests (Python 3.12) (push) Has been cancelled
rust: build dev volume server binaries / build-rust-volume-dev-darwin (darwin-amd64, x86_64-apple-darwin) (push) Has been cancelled
rust: build dev volume server binaries / build-rust-volume-dev-darwin (darwin-arm64, aarch64-apple-darwin) (push) Has been cancelled
rust: build dev volume server binaries / build-rust-volume-dev-linux (linux-amd64, x86_64-unknown-linux-gnu) (push) Has been cancelled
S3 PyArrow Parquet Tests / PyArrow Parquet Tests (Python 3.9) (push) Has been cancelled
S3 Proxy Signature Tests / S3 Proxy Signature Verification Tests (push) Has been cancelled
S3 SDK V2 Route Disambiguation Tests / S3 SDK V2 Routing Tests (push) Has been cancelled
S3 SSE Tests / S3 SSE Integration Tests (quick) (push) Has been cancelled
S3 SSE Tests / S3 SSE Compatibility Test (push) Has been cancelled
S3 SSE Tests / S3 SSE Metadata Persistence Test (push) Has been cancelled
S3 SSE Tests / S3 SSE Copy Operations Test (push) Has been cancelled
S3 SSE Tests / S3 SSE Multipart Upload Test (push) Has been cancelled
S3 SSE Tests / S3 SSE Performance Test (push) Has been cancelled
S3 SSE Tests / S3 Volume Encryption Test (push) Has been cancelled
S3 SSE Tests / S3 SSE Integration Tests (comprehensive) (push) Has been cancelled
Spark Integration Tests / Spark Integration Tests (push) Failing after 2s
Telemetry Integration Tests / telemetry-integration-test (push) Failing after 3s
Volume Server Integration Tests / Volume Server Integration Tests (grpc - Shard 1) (push) Failing after 3s
Volume Server Integration Tests / Volume Server Integration Tests (http - Shard 1) (push) Failing after 3s
Ceph S3 tests / Basic S3 tests (KV store) (push) Has been cancelled
Ceph S3 tests / S3 Versioning & Object Lock tests (push) Has been cancelled
S3 Policy Integration Tests / S3 Policy Unit Tests (push) Failing after 3s
Ceph S3 tests / S3 CORS tests (push) Has been cancelled
Ceph S3 tests / SeaweedFS Custom S3 Copy tests (push) Has been cancelled
Ceph S3 tests / Basic S3 tests (SQL store) (push) Has been cancelled
test s3 over https using aws-cli / awscli-tests (push) Has been cancelled
TLS Rotation Integration Tests / TLS Rotation Integration Tests (push) Has been cancelled
Vacuum Integration Tests / Vacuum Integration Tests (push) Has been cancelled
S3 Policy Integration Tests / S3 Policy Variables Integration Tests (push) Failing after 3s
S3 Policy Integration Tests / S3 Policy Enforcement Integration Tests (advanced-policy) (push) Failing after 3s
S3 Policy Integration Tests / S3 Policy Enforcement Integration Tests (basic-policy) (push) Failing after 2s
S3 Policy Integration Tests / S3 Policy Enforcement Integration Tests (contextual-policy) (push) Failing after 4s
S3 Policy Integration Tests / Trusted Proxy Detection Tests (push) Failing after 2s
S3 Policy Integration Tests / S3 Policy Shell Integration Tests (push) Failing after 3s
Samba on FUSE Integration / samba-integration (push) Failing after 2s
SFTP Integration Tests / SFTP Integration Testing (push) Failing after 3s
terraform: validate and test modules / fmt, validate, plan-level tests (push) Failing after 3s
terraform: validate and test modules / local cluster smoke test (real weed) (push) Failing after 2s
Volume Server Integration Tests / Volume Server Integration Tests (grpc - Shard 3) (push) Failing after 3s
Volume Server Integration Tests / Volume Server Integration Tests (grpc - Shard 2) (push) Failing after 3s
Volume Server Integration Tests / Volume Server Integration Tests (http - Shard 2) (push) Failing after 2s
Volume Server Integration Tests / Volume Server Integration Tests (http - Shard 3) (push) Failing after 5s
mount: windows conformance / WinFsp conformance (push) Has been cancelled
mount: windows / Mount on Windows (push) Has been cancelled
311 lines
11 KiB
Go
311 lines
11 KiB
Go
package s3api
|
|
|
|
import (
|
|
"net/http"
|
|
"testing"
|
|
|
|
"github.com/seaweedfs/seaweedfs/weed/s3api/s3_constants"
|
|
)
|
|
|
|
func TestResolveDestinationMime(t *testing.T) {
|
|
cases := []struct {
|
|
name string
|
|
reqCT string
|
|
srcMime string
|
|
replaceMeta bool
|
|
want string
|
|
}{
|
|
{"COPY keeps source mime", "text/plain", "image/png", false, "image/png"},
|
|
{"COPY without request CT", "", "image/png", false, "image/png"},
|
|
{"COPY with empty source mime", "text/plain", "", false, ""},
|
|
{"REPLACE with request CT wins", "text/plain", "image/png", true, "text/plain"},
|
|
{"REPLACE without request CT uses default", "", "image/png", true, defaultCopyContentType},
|
|
{"REPLACE with request CT and empty source", "application/json", "", true, "application/json"},
|
|
{"REPLACE without request CT and empty source", "", "", true, defaultCopyContentType},
|
|
}
|
|
for _, c := range cases {
|
|
t.Run(c.name, func(t *testing.T) {
|
|
h := http.Header{}
|
|
if c.reqCT != "" {
|
|
h.Set("Content-Type", c.reqCT)
|
|
}
|
|
got := resolveDestinationMime(h, c.srcMime, c.replaceMeta)
|
|
if got != c.want {
|
|
t.Errorf("got %q want %q", got, c.want)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestIsValidDirective(t *testing.T) {
|
|
cases := []struct {
|
|
value string
|
|
want bool
|
|
}{
|
|
{"", true},
|
|
{DirectiveCopy, true},
|
|
{DirectiveReplace, true},
|
|
{"copy", false},
|
|
{"replace", false},
|
|
{"FOO", false},
|
|
{"REPLACE ", false},
|
|
}
|
|
for _, c := range cases {
|
|
t.Run(c.value, func(t *testing.T) {
|
|
if got := isValidDirective(c.value); got != c.want {
|
|
t.Errorf("isValidDirective(%q) = %v, want %v", c.value, got, c.want)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestProcessMetadataBytes_ReplaceSystemHeaders(t *testing.T) {
|
|
existing := map[string][]byte{
|
|
"Cache-Control": []byte("max-age=60"),
|
|
"Content-Disposition": []byte(`attachment; filename="old.bin"`),
|
|
}
|
|
req := http.Header{}
|
|
req.Set("Cache-Control", "no-cache")
|
|
req.Set("Content-Encoding", "gzip")
|
|
|
|
out, err := processMetadataBytes(req, existing, true /* replaceMeta */, false /* replaceTagging */)
|
|
if err != nil {
|
|
t.Fatalf("processMetadataBytes returned error: %v", err)
|
|
}
|
|
if got := string(out["Cache-Control"]); got != "no-cache" {
|
|
t.Errorf("Cache-Control = %q, want %q", got, "no-cache")
|
|
}
|
|
if got := string(out["Content-Encoding"]); got != "gzip" {
|
|
t.Errorf("Content-Encoding = %q, want %q", got, "gzip")
|
|
}
|
|
if _, present := out["Content-Disposition"]; present {
|
|
t.Errorf("Content-Disposition should be dropped under REPLACE when not in request, got %q", string(out["Content-Disposition"]))
|
|
}
|
|
}
|
|
|
|
func TestIsManagedCopyMetadataKey_CoversSystemHeaders(t *testing.T) {
|
|
for _, h := range copyReplaceSystemHeaders {
|
|
if !isManagedCopyMetadataKey(h) {
|
|
t.Errorf("isManagedCopyMetadataKey(%q) = false, want true so mergeCopyMetadata drops stale source values", h)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestIsManagedCopyMetadataKey_CaseInsensitive(t *testing.T) {
|
|
cases := []string{
|
|
"cache-control",
|
|
"CACHE-CONTROL",
|
|
"content-encoding",
|
|
"x-amz-meta-owner",
|
|
"X-AMZ-META-OWNER",
|
|
"x-amz-tagging-env",
|
|
}
|
|
for _, k := range cases {
|
|
t.Run(k, func(t *testing.T) {
|
|
if !isManagedCopyMetadataKey(k) {
|
|
t.Errorf("isManagedCopyMetadataKey(%q) = false, want true; legacy non-canonical keys must still be recognized so mergeCopyMetadata clears them", k)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestProcessMetadataBytes_CopyAcceptsLowercaseSourceKeys(t *testing.T) {
|
|
existing := map[string][]byte{
|
|
"cache-control": []byte("max-age=60"),
|
|
"content-disposition": []byte(`attachment; filename="legacy.bin"`),
|
|
"CONTENT-ENCODING": []byte("gzip"),
|
|
"Content-language": []byte("en"),
|
|
}
|
|
req := http.Header{}
|
|
|
|
out, err := processMetadataBytes(req, existing, false, false)
|
|
if err != nil {
|
|
t.Fatalf("processMetadataBytes error: %v", err)
|
|
}
|
|
if got := string(out["Cache-Control"]); got != "max-age=60" {
|
|
t.Errorf("Cache-Control = %q, want %q (lowercase source must be promoted to canonical)", got, "max-age=60")
|
|
}
|
|
if got := string(out["Content-Disposition"]); got != `attachment; filename="legacy.bin"` {
|
|
t.Errorf("Content-Disposition = %q, want legacy source value promoted to canonical", got)
|
|
}
|
|
if got := string(out["Content-Encoding"]); got != "gzip" {
|
|
t.Errorf("Content-Encoding = %q, want %q (uppercase source must be promoted to canonical)", got, "gzip")
|
|
}
|
|
if got := string(out["Content-Language"]); got != "en" {
|
|
t.Errorf("Content-Language = %q, want %q (mixed-case source must be promoted to canonical)", got, "en")
|
|
}
|
|
}
|
|
|
|
func TestProcessMetadataBytes_CopyCanonicalSystemHeaderWinsOverLegacy(t *testing.T) {
|
|
// When both canonical and legacy-cased variants live on the source,
|
|
// COPY must deterministically prefer the canonical value. Run several
|
|
// times to exercise different Go map iteration orders.
|
|
for i := 0; i < 32; i++ {
|
|
existing := map[string][]byte{
|
|
"Cache-Control": []byte("canonical-wins"),
|
|
"cache-control": []byte("legacy-loses"),
|
|
}
|
|
out, err := processMetadataBytes(http.Header{}, existing, false, false)
|
|
if err != nil {
|
|
t.Fatalf("processMetadataBytes error: %v", err)
|
|
}
|
|
if got := string(out["Cache-Control"]); got != "canonical-wins" {
|
|
t.Fatalf("iter %d: Cache-Control = %q, want canonical-wins (canonical must beat legacy on COPY)", i, got)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestProcessMetadataBytes_CopyCanonicalTagWinsOverLegacy(t *testing.T) {
|
|
for i := 0; i < 32; i++ {
|
|
existing := map[string][]byte{
|
|
"X-Amz-Tagging-env": []byte("canonical-wins"),
|
|
"x-amz-tagging-env": []byte("legacy-loses"),
|
|
}
|
|
out, err := processMetadataBytes(http.Header{}, existing, false, false)
|
|
if err != nil {
|
|
t.Fatalf("processMetadataBytes error: %v", err)
|
|
}
|
|
if got := string(out["X-Amz-Tagging-env"]); got != "canonical-wins" {
|
|
t.Fatalf("iter %d: X-Amz-Tagging-env = %q, want canonical-wins (canonical tag must beat legacy on COPY)", i, got)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestProcessMetadataBytes_CopyAcceptsLowercaseTagKeys(t *testing.T) {
|
|
existing := map[string][]byte{
|
|
"x-amz-tagging-env": []byte("prod"),
|
|
"X-AMZ-TAGGING-team": []byte("infra"),
|
|
}
|
|
req := http.Header{}
|
|
|
|
out, err := processMetadataBytes(req, existing, false /* replaceMeta */, false /* replaceTagging */)
|
|
if err != nil {
|
|
t.Fatalf("processMetadataBytes error: %v", err)
|
|
}
|
|
if got := string(out["X-Amz-Tagging-env"]); got != "prod" {
|
|
t.Errorf("X-Amz-Tagging-env = %q, want %q (legacy lowercase tag must be promoted to canonical)", got, "prod")
|
|
}
|
|
if got := string(out["X-Amz-Tagging-team"]); got != "infra" {
|
|
t.Errorf("X-Amz-Tagging-team = %q, want %q (uppercase tag must be promoted to canonical)", got, "infra")
|
|
}
|
|
}
|
|
|
|
func TestMergeCopyMetadata_ReplaceDropsStaleSystemHeader(t *testing.T) {
|
|
// End-to-end caller flow: source-populated Extended + REPLACE request
|
|
// must drop stale managed values, keep non-managed ones.
|
|
existing := map[string][]byte{
|
|
"Content-Disposition": []byte(`attachment; filename="old.bin"`),
|
|
"Cache-Control": []byte("max-age=60"),
|
|
"X-Amz-Meta-Owner": []byte("old"),
|
|
"X-Amz-Meta-OnlyOnSource": []byte("should-drop"),
|
|
"X-Custom-Non-Managed": []byte("keep-me"),
|
|
"X-Amz-Server-Side-Encryption": []byte("aws:kms"),
|
|
}
|
|
req := http.Header{}
|
|
req.Set("Cache-Control", "no-cache")
|
|
req.Set("X-Amz-Meta-Owner", "new")
|
|
|
|
processed, err := processMetadataBytes(req, existing, true, false)
|
|
if err != nil {
|
|
t.Fatalf("processMetadataBytes error: %v", err)
|
|
}
|
|
|
|
merged := mergeCopyMetadata(existing, processed)
|
|
|
|
if _, leak := merged["Content-Disposition"]; leak {
|
|
t.Errorf("Content-Disposition leaked through REPLACE merge: %q", string(merged["Content-Disposition"]))
|
|
}
|
|
if got := string(merged["Cache-Control"]); got != "no-cache" {
|
|
t.Errorf("Cache-Control = %q, want %q", got, "no-cache")
|
|
}
|
|
if got := string(merged["X-Amz-Meta-Owner"]); got != "new" {
|
|
t.Errorf("X-Amz-Meta-Owner = %q, want %q", got, "new")
|
|
}
|
|
if _, leak := merged["X-Amz-Meta-OnlyOnSource"]; leak {
|
|
t.Errorf("stale X-Amz-Meta-OnlyOnSource must be dropped under REPLACE, still present: %q", string(merged["X-Amz-Meta-OnlyOnSource"]))
|
|
}
|
|
if got := string(merged["X-Custom-Non-Managed"]); got != "keep-me" {
|
|
t.Errorf("non-managed key %q must survive REPLACE merge, got %q", "X-Custom-Non-Managed", got)
|
|
}
|
|
}
|
|
|
|
func TestMergeCopyMetadata_ReplaceTaggingDropsStaleTags(t *testing.T) {
|
|
// REPLACE tagging directive must drop old object tags that the new
|
|
// request doesn't redeclare.
|
|
existing := map[string][]byte{
|
|
"X-Amz-Tagging-old": []byte("v1"),
|
|
"X-Amz-Tagging-env": []byte("dev"),
|
|
"X-Amz-Meta-Author": []byte("alice"),
|
|
}
|
|
req := http.Header{}
|
|
req.Set("X-Amz-Tagging", "env=prod")
|
|
|
|
processed, err := processMetadataBytes(req, existing, false /* replaceMeta */, true /* replaceTagging */)
|
|
if err != nil {
|
|
t.Fatalf("processMetadataBytes error: %v", err)
|
|
}
|
|
|
|
merged := mergeCopyMetadata(existing, processed)
|
|
|
|
if _, leak := merged["X-Amz-Tagging-old"]; leak {
|
|
t.Errorf("stale tag X-Amz-Tagging-old must be dropped, still present: %q", string(merged["X-Amz-Tagging-old"]))
|
|
}
|
|
if got := string(merged["X-Amz-Tagging-env"]); got != "prod" {
|
|
t.Errorf("X-Amz-Tagging-env = %q, want %q", got, "prod")
|
|
}
|
|
if got := string(merged["X-Amz-Meta-Author"]); got != "alice" {
|
|
t.Errorf("COPY-mode user metadata must survive tag-only REPLACE: got %q", got)
|
|
}
|
|
}
|
|
|
|
func TestProcessMetadataBytes_CopyInheritsSystemHeaders(t *testing.T) {
|
|
existing := map[string][]byte{
|
|
"Cache-Control": []byte("max-age=60"),
|
|
"Content-Disposition": []byte(`attachment; filename="src.bin"`),
|
|
"Content-Encoding": []byte("gzip"),
|
|
}
|
|
req := http.Header{}
|
|
req.Set("Cache-Control", "no-cache")
|
|
|
|
out, err := processMetadataBytes(req, existing, false /* replaceMeta */, false /* replaceTagging */)
|
|
if err != nil {
|
|
t.Fatalf("processMetadataBytes returned error: %v", err)
|
|
}
|
|
if got := string(out["Cache-Control"]); got != "max-age=60" {
|
|
t.Errorf("Cache-Control = %q, want %q (source value, request ignored under COPY)", got, "max-age=60")
|
|
}
|
|
if got := string(out["Content-Disposition"]); got != `attachment; filename="src.bin"` {
|
|
t.Errorf("Content-Disposition = %q, want source value", got)
|
|
}
|
|
if got := string(out["Content-Encoding"]); got != "gzip" {
|
|
t.Errorf("Content-Encoding = %q, want %q", got, "gzip")
|
|
}
|
|
}
|
|
|
|
func TestProcessMetadataBytes_CopyAppliesRequestedSSES3Header(t *testing.T) {
|
|
req := http.Header{}
|
|
req.Set(s3_constants.AmzServerSideEncryption, s3_constants.SSEAlgorithmAES256)
|
|
|
|
out, err := processMetadataBytes(req, nil, false, false)
|
|
if err != nil {
|
|
t.Fatalf("processMetadataBytes returned error: %v", err)
|
|
}
|
|
if got := string(out[s3_constants.AmzServerSideEncryption]); got != s3_constants.SSEAlgorithmAES256 {
|
|
t.Fatalf("%s = %q, want %q", s3_constants.AmzServerSideEncryption, got, s3_constants.SSEAlgorithmAES256)
|
|
}
|
|
}
|
|
|
|
func TestProcessMetadataBytes_CopyPreservesSourceSSEWhenRequestOmitsHeader(t *testing.T) {
|
|
existing := map[string][]byte{
|
|
s3_constants.AmzServerSideEncryption: []byte(s3_constants.SSEAlgorithmKMS),
|
|
}
|
|
|
|
out, err := processMetadataBytes(http.Header{}, existing, false, false)
|
|
if err != nil {
|
|
t.Fatalf("processMetadataBytes returned error: %v", err)
|
|
}
|
|
if got := string(out[s3_constants.AmzServerSideEncryption]); got != s3_constants.SSEAlgorithmKMS {
|
|
t.Fatalf("%s = %q, want %q", s3_constants.AmzServerSideEncryption, got, s3_constants.SSEAlgorithmKMS)
|
|
}
|
|
}
|