(t *testing.T)
| 359 | } |
| 360 | |
| 361 | func TestPostPolicySetChecksum(t *testing.T) { |
| 362 | tests := []struct { |
| 363 | name string |
| 364 | checksum Checksum |
| 365 | wantErr bool |
| 366 | wantResult string |
| 367 | }{ |
| 368 | { |
| 369 | name: "valid checksum SHA256", |
| 370 | checksum: ChecksumSHA256.ChecksumBytes([]byte("somerandomdata")), |
| 371 | wantResult: `[["eq","$x-amz-checksum-algorithm","SHA256"],["eq","$x-amz-checksum-sha256","29/7Qm/iMzZ1O3zMbO0luv6mYWyS6JIqPYV9lc8w1PA="]]`, |
| 372 | }, |
| 373 | { |
| 374 | name: "valid checksum CRC32", |
| 375 | checksum: ChecksumCRC32.ChecksumBytes([]byte("somerandomdata")), |
| 376 | wantResult: `[["eq","$x-amz-checksum-algorithm","CRC32"],["eq","$x-amz-checksum-crc32","7sOPnw=="]]`, |
| 377 | }, |
| 378 | { |
| 379 | name: "empty checksum", |
| 380 | checksum: Checksum{}, |
| 381 | wantResult: "", |
| 382 | }, |
| 383 | } |
| 384 | for _, tt := range tests { |
| 385 | t.Run(tt.name, func(t *testing.T) { |
| 386 | pp := NewPostPolicy() |
| 387 | |
| 388 | err := pp.SetChecksum(tt.checksum) |
| 389 | if (err != nil) != tt.wantErr { |
| 390 | t.Errorf("%s: want error: %v, got: %v", tt.name, tt.wantErr, err) |
| 391 | } |
| 392 | |
| 393 | if tt.wantResult != "" { |
| 394 | result := pp.String() |
| 395 | if !strings.Contains(result, tt.wantResult) { |
| 396 | t.Errorf("%s: want result to contain: '%s', got: '%s'", tt.name, tt.wantResult, result) |
| 397 | } |
| 398 | } |
| 399 | }) |
| 400 | } |
| 401 | } |
| 402 | |
| 403 | func TestPostPolicySetEncryption(t *testing.T) { |
| 404 | tests := []struct { |
nothing calls this directly
no test coverage detected