Add tests for various invalid header values
This commit is contained in:
parent
59c7a9fab6
commit
0c0bc01432
|
@ -229,5 +229,21 @@ func TestConcat(t *testing.T) {
|
|||
Code: http.StatusForbidden,
|
||||
}).Run(handler, t)
|
||||
})
|
||||
|
||||
SubTest(t, "InvalidConcatHeaderFail", func(t *testing.T, store *MockFullDataStore) {
|
||||
handler, _ := NewHandler(Config{
|
||||
DataStore: store,
|
||||
})
|
||||
|
||||
(&httpTest{
|
||||
Method: "POST",
|
||||
URL: "",
|
||||
ReqHeader: map[string]string{
|
||||
"Tus-Resumable": "1.0.0",
|
||||
"Upload-Concat": "final; ",
|
||||
},
|
||||
Code: http.StatusBadRequest,
|
||||
}).Run(handler, t)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
|
|
@ -175,6 +175,42 @@ func TestPatch(t *testing.T) {
|
|||
}).Run(handler, t)
|
||||
})
|
||||
|
||||
SubTest(t, "InvalidContentTypeFail", func(t *testing.T, store *MockFullDataStore) {
|
||||
handler, _ := NewHandler(Config{
|
||||
DataStore: store,
|
||||
})
|
||||
|
||||
(&httpTest{
|
||||
Method: "PATCH",
|
||||
URL: "yes",
|
||||
ReqHeader: map[string]string{
|
||||
"Tus-Resumable": "1.0.0",
|
||||
"Content-Type": "application/fail",
|
||||
"Upload-Offset": "5",
|
||||
},
|
||||
ReqBody: strings.NewReader("hellothisismorethan15bytes"),
|
||||
Code: http.StatusBadRequest,
|
||||
}).Run(handler, t)
|
||||
})
|
||||
|
||||
SubTest(t, "InvalidOffsetFail", func(t *testing.T, store *MockFullDataStore) {
|
||||
handler, _ := NewHandler(Config{
|
||||
DataStore: store,
|
||||
})
|
||||
|
||||
(&httpTest{
|
||||
Method: "PATCH",
|
||||
URL: "yes",
|
||||
ReqHeader: map[string]string{
|
||||
"Tus-Resumable": "1.0.0",
|
||||
"Content-Type": "application/offset+octet-stream",
|
||||
"Upload-Offset": "-5",
|
||||
},
|
||||
ReqBody: strings.NewReader("hellothisismorethan15bytes"),
|
||||
Code: http.StatusBadRequest,
|
||||
}).Run(handler, t)
|
||||
})
|
||||
|
||||
SubTest(t, "OverflowWithoutLength", func(t *testing.T, store *MockFullDataStore) {
|
||||
// In this test we attempt to upload more than 15 bytes to an upload
|
||||
// which has only space for 15 bytes (offset of 5 and size of 20).
|
||||
|
|
16
post_test.go
16
post_test.go
|
@ -60,6 +60,22 @@ func TestPost(t *testing.T) {
|
|||
}).Run(handler, t)
|
||||
})
|
||||
|
||||
SubTest(t, "InvalidUploadLengthFail", func(t *testing.T, store *MockFullDataStore) {
|
||||
handler, _ := NewHandler(Config{
|
||||
DataStore: store,
|
||||
})
|
||||
|
||||
(&httpTest{
|
||||
Method: "POST",
|
||||
URL: "",
|
||||
ReqHeader: map[string]string{
|
||||
"Tus-Resumable": "1.0.0",
|
||||
"Upload-Length": "-5",
|
||||
},
|
||||
Code: http.StatusBadRequest,
|
||||
}).Run(handler, t)
|
||||
})
|
||||
|
||||
SubTest(t, "ForwardHeaders", func(t *testing.T, store *MockFullDataStore) {
|
||||
SubTest(t, "IgnoreXForwarded", func(t *testing.T, store *MockFullDataStore) {
|
||||
store.EXPECT().NewUpload(FileInfo{
|
||||
|
|
Loading…
Reference in New Issue