MCPcopy
hub / github.com/minio/minio-go / TestPutObjectOptionsValidate

Function TestPutObjectOptionsValidate

api-put-object_test.go:29–69  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

27)
28
29func TestPutObjectOptionsValidate(t *testing.T) {
30 testCases := []struct {
31 name, value string
32 shouldPass bool
33 }{
34 // Invalid cases.
35 {"X-Amz-Matdesc", "blah", false},
36 {"x-amz-meta-X-Amz-Iv", "blah", false},
37 {"x-amz-meta-X-Amz-Key", "blah", false},
38 {"x-amz-meta-X-Amz-Matdesc", "blah", false},
39 {"It has spaces", "v", false},
40 {"It,has@illegal=characters", "v", false},
41 {"X-Amz-Iv", "blah", false},
42 {"X-Amz-Key", "blah", false},
43 {"X-Amz-Key-prefixed-header", "blah", false},
44 {"Content-Type", "custom/content-type", false},
45 {"content-type", "custom/content-type", false},
46 {"Content-Encoding", "gzip", false},
47 {"Cache-Control", "blah", false},
48 {"Content-Disposition", "something", false},
49 {"Content-Language", "somelanguage", false},
50
51 // Valid metadata names.
52 {"my-custom-header", "blah", true},
53 {"custom-X-Amz-Key-middle", "blah", true},
54 {"my-custom-header-X-Amz-Key", "blah", true},
55 {"blah-X-Amz-Matdesc", "blah", true},
56 {"X-Amz-MatDesc-suffix", "blah", true},
57 {"It-Is-Fine", "v", true},
58 {"Numbers-098987987-Should-Work", "v", true},
59 {"Crazy-!#$%&'*+-.^_`|~-Should-193832-Be-Fine", "v", true},
60 }
61 for i, testCase := range testCases {
62 err := PutObjectOptions{UserMetadata: map[string]string{
63 testCase.name: testCase.value,
64 }}.validate(nil)
65 if testCase.shouldPass && err != nil {
66 t.Errorf("Test %d - output did not match with reference results, %s", i+1, err)
67 }
68 }
69}
70
71type InterceptRouteTripper struct {
72 request *http.Request

Callers

nothing calls this directly

Calls 1

validateMethod · 0.45

Tested by

no test coverage detected